Last updated: 2020-11-27

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 1f8cd99. 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:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.DS_Store
    Ignored:    data/.DS_Store
    Ignored:    output/.DS_Store

Untracked files:
    Untracked:  data/GEBV_IITA_OutliersRemovedTRUE_73119.csv
    Untracked:  data/iita_blupsForCrossVal_outliersRemoved_73019.rds
    Untracked:  data/~$pedigreeGeneticGainCycleTime.xlsx
    Untracked:  output/DosageMatrix_IITA_2020Sep16.rds
    Untracked:  output/Kinship_AA_IITA_2020Sep16.rds
    Untracked:  output/Kinship_AD_IITA_2020Sep16.rds
    Untracked:  output/Kinship_A_IITA_2020Sep16.rds
    Untracked:  output/Kinship_DD_IITA2020Sep16.rds
    Untracked:  output/Kinship_D_IITA_2020Sep16.rds
    Untracked:  output/cvresults_ModelADE_chunk1.rds
    Untracked:  output/cvresults_ModelADE_chunk2.rds
    Untracked:  output/cvresults_ModelADE_chunk3.rds
    Untracked:  output/genomicPredictions_ModelADE_threestage_IITA_2020Sep21.rds
    Untracked:  output/genomicPredictions_ModelA_threestage_IITA_2020Sep21.rds
    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/06-Results.Rmd) and HTML (docs/06-Results.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 1f8cd99 wolfemd 2020-11-27 Added plots of genetic gain for 4 traits. Initial analysis of GEBV vs.
html d72a9ed wolfemd 2020-09-21 Build site.
html 9194239 wolfemd 2020-09-21 Build site.
Rmd 97778e7 wolfemd 2020-09-21 Big update. Two types of pipeline to get BLUPs, GEBVs and GETGVs:

Cross-validation accuracy

Conducted 5-fold x 5-reps of cross-validation (here). Three traits only, MCMDS, logFYLD, DM.

library(tidyverse)
library(magrittr)
cvresults <- readRDS(here::here("output", "cvresults_ModelA_chunk1.rds")) %>% bind_rows(readRDS(here::here("output", 
    "cvresults_ModelA_chunk2.rds"))) %>% bind_rows(readRDS(here::here("output", "cvresults_ModelA_chunk3.rds")))
cvresults %>% select(Trait, repeats, id, VersionOfBLUPs, accGEBV) %>% ggplot(., aes(x = Trait, 
    y = accGEBV, fill = VersionOfBLUPs)) + geom_boxplot() + theme_bw() + scale_fill_viridis_d() + 
    labs(title = "Compare 3-stage and 2-stage prediction pipelines", subtitle = "Model: Additive-only")

Version Author Date
9194239 wolfemd 2020-09-21
cvresults %>% select(Trait, repeats, id, VersionOfBLUPs, accGEBV) %>% spread(VersionOfBLUPs, 
    accGEBV) %>% mutate(diffAcc = blups2stage - blups3stage) %>% ggplot(., aes(x = Trait, 
    y = diffAcc, fill = Trait)) + geom_hline(yintercept = 0, color = "darkred") + 
    geom_boxplot() + theme_bw() + scale_fill_viridis_d() + labs(y = "Accuracy Difference (2-stage minus 3-stage)", 
    subtitle = "Model: Additive-only")

Version Author Date
9194239 wolfemd 2020-09-21

Genetic Gain

library(tidyverse)
library(magrittr)
iita_gebvs <- read.csv(here::here("output", "GEBV_IITA_ModelA_twostage_IITA_2020Sep21.csv"), 
    stringsAsFactors = F)
traits <- c("DM", "logFYLD", "logTOPYLD", "MCMDS")
iita_gebvs %>% select(GID, GeneticGroup, any_of(traits)) %>% pivot_longer(cols = any_of(traits), 
    names_to = "Trait", values_to = "GEBV") %>% group_by(Trait, GeneticGroup) %>% 
    summarize(meanGEBV = mean(GEBV), stdErr = sd(GEBV)/sqrt(n()), upperSE = meanGEBV + 
        stdErr, lowerSE = meanGEBV - stdErr) %>% ggplot(., aes(x = GeneticGroup, 
    y = meanGEBV, fill = Trait)) + geom_bar(stat = "identity", color = "gray60", 
    size = 1.25) + geom_linerange(aes(ymax = upperSE, ymin = lowerSE), color = "gray60", 
    size = 1.25) + facet_wrap(~Trait, scales = "free_y", ncol = 1) + theme_bw() + 
    geom_hline(yintercept = 0, size = 1.15, color = "black") + theme(axis.text.x = element_text(face = "bold", 
    angle = 0, size = 12), axis.title.y = element_text(face = "bold", size = 14), 
    legend.position = "none", strip.background.x = element_blank(), strip.text = element_text(face = "bold", 
        size = 14)) + scale_fill_viridis_d() + labs(x = NULL, y = "Mean GEBVs")

Rate of gain

library(tidyverse)
library(magrittr)
iita_gebvs <- read.csv(here::here("output", "GEBV_IITA_ModelA_twostage_IITA_2020Sep21.csv"), 
    stringsAsFactors = F)
traits <- c("DM", "logFYLD", "logTOPYLD", "MCMDS")

ggcycletime <- readxl::read_xlsx(here::here("data", "pedigreeGeneticGainCycleTime.xlsx"))
table(ggcycletime$Accession %in% iita_gebvs$GID)

FALSE 
  807 

Need germplasmName field from raw trial data to match GEBV and cycle time

library(tidyverse)
library(magrittr)
dbdata <- readRDS(here::here("output", "IITA_ExptDesignsDetected.rds"))


iita_gebvs %<>% left_join(dbdata %>% select(-MaxNOHAV) %>% unnest(TrialData) %>% 
    distinct(germplasmName, GID)) %>% group_by(GID) %>% slice(1) %>% ungroup()
table(ggcycletime$Accession %in% iita_gebvs$germplasmName)

FALSE  TRUE 
  193   614 
iita_gebvs %<>% left_join(., ggcycletime %>% rename(germplasmName = Accession))
iita_gebvs %<>% mutate(Year_Accession = case_when(grepl("2013_|TMS13", germplasmName) ~ 
    2013, grepl("TMS14", germplasmName) ~ 2014, grepl("TMS15", germplasmName) ~ 2015, 
    grepl("TMS18", germplasmName) ~ 2018, !grepl("2013_|TMS13|TMS14|TMS15|TMS18", 
        germplasmName) ~ Year_Accession))
iita_gebvs %>% 
  select(germplasmName,GeneticGroup,Year_Accession,any_of(traits)) %>% 
  pivot_longer(cols=any_of(traits),names_to = "Trait",values_to = "GEBV") %>% 
  ggplot(.,aes(x=Year_Accession,y=GEBV,color=GeneticGroup)) + 
  geom_point() + 
  facet_wrap(~Trait,scales='free_y', ncol=1) + 
  theme_bw() +
#  geom_hline(yintercept = 0, size=1.15, color='black') + 
  theme(axis.text.x = element_text(face = 'bold',angle = 0, size=12),
        axis.title.y = element_text(face = 'bold',size=14),
        #legend.position = 'none',
        strip.background.x = element_blank(),
        strip.text = element_text(face='bold',size=14)) + 
  scale_color_viridis_d()

#  labs(x=NULL,y="Mean GEBVs")
iita_gebvs %>% select(germplasmName, GeneticGroup, Year_Accession, any_of(traits)) %>% 
    mutate(GeneticGroup = ifelse(Year_Accession >= 2013, "GS", "PreGS")) %>% pivot_longer(cols = any_of(traits), 
    names_to = "Trait", values_to = "GEBV") %>% group_by(Trait, GeneticGroup, Year_Accession) %>% 
    summarize(meanGEBV = mean(GEBV), Nclones = n(), stdErr = sd(GEBV)/sqrt(n()), 
        upperSE = meanGEBV + stdErr, lowerSE = meanGEBV - stdErr) %>% ggplot(., aes(x = Year_Accession, 
    y = meanGEBV, color = GeneticGroup, size = Nclones)) + geom_point(size = 4) + 
    geom_smooth(method = lm, se = TRUE) + geom_linerange(aes(ymax = upperSE, ymin = lowerSE), 
    color = "gray40", size = 1) + facet_wrap(~Trait, scales = "free_y", ncol = 1) + 
    theme_bw() + theme(axis.text = element_text(face = "bold", angle = 0, size = 14), 
    axis.title = element_text(face = "bold", size = 16), strip.background.x = element_blank(), 
    strip.text = element_text(face = "bold", size = 18)) + scale_color_viridis_d()


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

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] magrittr_2.0.1  forcats_0.5.0   stringr_1.4.0   dplyr_1.0.2    
 [5] purrr_0.3.4     readr_1.4.0     tidyr_1.1.2     tibble_3.0.4   
 [9] ggplot2_3.3.2   tidyverse_1.3.0 workflowr_1.6.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5        lattice_0.20-41   lubridate_1.7.9.2 here_1.0.0       
 [5] assertthat_0.2.1  rprojroot_2.0.2   digest_0.6.27     R6_2.5.0         
 [9] cellranger_1.1.0  backports_1.2.0   reprex_0.3.0      evaluate_0.14    
[13] httr_1.4.2        pillar_1.4.6      rlang_0.4.8       readxl_1.3.1     
[17] rstudioapi_0.13   whisker_0.4       Matrix_1.2-18     rmarkdown_2.5    
[21] labeling_0.4.2    splines_4.0.2     munsell_0.5.0     broom_0.7.2      
[25] compiler_4.0.2    httpuv_1.5.4      modelr_0.1.8      xfun_0.19        
[29] pkgconfig_2.0.3   mgcv_1.8-33       htmltools_0.5.0   tidyselect_1.1.0 
[33] fansi_0.4.1       viridisLite_0.3.0 crayon_1.3.4      dbplyr_2.0.0     
[37] withr_2.3.0       later_1.1.0.1     grid_4.0.2        nlme_3.1-150     
[41] jsonlite_1.7.1    gtable_0.3.0      lifecycle_0.2.0   DBI_1.1.0        
[45] git2r_0.27.1      formatR_1.7       scales_1.1.1      cli_2.1.0        
[49] stringi_1.5.3     farver_2.0.3      fs_1.5.0          promises_1.1.1   
[53] xml2_1.3.2        ellipsis_0.3.1    generics_0.1.0    vctrs_0.3.5      
[57] tools_4.0.2       glue_1.4.2        hms_0.5.3         yaml_2.2.1       
[61] colorspace_2.0-0  rvest_0.3.6       knitr_1.30        haven_2.3.1