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/PreprocessDataFiles.Rmd
) and HTML (docs/PreprocessDataFiles.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. |
https://www.biorxiv.org/content/10.1101/794339v1.full
ftp://ftp.cassavabase.org/manuscripts/Chan_et_al_2019/
The directory has since been compressed for storage to jj332_cas/ac2278/
Eventually the data will be here:
ftp://ftp.cassavabase.org/manuscripts/Chan_et_al_2019/shapeit2duohmm_mlhaplotypes/
and also: ftp://ftp.cassavabase.org/manuscripts/Wolfe_et_al_2020
For now, they need files are at /jj332_cas/marnin/shapeit2duohmm_mlhaplotypes/
library(tidyverse); library(magrittr); library(furrr); library(data.table)
library(furrr); options(mc.cores=18); plan(multiprocess)
<-"/workdir/marnin/shapeit2duohmm_mlhaplotypes"
path2haps<-tibble(Chr=1:18) %>%
haps::mutate(Haps=future_map(Chr,~fread(paste0(path2haps,"/chr",
dplyr::str_pad(.,width = 3,side = 'left',pad = 0),
stringr"_0.30.haps"),
stringsAsFactors = F,header = F,sep = " ") %>%
as.data.frame))<-tibble(Chr=1:18) %>%
sampleids::mutate(Samples=future_map(Chr,# read in SAMPLE file
dplyr~fread(paste0(path2haps,"/chr",
::str_pad(.,width = 3,side = 'left',pad = 0),
stringr"_0.30.sample"),
stringsAsFactors = F,header = T,sep = " ") %>%
slice(-1))) # ignore the first (non-header) row of the SAMPLE file.
<-sampleids$Samples[[1]]$ID_2 %>%
SampleIDstibble(ID=.,SampleIndex=1:length(.), Haplo="_HapA") %>%
bind_rows(.,dplyr::mutate(.,Haplo="_HapB")) %>%
arrange(SampleIndex) %>%
::mutate(SampleID=paste0(ID,Haplo)) %$% SampleID
dplyroptions(future.globals.maxSize= 15000*1024^2)
%<>%
haps ::mutate(Haps=future_map(Haps,function(Haps){
dplyr#Haps<-haps$Haps[[1]]
colnames(Haps)<-c("Chr","HAP_ID","Pos","REF","ALT",SampleIDs)
%<>%
Haps ::mutate(HAP_ID=paste0(HAP_ID,"_",REF,"_",ALT)) %>%
dplyrcolumn_to_rownames(var = "HAP_ID") %>%
select(-Chr,-Pos,-REF,-ALT)
%<>% t(.) %>% as.matrix(.)
Haps return(Haps)}))
<-reduce(haps$Haps,cbind)
hapssaveRDS(haps,file=here::here("data","haps_awc.rds"))
$Samples[[1]]$ID_2 %>%
sampleidsgrep("TMS13|TMS14|TMS15|2013_",.,value=T,invert=T) %>%
# 168 parents from the GeneticGain / C0 population length
To ensure consistency in allele counting, create dosage from haps.
library(tidyverse); library(magrittr);
<-readRDS(file=here::here("data","haps_awc.rds"))
haps<-haps %>%
dosagesas.data.frame(.) %>%
rownames_to_column(var = "GID") %>%
separate(GID,c("SampleID","Haplo"),"_Hap",remove = T) %>%
select(-Haplo) %>%
group_by(SampleID) %>%
summarise_all(~sum(.)) %>%
ungroup() %>%
column_to_rownames(var = "SampleID") %>%
as.matrixsaveRDS(dosages,file=here::here("data","dosages_awc.rds"))
ftp://ftp.cassavabase.org/manuscripts/Chan_et_al_2019/alphapeel.vped
/PredictOutbredCrossVar/data/
library(tidyverse); library(magrittr);
<-read.table(here::here("data","alphapeel.vped"),stringsAsFactors = F, header = F) %>%
awcpedrename(FullSampleName=V1,
sireID=V2,
damID=V3) %>%
# Remove families with one or both parents unknown
filter(sireID!=0,damID!=0)
%>%
awcped count(sireID,damID) %$% summary(n)
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 1.000 2.000 4.000 6.924 10.000 72.000
%>%
awcped count(sireID,damID) %>% dim # 462 families
saveRDS(awcped,file=here::here("data","ped_awc.rds"))
Select traits and data to be analyzed.
library(tidyverse); library(magrittr);
<-readRDS(url("https://raw.github.com/wolfemd/IITA_2019GS/master/data/iita_blupsForCrossVal_72619.rds"))
blups<-readRDS(url("https://raw.github.com/wolfemd/IITA_2019GS/master/data/IITA_ExptDesignsDetected_72619.rds"))
trials<-readRDS(here::here("data","haps_awc.rds"))
haps
<-trials %>%
germnamesunnest_legacy(TrialData) %>%
select(FullSampleName,germplasmName) %>%
%>%
distinct mutate(GID=ifelse(is.na(FullSampleName),germplasmName,FullSampleName))
#blups %>% select(Trait,Dataset,blups) %>% spread(Dataset,blups)
%<>%
blups filter(Dataset=="2013toPresent",
%in% c("DM","logFYLD","MCMDS","TCHART"))
Trait %<>%
blups select(Trait,blups,varcomp) %>%
mutate(blups=map(blups,~inner_join(.,germnames) %>%
filter(germplasmName %in% gsub("_HapA|_HapB","",rownames(haps)))))
saveRDS(blups,file=here::here("data","blups_forawcdata.rds"))
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)
<-blups %>%
indicessummarize_if(is.numeric,sd, na.rm=T) %>%
pivot_longer(cols = everything(), names_to = "Trait", values_to = "blupSD") %>%
left_join(tibble(Trait=c("DM","logFYLD","MCMDS","TCHART"),
stdSI_unscaled=c(5, 10, -10, -5),
biofortSI_unscaled=c(10, 5, -5,10))) %>%
mutate(stdSI=stdSI_unscaled/blupSD,
biofortSI=biofortSI_unscaled/blupSD)
%>% mutate_if(is.numeric,~round(.,2))
indices saveRDS(indices,file=here::here("data","selection_index_weights_4traits.rds"))
https://www.biorxiv.org/content/10.1101/794339v1.full
ftp://ftp.cassavabase.org/manuscripts/Chan_et_al_2019/
# activate multithread OpenBLAS for fast matrix algebra
export OMP_NUM_THREADS=56
library(tidyverse); library(magrittr); library(predCrossVar)
<-tibble(Chr=1:18) %>%
genmap::mutate(geneticMap=map(Chr,~readRDS(paste0("/workdir/marnin/ac2278_shapeit2_maxna/chr",
dplyr::str_pad(.,width = 3,side = 'left',pad = 0),
stringr"_AWC.rds"))))
<-readRDS(here::here("data","dosages_awc.rds")) %>%
snpsremove_invariant(.);
dim(snps)
%<>%
genmap ::mutate(geneticMap=map(geneticMap,as.data.frame)) %>%
dplyrunnest(geneticMap) %>%
::mutate(SNP_ID=paste0(Chr,"_",pos)) %>%
dplyrrename(cM=V2) %>%
filter(SNP_ID %in% gsub("_C|_G|_T|_A","",colnames(snps))) %>%
left_join(tibble(SNP_ID=gsub("_C|_G|_T|_A","",colnames(snps)),
IDwithREF=colnames(snps)))
saveRDS(genmap,file=here::here("data","genmap_awc_May2020.rds"))
Construct a matrix of recombination frequencies at loci for all study loci. Pre-compute 1-2c to save time predicting cross variance.
<-genmap$cM;
mnames(m)<-genmap$IDwithREF
library(predCrossVar)
<-1-(2*genmap2recombfreq(m,nChr = 18))
recombFreqMatsaveRDS(recombFreqMat,file=here::here("data","recombFreqMat_1minus2c_awcmap_May2020.rds")
sessionInfo()