Last updated: 2020-09-17

Checks: 7 0

Knit directory: IITA_2020GS/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20200915) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 7ea8b80. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rproj.user/
    Ignored:    analysis/.DS_Store
    Ignored:    data/.DS_Store

Untracked files:
    Untracked:  data/2019_GS_PhenoUpload.csv
    Untracked:  data/DCas19_4301_DArTseqLD_AllSites_AllChrom_raw_70919.samples
    Untracked:  data/GBSdataMasterList_31818.csv
    Untracked:  data/IITA_GBStoPhenoMaster_33018.csv
    Untracked:  data/NRCRI_GBStoPhenoMaster_40318.csv
    Untracked:  data/cassavabase_download_screen.png
    Untracked:  data/chr1_RefPanelAndGSprogeny_ReadyForGP_72719.fam
    Untracked:  data/dartOnlySamplesToImpute_72619.txt
    Untracked:  output/GEBV_IITA_ModelA_2020Sep16.csv
    Untracked:  output/GETGV_IITA_ModelADE_2020Sep16.csv
    Untracked:  output/IITA_CuratedTrials.rds
    Untracked:  output/IITA_ExptDesignsDetected.rds
    Untracked:  output/all_iita_metadata.csv
    Untracked:  output/genomicPredictions_ModelADE_IITA_2020Sep16.rds
    Untracked:  output/genomicPredictions_ModelA_IITA_2020Sep16.rds
    Untracked:  output/iita_blupsForModelTraining.rds
    Untracked:  output/iita_trials_NOT_identifiable.csv
    Untracked:  output/maxNOHAV_byStudy.csv
    Untracked:  workflowr_log.R

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/03-GetBLUPs.Rmd) and HTML (docs/03-GetBLUPs.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 7ea8b80 wolfemd 2020-09-17 All steps including genomic predicting (excluding cross-validation),

Previous step

  1. Curate by trait-trial: Model each trait-trial separately, remove outliers, get BLUPs.

This step

Two-stage genomic prediction refers to the following procedure:

Stage 1: Fit a linear mixed model to the data without genomic data. Individuals (e.g. clones / accessions) are modeled as independent and identically distributed (i.i.d.) random effects. The BLUPs for this random effect represent the measurable total genetic values of each individual. All the experimental design variation, e.g. replication and blocking effects have been controlled for in the creation of our new response variable, the BLUPs from the gneotype random effect.

Stage 2: Using a modified version of the BLUPs from step 1 as the response variable, fit a genomic prediction model, which now has reduced size because the number of observations is now the same as the number of individuals.

NOTE: In the animal breeding literature single-step often refers to predictions that combine pedigree and marker information simultaneously. That is not our meaning here.

The code below represents Stage I.

Set-up training datasets

This next step fits models to each trait, combining curated data (BLUPs) from each trial, which we computed in the previous step.

rm(list=ls())
library(tidyverse); library(magrittr);
source(here::here("code","gsFunctions.R"))
dbdata<-readRDS(here::here("output","IITA_CuratedTrials.rds"))
traits<-c("MCMDS","DM","PLTHT","BRNHT1","BRLVLS","HI","logFYLD","logTOPYLD","logRTNO","TCHART","LCHROMO","ACHROMO","BCHROMO")

Starting with the curated trial data (which correspond to per-trait, per-trial BLUPs) from the previous step.

Nest by trait. Need to restructure the data from per-trial BLUPs by regrouping by trait.

dbdata<-nestForMultiTrialAnalysis(dbdata)
dbdata %>% mutate(N_blups=map_dbl(MultiTrialTraitData,nrow)) %>% rmarkdown::paged_table()

Model multiple trials

Function fitMultiTrialModel() takes de-regressed BLUPs as response and corresponding weights on error variances are applied. Output includes BLUPs for each clone that combine data across trials and are suitable for downstream genomic prediction work.

Apply the fitMultiTrialModel() to each chunk of trials (per trait) using the purrr function map().

dbdata %<>% 
  mutate(modelOutput=map(MultiTrialTraitData,fitMultiTrialModel))
dbdata %>% 
  select(-MultiTrialTraitData) %>% 
  unnest(modelOutput) %>% 
  unnest(VarComps) %>% rmarkdown::paged_table()

Output file

saveRDS(dbdata,file=here::here("output","iita_blupsForModelTraining.rds"))

Next step

  1. Check prediction accuracy: Evaluate prediction accuracy with cross-validation.

sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] lme4_1.1-23     Matrix_1.2-18   magrittr_1.5    forcats_0.5.0  
 [5] stringr_1.4.0   dplyr_1.0.2     purrr_0.3.4     readr_1.3.1    
 [9] tidyr_1.1.2     tibble_3.0.3    ggplot2_3.3.2   tidyverse_1.3.0
[13] workflowr_1.6.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5       lubridate_1.7.9  here_0.1         lattice_0.20-41 
 [5] assertthat_0.2.1 rprojroot_1.3-2  digest_0.6.25    R6_2.4.1        
 [9] cellranger_1.1.0 backports_1.1.9  reprex_0.3.0     evaluate_0.14   
[13] httr_1.4.2       pillar_1.4.6     rlang_0.4.7      readxl_1.3.1    
[17] minqa_1.2.4      rstudioapi_0.11  nloptr_1.2.2.2   whisker_0.4     
[21] blob_1.2.1       rmarkdown_2.3    splines_4.0.2    statmod_1.4.34  
[25] munsell_0.5.0    broom_0.7.0      compiler_4.0.2   httpuv_1.5.4    
[29] modelr_0.1.8     xfun_0.17        pkgconfig_2.0.3  htmltools_0.5.0 
[33] tidyselect_1.1.0 fansi_0.4.1      crayon_1.3.4     dbplyr_1.4.4    
[37] withr_2.2.0      later_1.1.0.1    MASS_7.3-53      grid_4.0.2      
[41] nlme_3.1-149     jsonlite_1.7.1   gtable_0.3.0     lifecycle_0.2.0 
[45] DBI_1.1.0        git2r_0.27.1     scales_1.1.1     cli_2.0.2       
[49] stringi_1.5.3    fs_1.5.0         promises_1.1.1   xml2_1.3.2      
[53] ellipsis_0.3.1   generics_0.0.2   vctrs_0.3.4      boot_1.3-25     
[57] tools_4.0.2      glue_1.4.2       hms_0.5.3        yaml_2.2.1      
[61] colorspace_1.4-1 rvest_0.3.6      knitr_1.29       haven_2.3.1