Last updated: 2021-03-24
Checks: 7 0
Knit directory: PredictOutbredCrossVar/
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(20191123)
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 f73b05f. 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: output/.DS_Store
Untracked files:
Untracked: Icon
Untracked: PredictOutbredCrossVarMS_ResponseToReviews_R1.gdoc
Untracked: figure/
Untracked: manuscript/
Untracked: output/crossPredictions/
Untracked: output/gblups_DirectionalDom_parentwise_crossVal_folds.rds
Untracked: output/gblups_geneticgroups.rds
Untracked: output/gblups_parentwise_crossVal_folds.rds
Untracked: output/mtMarkerEffects/
Unstaged changes:
Modified: analysis/NGCleadersCall.Rmd
Modified: code/fitDirectionalDomMtBRR.R
Modified: code/fitmtBRR.R
Modified: code/getDirectionalDomGenomicBLUPs.R
Modified: code/getDirectionalDomMtCrossMeanPreds.R
Modified: code/getDirectionalDomMtCrossVarBVpreds.R
Modified: code/getDirectionalDomMtCrossVarTGVpreds.R
Modified: code/getDirectionalDomVarComps.R
Modified: code/getGenomicBLUPs.R
Modified: code/getMtCrossMeanPreds.R
Modified: code/getMtCrossVarPreds.R
Modified: code/getUntestedMtCrossVarPreds.R
Modified: code/getVarComps.R
Modified: data/blups_forawcdata.rds
Modified: data/genmap_awc_May2020.rds
Modified: data/parentwise_crossVal_folds.rds
Modified: data/ped_awc.rds
Modified: data/selection_index_weights_4traits.rds
Modified: output/CrossesToPredict_top100stdSI_and_209originalParents.rds
Modified: output/accuraciesMeans.rds
Modified: output/accuraciesUC.rds
Modified: output/accuraciesVars.rds
Modified: output/crossRealizations/realizedCrossMeans.rds
Modified: output/crossRealizations/realizedCrossMeans_BLUPs.rds
Modified: output/crossRealizations/realizedCrossMetrics.rds
Modified: output/crossRealizations/realizedCrossVars.rds
Modified: output/crossRealizations/realizedCrossVars_BLUPs.rds
Modified: output/crossRealizations/realized_cross_means_and_covs_traits.rds
Modified: output/crossRealizations/realized_cross_means_and_vars_selindices.rds
Modified: output/ddEffects.rds
Modified: output/gebvs_ModelA_GroupAll_stdSI.rds
Modified: output/obsVSpredMeans.rds
Modified: output/obsVSpredUC.rds
Modified: output/obsVSpredVars.rds
Modified: output/pmv_DirectionalDom_varcomps_geneticgroups.rds
Modified: output/pmv_varcomps_geneticgroups.rds
Modified: output/pmv_varcomps_geneticgroups_tidy_includingSIvars.rds
Modified: output/propHomozygous.rds
Modified: output/top100stdSI.rds
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/getPMVarComps.Rmd
) and HTML (docs/getPMVarComps.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 | f73b05f | wolfemd | 2021-03-24 | Update to match revised manuscript. Several comparisons moved to Appendix to streamline primary results, figures, etc. |
html | 4de1330 | wolfemd | 2021-02-01 | Build site. |
Rmd | 883b1d4 | wolfemd | 2021-02-01 | Update the syntax highlighting and code-block formatting throughout for |
Rmd | 6a10c30 | wolfemd | 2021-01-04 | Submission and GitHub ready version. |
html | 6a10c30 | wolfemd | 2021-01-04 | Submission and GitHub ready version. |
For each of the genetic groups (GG, C1, C2, C3 , ALL):
Compute the posterior mean variances and covariances from the on-disk-stored, post-burnIn, thinned posterior samples of marker effects.
Models: A, AD, DirDom
For the directional dominance (DirDom) marker effects set. Add inbreeding/propHom effect to vector d.
# activate multithread OpenBLAS
export OMP_NUM_THREADS=112
rm(list=ls()); gc()
library(tidyverse); library(magrittr); library(predCrossVar); library(BGLR);
<-readRDS(here::here("data","blups_forawcdata.rds")) %>%
blupsselect(Trait,blups) %>% # BLUPs long-->wide for multivar analysis
unnest(blups) %>%
select(Trait,germplasmName,drgBLUP) %>%
spread(Trait,drgBLUP) %>% # choosing de-regressed BLUPs as responses despite unweighted analysis
select(germplasmName,all_of(c("DM","logFYLD","MCMDS","TCHART"))) # precaution to ensure consistent column order
# SNP data ------------
<-readRDS(here::here("data","dosages_awc.rds")) %>%
snpsremove_invariant(.); dim(snps) # [1] 5591 38093
# Training datasets -----------
<-blups %>%
geneticgroupsfilter(!grepl("TMS13|TMS14|TMS15",germplasmName)) %>%
mutate(Group="GG") %>%
bind_rows(blups %>%
filter(grepl("TMS13",germplasmName)) %>%
mutate(Group="TMS13")) %>%
bind_rows(blups %>%
filter(grepl("TMS14",germplasmName)) %>%
mutate(Group="TMS14")) %>%
bind_rows(blups %>%
filter(grepl("TMS15",germplasmName)) %>%
mutate(Group="TMS15")) %>%
bind_rows(blups %>%
mutate(Group="All")) %>%
nest(blups=-Group) %>%
crossing(Model=c("A","AD")) %>%
mutate(blups=map(blups,~filter(.,germplasmName %in% rownames(snps))),
outName=paste0("mt_",Group,"_",Model))
# Parallelization specs ---------
require(furrr); options(future.globals.maxSize=50000*1024^2)
plan(multiprocess); options(mc.cores=10);
# MCMC params ------
<-30000; burnIn<-5000; thin<-5
nIter
# getVarComps function -----------
## Wrapper function for getMultiTraitPMVs_A and getMultiTraitPMVs_AD
## For a given Model / data chunk, load stored posterior marker effects
## Compute vars/covars
source(here::here("code","getVarComps.R"))
# cbsulm12 - Done!
%<>%
geneticgroups mutate(PMV=future_pmap(.,getVarComps,snps=snps,nIter=30000, burnIn=5000,thin=5))
saveRDS(geneticgroups,file=here::here("output","pmv_varcomps_geneticgroups.rds"))
# activate multithread OpenBLAS
export OMP_NUM_THREADS=112
rm(list=ls()); gc()
library(tidyverse); library(magrittr); library(predCrossVar); library(BGLR);
<-readRDS(here::here("data","blups_forawcdata.rds")) %>%
blupsselect(Trait,blups) %>% # BLUPs long-->wide for multivar analysis
unnest(blups) %>%
select(Trait,germplasmName,drgBLUP) %>%
spread(Trait,drgBLUP) %>% # choosing de-regressed BLUPs as responses despite unweighted analysis
select(germplasmName,all_of(c("DM","logFYLD","MCMDS","TCHART"))) # precaution to ensure consistent column order
# SNP data ------------
<-readRDS(here::here("data","dosages_awc.rds")) %>%
snpsremove_invariant(.); dim(snps) # [1] 5591 38093
# Training datasets -----------
<-blups %>%
geneticgroupsfilter(!grepl("TMS13|TMS14|TMS15",germplasmName)) %>%
mutate(Group="GG") %>%
bind_rows(blups %>%
filter(grepl("TMS13",germplasmName)) %>%
mutate(Group="TMS13")) %>%
bind_rows(blups %>%
filter(grepl("TMS14",germplasmName)) %>%
mutate(Group="TMS14")) %>%
bind_rows(blups %>%
filter(grepl("TMS15",germplasmName)) %>%
mutate(Group="TMS15")) %>%
bind_rows(blups %>%
mutate(Group="All")) %>%
nest(blups=-Group) %>%
crossing(Model=c("DirDomA","DirDomAD")) %>%
mutate(blups=map(blups,~filter(.,germplasmName %in% rownames(snps))),
outName=paste0("mt_",Group,"_DirectionalDom"))
# Parallelization specs ---------
require(furrr); options(future.globals.maxSize=50000*1024^2)
plan(multiprocess); options(mc.cores=10);
# MCMC params ------
<-30000; burnIn<-5000; thin<-5
nIter
# getDirectionalDomVarComps function -----------
## Wrapper function for getMultiTraitPMVs_A and getMultiTraitPMVs_AD
## For a given Model / data chunk, load stored posterior marker effects
## Compute vars/covars
source(here::here("code","getDirectionalDomVarComps.R"))
# cbsulm12 - Done!
%<>%
geneticgroups mutate(PMV=future_pmap(.,getDirectionalDomVarComps,snps=snps,nIter=30000, burnIn=5000,thin=5))
saveRDS(geneticgroups,file=here::here("output","pmv_DirectionalDom_varcomps_geneticgroups.rds"))
library(tidyverse); library(magrittr);
<-readRDS(here::here("output","pmv_varcomps_geneticgroups.rds")) %>%
geneticgroupsbind_rows(readRDS(here::here("output","pmv_DirectionalDom_varcomps_geneticgroups.rds")))
%<>%
geneticgroups select(-blups) %>%
unnest_wider(PMV) %>%
select(-runtime) %>%
unnest(pmv) %>%
mutate_if(is.numeric,~round(.,6)) %>%
pivot_longer(cols=c(VPM,PMV),names_to = "VarMethod",values_to = "Var")
# Selection weights -----------
<-readRDS(file=here::here("data","selection_index_weights_4traits.rds"))
indices## Predicted Index Variances
<-geneticgroups %>%
geneticgroups_SInest(varcovars=c(Trait1,Trait2,Var)) %>%
mutate(varcovars=map(varcovars,
function(varcovars){
# pairwise to square symmetric matrix
<-varcovars %>%
gmatspread(Trait2,Var) %>%
column_to_rownames(var = "Trait1") %>%
%>%
as.matrix $Trait,indices$Trait]
.[indiceslower.tri(gmat)]<-t(gmat)[lower.tri(gmat)]
gmat[return(gmat) }),
# compute index variances
stdSI=map_dbl(varcovars,~t(indices$stdSI)%*%.%*%indices$stdSI),
biofortSI=map_dbl(varcovars,~t(indices$biofortSI)%*%.%*%indices$biofortSI)) %>%
# discard var-covar matrix
select(-varcovars) %>%
pivot_longer(cols = c(stdSI,biofortSI),
names_to = "Trait1",
values_to = "Var") %>%
mutate(Trait2=Trait1)
%<>% bind_rows(geneticgroups_SI)
geneticgroups rm(geneticgroups_SI)
saveRDS(geneticgroups,file=here::here("output","pmv_varcomps_geneticgroups_tidy_includingSIvars.rds"))
library(tidyverse); library(magrittr); library(BGLR)
<-readRDS(here::here("output","pmv_DirectionalDom_varcomps_geneticgroups.rds")) %>%
geneticgroups_dddistinct(Group,outName) %>%
mutate(mtbrrFit=map(outName,~readRDS(here::here("output/mtMarkerEffects",paste0(.,".rds"))))) %>%
unnest_wider(mtbrrFit) %>%
select(-runtime,-snpIDs,-outName) %>%
mutate(Dataset="GeneticGroups")
<-readRDS(file = here::here("data","parentwise_crossVal_folds.rds")) %>%
parentfolds_ddrename(Repeat=id,Fold=id2) %>%
select(Repeat,Fold,trainset,testset) %>%
pivot_longer(c(trainset,testset),
names_to = "Dataset",
values_to = "sampleIDs") %>%
mutate(Model="DirectionalDom") %>%
arrange(desc(Dataset),Repeat,Fold) %>%
mutate(outName=paste0("mt_",Repeat,"_",Fold,"_",Dataset,"_",Model)) %>%
mutate(mtbrrFit=map(outName,~readRDS(here::here("output/mtMarkerEffects",paste0(.,".rds"))))) %>%
unnest_wider(mtbrrFit) %>%
select(-runtime,-snpIDs,-sampleIDs,-outName,-Model)
<-bind_rows(geneticgroups_dd,parentfolds_dd) %>%
ddEffectsmutate(inbreff=map(mtbrrFit,function(mtbrrFit){
<-colnames(mtbrrFit$yHat)
traits<-mtbrrFit$ETA$GmeanD$beta
beta<-mtbrrFit$ETA$GmeanD$SD.beta
SD.betacolnames(beta)<-colnames(SD.beta)<-traits
<-bind_rows(as_tibble(beta),as_tibble(SD.beta)) %>%
inbeffst(.) %>%
%>%
as.data.frame rownames_to_column(var="Trait") %>%
rename(InbreedingEffect=V1,
InbreedingEffectSD=V2)
return(inbeffs) })) %>%
select(-mtbrrFit) %>%
unnest(inbreff)
saveRDS(ddEffects,file=here::here("output","ddEffects.rds"))
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
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] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 whisker_0.4 knitr_1.31 magrittr_2.0.1
[5] R6_2.5.0 rlang_0.4.10 fansi_0.4.2 stringr_1.4.0
[9] tools_4.0.3 xfun_0.22 utf8_1.2.1 git2r_0.28.0
[13] jquerylib_0.1.3 htmltools_0.5.1.1 ellipsis_0.3.1 rprojroot_2.0.2
[17] yaml_2.2.1 digest_0.6.27 tibble_3.1.0 lifecycle_1.0.0
[21] crayon_1.4.1 later_1.1.0.1 sass_0.3.1 vctrs_0.3.6
[25] promises_1.2.0.1 fs_1.5.0 glue_1.4.2 evaluate_0.14
[29] rmarkdown_2.7 stringi_1.5.3 bslib_0.2.4 compiler_4.0.3
[33] pillar_1.5.1 jsonlite_1.7.2 httpuv_1.5.5 pkgconfig_2.0.3