Last updated: 2021-09-18
Checks: 7 0
Knit directory: IITA_2021GS/
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(20210504)
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 01fb4d2. 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: analysis/figure/
Ignored: code/.DS_Store
Ignored: data/.DS_Store
Untracked files:
Untracked: data/DatabaseDownload_2021Aug08/
Untracked: data/DatabaseDownload_2021May04/
Untracked: data/GBSdataMasterList_31818.csv
Untracked: data/IITA_GBStoPhenoMaster_33018.csv
Untracked: data/Mate_selection_parental.pool.xlsx
Untracked: data/NRCRI_GBStoPhenoMaster_40318.csv
Untracked: data/PedigreeGeneticGainCycleTime_aafolabi_01122020.xls
Untracked: data/Report-DCas21-6038/
Untracked: data/blups_forGP.rds
Untracked: data/chr1_RefPanelAndGSprogeny_ReadyForGP_72719.fam
Untracked: data/dosages_IITA_2021Aug09.rds
Untracked: data/haps_IITA_2021Aug09.rds
Untracked: data/recombFreqMat_1minus2c_2021Aug02.qs
Untracked: output/
Unstaged changes:
Modified: analysis/inputsForSimulationV2.Rmd
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-GenomicPredictions.Rmd
) and HTML (docs/06-GenomicPredictions.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 | 01fb4d2 | wolfemd | 2021-09-18 | Updated mate predictions and results page - predicted >250K crosses of 719 parents at Ubiaja now. |
html | ceae21a | wolfemd | 2021-08-26 | Build site. |
html | 19c3a38 | wolfemd | 2021-08-19 | Build site. |
html | e029efc | wolfemd | 2021-08-12 | Build site. |
Rmd | efebeab | wolfemd | 2021-08-12 | Cross-validation and genomic mate predictions complete. All results updated. |
html | 1c03315 | wolfemd | 2021-08-11 | Build site. |
Rmd | e4df79f | wolfemd | 2021-08-11 | Completed IITA_2021GS pipeline including imputation and genomic prediction. Last bit of cross-validation and cross-prediction finishes in 24 hrs. |
Rmd | 1d017cb | wolfemd | 2021-07-25 | Debugging completed for predictCrosses(). Work shown and tests passed also shown. Full run underway. |
html | 934141c | wolfemd | 2021-07-14 | Build site. |
html | cc1eb4b | wolfemd | 2021-07-14 | Build site. |
Rmd | 772750a | wolfemd | 2021-07-14 | DirDom model and selection index calc fully integrated functions. |
Rmd | b43ee90 | wolfemd | 2021-07-12 | Completed predictCrosses function, which predicts cross usefullness on SELINDs and component traits. Work is shown. |
Rmd | 0ac841c | wolfemd | 2021-07-11 | Full genomic prediction including (1) genomic prediction of clone GBLUPs and (2) prediction of cross usefulness. (1) is completed. Work shown. (2) is TO DO still. |
Genomic prediction of clone GEBV/GETGV. Fit GBLUP model, using genotypic add-dom partition. NEW: modelType=“DirDom”, include genome-wide inbreeding effect in GEBV/GETGV predictions after backsolving SNP effects. For all models, extract GBLUPs and backsolve SNP effects for use in cross usefulness predictions (mean+variance predictions). ALSO NEW: selection index predictions.
Genomic prediction of cross \(UC_{parent}\) and \(UC_{variety}\). Rank potential parents on SI. Predict all possible crosses of some portion of best parents.
# 1) start a screen shell
screen; # or screen -r if re-attaching...
# 2) start the singularity Linux shell inside that
singularity shell ~/rocker2.sif;
# Project directory, so R will use as working dir.
cd /home/mw489/IITA_2021GS/;
# 3) Start R
R
Load input data
# NEEDED LIBRARIES
require(tidyverse); require(magrittr); library(qs)
library(genomicMateSelectR)
# BLUPs
<-readRDS(file=here::here("data","blups_forGP.rds")) %>%
blups::select(-varcomp) %>%
dplyrrename(TrainingData=blups) # for compatibility with runCrossVal() function
# DOSAGE MATRIX (UNFILTERED)
<-readRDS(file=here::here("data","dosages_IITA_2021Aug09.rds"))
dosages
# SNP SETS TO ANALYZE
<-readRDS(file = here::here("data","snpsets.rds"))
snpsets
# SELECTION INDEX WEIGHTS
## from IYR+IK
## note that not ALL predicted traits are on index
<-c(logFYLD=20,
SIwtsHI=10,
DM=15,
MCMDS=-10,
logRTNO=12,
logDYLD=20,
logTOPYLD=15,
PLTHT=10)
Run the “DirDom” modelTypes built into runGenomicPredictions()
. Output will contain both GBLUPs for selection of clones and SNP effects to use as input for prediction of cross usefulness and subsequent mate selection.
Get effects for: full_set (~31K SNPs), medium_set (~13K, LD-pruned) and reduced_set (~9K SNPs, LD-pruned).
# cbsulm30 - 112 cores, 512 GB RAM - 2021 Aug 10 - 8:40am
<-"full_set"
snpSet<-list(A=readRDS(here::here("output","kinship_A_IITA_2021Aug09.rds")),
grmsD=readRDS(here::here("output","kinship_Dgeno_IITA_2021Aug09.rds")))
# [1] "Time elapsed: 24.066 mins"
# cbsulm30 - 112 cores, 512 GB RAM - 2021 Aug 10 - 8:40am
<-"reduced_set"
snpSet<-list(A=readRDS(here::here("output","kinship_A_ReducedSNPset_IITA_2021Aug09.rds")),
grmsD=readRDS(here::here("output","kinship_Dgeno_ReducedSNPset_IITA_2021Aug09.rds")))
# [1] "Time elapsed: 22.431 mins"
# cbsulm20 - 88 cores, 512 GB RAM - 2021 Aug 10 - 2:50pm
<-"medium_set"
snpSet<-list(A=readRDS(here::here("output","kinship_A_MediumSNPset_IITA_2021Aug09.rds")),
grmsD=readRDS(here::here("output","kinship_Dgeno_MediumSNPset_IITA_2021Aug09.rds")))
# [1] "Time elapsed: 13.299 mins"
<-snpsets %>%
snps2keepfilter(Set==snpSet) %>%
select(snps2keep) %>%
unnest(snps2keep)
<-dosages[,snps2keep$FULL_SNP_ID]
dosagesrm(snpsets); gc()
<-proc.time()[3]
starttime<-runGenomicPredictions(modelType="DirDom",selInd=TRUE, SIwts=SIwts,
gpredsgetMarkEffs=TRUE,
returnPEV=FALSE,
blups=blups,grms=grms,dosages=dosages,
ncores=11,nBLASthreads=5)
saveRDS(gpreds,
file = here::here("output",
paste0("genomicPredictions_",snpSet,"_2021Aug09.rds")))
<-proc.time()[3]; print(paste0("Time elapsed: ",
endtimeround((endtime-starttime)/60,3)," mins"))
# 1) start a screen shell
screen; # or screen -r if re-attaching...
# 2) start the singularity Linux shell inside that
singularity shell ~/rocker2.sif;
# Project directory, so R will use as working dir.
cd /home/mw489/IITA_2021GS/;
# 3) Start R
R
# NEEDED LIBRARIES
require(tidyverse); require(magrittr); library(qs)
library(genomicMateSelectR)
# BLUPs
<-readRDS(file=here::here("data","blups_forGP.rds")) %>%
blups::select(-varcomp)
dplyr
# DOSAGE MATRIX (UNFILTERED)
<-readRDS(file=here::here("data","dosages_IITA_2021Aug09.rds"))
dosages
# RECOMBINATION FREQUENCY MATRIX (UNFILTERED)
<-qread(file=here::here("data",
recombFreqMat"recombFreqMat_1minus2c_2021Aug02.qs"))
# HAPLOTYPE MATRIX (UNFILTERED)
## keep only haplos for parents-in-the-pedigree
## those which will be used in prediction, saves memory
<-readRDS(file=here::here("data","haps_IITA_2021Aug09.rds"))
haploMat<-union(ped$sireID,ped$damID)
parents<-sort(c(paste0(parents,"_HapA"),
parenthapspaste0(parents,"_HapB")))
<-haploMat[parenthaps,]
haploMat
# SNP SETS TO ANALYZE
<-readRDS(file = here::here("data","snpsets.rds"))
snpsets
# SELECTION INDEX WEIGHTS
## from IYR+IK
## note that not ALL predicted traits are on index
<-c(logFYLD=20,
SIwtsHI=10,
DM=15,
MCMDS=-10,
logRTNO=12,
logDYLD=20,
logTOPYLD=15,
PLTHT=10)
# LIST OF ACCESSIONS LIKELY IN THE FIELD
<-readRDS(here::here("data",
accessions_infield"accessions_possibly_infield_2021Aug10.rds"))
# gpreds_full<-readRDS(file = here::here("output","genomicPredictions_full_set_2021Aug09.rds"))
# gpreds_medium<-readRDS(file = here::here("output","genomicPredictions_medium_set_2021Aug09.rds"))
# gpreds_reduced<-readRDS(file = here::here("output","genomicPredictions_reduced_set_2021Aug09.rds"))
### Quick check that GBLUPs from full and medium_set are strongly correlated
### This will be an additional assurance that similar cross variances
### will be predicted by the reduced SNP model
### Cor between SELIND GEBV and GETGV between full_set and reduced_set of SNPs?
# left_join(gpreds_full$gblups[[1]] %>% select(GID,predOf,SELIND) %>% rename(SELIND_full=SELIND),
# gpreds_reduced$gblups[[1]] %>% select(GID,predOf,SELIND) %>% rename(SELIND_reduced=SELIND)) %>%
# group_by(predOf) %>%
# summarize(SELIND_corModels=cor(SELIND_full,SELIND_reduced))
# predOf SELIND_corModels
# GEBV 0.0363334
# GETGV 0.7809016
## TERRIBLE!! :(
### Cor between SELIND GEBV and GETGV between full_set and medium_set of SNPs?
# left_join(gpreds_full$gblups[[1]] %>% select(GID,predOf,SELIND) %>% rename(SELIND_full=SELIND),
# gpreds_medium$gblups[[1]] %>% select(GID,predOf,SELIND) %>% rename(SELIND_medium=SELIND)) %>%
# group_by(predOf) %>%
# summarize(SELIND_corModels=cor(SELIND_full,SELIND_medium))
# predOf SELIND_corModels
# GEBV 0.9901325
# GETGV 0.9887326
## EXCELLENT!! :)
Choose the best parents for which to predict crosses. Use the GBLUPs from the full_set of SNPs.
Take the union of the top 300 clones on the SELIND in terms of GEBV and of GETGV. Probably they will be a very similar list.
# SELECT THE BEST PARENTS AS CROSSES-TO-BE-PREDICTED
<-300
nParentsToSelect<-readRDS(file = here::here("output","genomicPredictions_full_set_2021Aug09.rds"))
gpreds_full<-union(gpreds_full$gblups[[1]] %>%
union_bestGEBVandGETGVfilter(predOf=="GEBV") %>%
arrange(desc(SELIND)) %>%
slice(1:nParentsToSelect) %$% GID,
$gblups[[1]] %>%
gpreds_fullfilter(predOf=="GETGV") %>%
arrange(desc(SELIND)) %>%
slice(1:nParentsToSelect) %$% GID)
rm(gpreds_full);
length(union_bestGEBVandGETGV)
# [1] 365 parents in top nParentsToSelect on SELIND for GEBV/GETGV
# KEEP ONLY CANDIDATE PARENTS EXPECTED TO BE IN THE FIELD
table(union_bestGEBVandGETGV %in% accessions_infield$FullSampleName)
# FALSE TRUE
# 165 200
<-union_bestGEBVandGETGV %>%
parentsToPredictCrosses%in% accessions_infield$FullSampleName]
.[. <-crosses2predict(parentsToPredictCrosses)
CrossesToPredictnrow(CrossesToPredict)
# [1] 20100 possible crosses of 200 parents
saveRDS(parentsToPredictCrosses,
file = here::here("output",
"parentsToPredictCrosses_2021Aug10.rds"))
saveRDS(CrossesToPredict,
file = here::here("output",
"CrossesToPredict_2021Aug10.rds"))
Predict all pairwise crosses of those 200 parents.
# cbsulm17 - 112 cores, 512 GB RAM - 2021 Aug 11 - 8:10am
<-"full_set"
snpSet<-list(A=readRDS(here::here("output","kinship_A_IITA_2021Aug09.rds")),
grmsD=readRDS(here::here("output","kinship_Dgeno_IITA_2021Aug09.rds")))
<-TRUE; predTheVars<-FALSE
predTheMeans<-readRDS(file = here::here("output","genomicPredictions_full_set_2021Aug09.rds")); gc()
gpreds## takes ~2 minutes, predicting means only
# cbsulm17 - 112 cores, 512 GB RAM - 2021 Aug 10 - 8:25am
<-"medium_set"
snpSet<-list(A=readRDS(here::here("output","kinship_A_MediumSNPset_IITA_2021Aug09.rds")),
grmsD=readRDS(here::here("output","kinship_Dgeno_MediumSNPset_IITA_2021Aug09.rds")))
<-TRUE; predTheVars<-TRUE
predTheMeans<-readRDS(file = here::here("output","genomicPredictions_medium_set_2021Aug09.rds")); gc()
gpreds# 1263.904
<-snpsets %>%
snps2keepfilter(Set==snpSet) %>%
select(snps2keep) %>%
unnest(snps2keep)
<-dosages[,snps2keep$FULL_SNP_ID]
dosages<-haploMat[,snps2keep$FULL_SNP_ID]
haploMat<-recombFreqMat[snps2keep$FULL_SNP_ID,snps2keep$FULL_SNP_ID]
recombFreqMatrm(snpsets); gc()
dim(dosages); predTheMeans; predTheVars
snpSet;
<-proc.time()[3]
start<-predictCrosses(modelType="DirDom",stdSelInt = 2.0627128,
crossPredsselInd=TRUE, SIwts=SIwts,
CrossesToPredict=CrossesToPredict,
snpeffs=gpreds$genomicPredOut[[1]],
dosages=dosages,
haploMat=haploMat,recombFreqMat=recombFreqMat,
ncores=20,nBLASthreads=5,
predTheMeans = predTheMeans,
predTheVars = predTheVars)
<-proc.time()[3]-start; runtime/60
runtimesaveRDS(crossPreds,file = here::here("output",
paste0("genomicMatePredictions_",
"_2021Aug10.rds"))) snpSet,
September 10th, 2021: received from I. Kayondo a list of plots in Ubiaja available for crosses (data/Mate_selection_parental.pool.xlsx
). Match these lines to genomic data and (if not already done) predict matings!
First thing, match the germplasm in the list provided to genotype data…
library(genomicMateSelectR)
library(tidyverse); library(magrittr)
<-readRDS(here::here("output","IITA_ExptDesignsDetected_2021Aug08.rds"))
dbdata<-readRDS(file=here::here("data","dosages_IITA_2021Aug09.rds"))
dosages
<-readxl::read_xlsx(here::here("data","Mate_selection_parental.pool.xlsx")) %>%
parent_candidatesdistinct(accession_name) %>%
rename(germplasmName=accession_name) %>%
left_join(dbdata %>%
distinct(germplasmName,GID,FullSampleName))
1354 unique germplasm to select among. Some genotyped multiple times, so 1576 geno matches.
%>%
parent_candidates filter(is.na(GID)) %>%
distinct(germplasmName) %>%
write.table(.,file=here::here("output","parent_candidates_NOGENOS.txt"),col.names = F, row.names = F, quote = F)
%>%
parent_candidates filter(!FullSampleName %in% rownames(dosages),
!is.na(FullSampleName)) %>%
distinct(germplasmName) %>%
write.table(.,file=here::here("output","parent_candidates_PEDIGREEREJECT.txt"),col.names = F, row.names = F, quote = F)
%<>%
parent_candidates filter(FullSampleName %in% rownames(dosages)) %>%
distinct(germplasmName,FullSampleName) %>%
group_by(germplasmName) %>%
slice(1)
%>%
parent_candidates write.table(.,file=here::here("output","parent_candidates_TOPREDICT.txt"),col.names = F, row.names = F, quote = F)
<-genomicMateSelectR::crosses2predict(parents)
CrossesToPredict# nrow(CrossesToPredict)
# [1] 258840 possible crosses of 719 parents
saveRDS(CrossesToPredict,
file = here::here("output",
"CrossesToPredict_2021Sep13.rds"))
13 lines don’t seem to have matches in SNP data. 552 lines DO have SNP data, but seem to have been excluded from my analyses at the pedigree-validation step here because they had neither BLUPs (useful training data) nor could their pedigree be validated.
That might not be what you want, since as long as the genomic data matches the clone in the field, even without a verified pedigree it could be a useful parent for crossing. Also, my pedigree verification could have false rejections. So care should be taken. Two lists of clones for you: output/parent_candidates_NOGENOS.txt
, output/parent_candidates_PEDIGREEREJECT.txt
.
719 germplasmName have genotype data matches and verified pedigrees. Some have more than one DNA sample, so I will choose one for each.
Because there are PLENTY of candidate parents, I suggest to proceed for now, but some action or decision should be made about the 552 germplasm not-yet-considered.
File with the list I suggeset to work from: ouptput/parent_candidates_TOPREDICT.txt
.
You can match the predictions I make with your field plots based on match the “germplasmName” column in this file with the “accession_name” column in the Mate_selection_parental.pool.xlsx
file you shared with me.
Regarding the number of crosses I can predict: It took 21 hrs on a single 112 core server to predict 20100 crosses (pairwise for 200 parents).
For pairwise crosses among 719 in-field parents, 258840 crosses-to-predict. 271 hrs or 11 days. I could secure at least 3 servers and do it in about 3-5 actual days.
Or I could take the top 500 parents (125250 crosses) or 400 parents (80200 crosses) and cut it down to as little as 2 days.
Delivery end of week vs mid-week?
# 1) start a screen shell
screen; # or screen -r if re-attaching...
# 2) start the singularity Linux shell inside that
singularity shell ~/rocker2.sif;
# Project directory, so R will use as working dir.
cd /home/mw489/IITA_2021GS/;
# 3) Start R
R
# NEEDED LIBRARIES
require(tidyverse); require(magrittr); library(qs)
library(genomicMateSelectR)
# BLUPs
<-readRDS(file=here::here("data","blups_forGP.rds")) %>%
blups::select(-varcomp)
dplyr
# DOSAGE MATRIX (UNFILTERED)
<-readRDS(file=here::here("data","dosages_IITA_2021Aug09.rds"))
dosages
# RECOMBINATION FREQUENCY MATRIX (UNFILTERED)
<-qread(file=here::here("data",
recombFreqMat"recombFreqMat_1minus2c_2021Aug02.qs"))
# HAPLOTYPE MATRIX (UNFILTERED)
## keep only haplos for parents-in-the-pedigree
## those which will be used in prediction, saves memory
<-readRDS(file=here::here("data","haps_IITA_2021Aug09.rds"))
haploMat
# PARENTS FOR CROSS PREDICTIONS
<-read.table(here::here("output","parent_candidates_TOPREDICT.txt"), header = F, stringsAsFactors = F)$V2
parents
# SUBSET HAPS
<-sort(c(paste0(parents,"_HapA"),
parenthapspaste0(parents,"_HapB")))
<-haploMat[parenthaps,]
haploMat
# SNP SETS TO ANALYZE
<-readRDS(file = here::here("data","snpsets.rds"))
snpsets
# SELECTION INDEX WEIGHTS
## from IYR+IK
## note that not ALL predicted traits are on index
<-c(logFYLD=20,
SIwtsHI=10,
DM=15,
MCMDS=-10,
logRTNO=12,
logDYLD=20,
logTOPYLD=15,
PLTHT=10)
# CROSSES TO PREDICT
<-readRDS(here::here("output",
CrossesToPredict"CrossesToPredict_2021Sep13.rds"))
# cbsulm26 - 88 cores, 512 GB RAM - 2021 Sep 13
<-"full_set"
snpSet<-list(A=readRDS(here::here("output","kinship_A_IITA_2021Aug09.rds")),
grmsD=readRDS(here::here("output","kinship_Dgeno_IITA_2021Aug09.rds")))
<-TRUE; predTheVars<-FALSE
predTheMeans<-readRDS(file = here::here("output","genomicPredictions_full_set_2021Aug09.rds")); gc()
gpreds
<-snpsets %>%
snps2keepfilter(Set==snpSet) %>%
select(snps2keep) %>%
unnest(snps2keep)
<-dosages[,snps2keep$FULL_SNP_ID]
dosages<-haploMat[,snps2keep$FULL_SNP_ID]
haploMat<-recombFreqMat[snps2keep$FULL_SNP_ID,snps2keep$FULL_SNP_ID]
recombFreqMatrm(snpsets); gc()
dim(dosages); predTheMeans; predTheVars
snpSet;
<-proc.time()[3]
start<-predictCrosses(modelType="DirDom",stdSelInt = 2.0627128,
crossPredsselInd=TRUE, SIwts=SIwts,
CrossesToPredict=CrossesToPredict,
snpeffs=gpreds$genomicPredOut[[1]],
dosages=dosages,
haploMat=haploMat,recombFreqMat=recombFreqMat,
ncores=17,nBLASthreads=5,
predTheMeans = predTheMeans,
predTheVars = predTheVars)
<-proc.time()[3]-start; runtime/60
runtimesaveRDS(crossPreds,file = here::here("output",
paste0("genomicMatePredictions_",
"_2021Sep13.rds")))
snpSet,# elapsed
# 14.7936 minutes
<-"medium_set"
snpSet<-list(A=readRDS(here::here("output","kinship_A_MediumSNPset_IITA_2021Aug09.rds")),
grmsD=readRDS(here::here("output","kinship_Dgeno_MediumSNPset_IITA_2021Aug09.rds")))
<-TRUE; predTheVars<-TRUE
predTheMeans<-readRDS(file = here::here("output","genomicPredictions_medium_set_2021Aug09.rds")); gc()
gpreds<-snpsets %>%
snps2keepfilter(Set==snpSet) %>%
select(snps2keep) %>%
unnest(snps2keep)
<-dosages[,snps2keep$FULL_SNP_ID]
dosages<-haploMat[,snps2keep$FULL_SNP_ID]
haploMat<-recombFreqMat[snps2keep$FULL_SNP_ID,snps2keep$FULL_SNP_ID]
recombFreqMatrm(snpsets); gc()
dim(dosages); predTheMeans; predTheVars
snpSet;
# DIVIDE CROSSES-TO-PREDICT INTO 3 CHUNKS
%<>%
CrossesToPredict mutate(Chunk=rep_along(along = CrossesToPredict$sireID, 1:3) %>% sort(.)) %>%
nest(Crosses=c(sireID,damID))
# cbsulm26 - 88 cores, 512 GB RAM - 2021 Sep 13, 10:20am
<-CrossesToPredict$Crosses[[1]]
CrossesToPredict<-1
chunk# [1] "Done predicting fam vars. Took 3867.09 mins for 86280 crosses" = 64.45 hrs = 2.68 days
# [1] "Done predicting fam vars. Took 1658.5 mins for 86280 crosses"
# 5548.574
## two runs of predCrossVars() function internally
## to predictCrosses() for the DirDom model
## 3867.09/86280 = 0.045 min per cross
## (3867.09*2)/86280 = 0.089 total mins per cross (for DirDom model)
# cbsulm18 - 88 cores, 512 GB RAM - 2021 Sep 13, 9:30am
<-CrossesToPredict$Crosses[[2]]
CrossesToPredict<-2
chunk
# [1] "Done predicting fam vars. Took 3700.52 mins for 86280 crosses" = 61.67 hrs = 2.57 days
# [1] "Done predicting fam vars. Took 1600.63 mins for 86280 crosses"
# 5323.687 mins elapsed total
# cbsulm19 - 88 cores, 512 GB RAM - 2021 Sep 13, 9:30am
<-CrossesToPredict$Crosses[[3]]
CrossesToPredict<-3
chunk# [1] "Done predicting fam vars. Took 3659.66 mins for 86280 crosses"
# [1] "Done predicting fam vars. Took 1609.88 mins for 86280 crosses"
# 5292.067 = 88.2 hrs = 3.67 days
%>% head
CrossesToPredict
## 128.9 hrs = 5.37 days expected for 3 servers (each 88 core, 512 GB RAM)
## to deliver ~260K cross predictions for an directional dominance model with
## an 8 trait SI and 13K SNPs
<-proc.time()[3]
start<-predictCrosses(modelType="DirDom",stdSelInt = 2.0627128,
crossPredsselInd=TRUE, SIwts=SIwts,
CrossesToPredict=CrossesToPredict,
snpeffs=gpreds$genomicPredOut[[1]],
dosages=dosages,
haploMat=haploMat,recombFreqMat=recombFreqMat,
ncores=17,nBLASthreads=5,
predTheMeans = predTheMeans,
predTheVars = predTheVars)
<-proc.time()[3]-start; runtime/60
runtimesaveRDS(crossPreds,file = here::here("output",
paste0("genomicMatePredictions_",
"_chunk",chunk,"_2021Sep13.rds"))) snpSet,
Add genetic groups and cohort identifiers and tidy format
library(tidyverse); library(magrittr)
<-readRDS(file = here::here("output","genomicPredictions_full_set_2021Aug09.rds"))
gpreds$gblups[[1]] %>%
gpredsmutate(GeneticGroup=case_when(grepl("2013_|TMS13",GID)~"C1",
grepl("TMS14",GID)~"C2",
grepl("TMS15",GID)~"C3",
grepl("TMS18",GID)~"C4",
grepl("TMS20",GID)~"C5",
grepl("TMS16",GID)~"TMS16",
grepl("TMS17",GID)~"TMS17",
grepl("TMS19",GID)~"TMS19",
!grepl("2013_|TMS13|TMS14|TMS15|TMS16|TMS17|TMS18|TMS19|TMS20",GID)~"PreGS"),
#GeneticGroup=factor(GeneticGroup,levels = c("PreGS","C1","C2","C3","C4","C5","TMS16","TMS17","TMS19")),
Cohort=case_when(grepl("2013_|TMS13",GID)~"TMS13",
grepl("TMS14",GID)~"TMS14",
grepl("TMS15",GID)~"TMS15",
grepl("TMS16",GID)~"TMS16",
grepl("TMS17",GID)~"TMS17",
grepl("TMS18",GID)~"TMS18",
grepl("TMS19",GID)~"TMS19",
grepl("TMS20",GID)~"TMS20",
!grepl("2013_|TMS13|TMS14|TMS15|TMS16|TMS17|TMS18|TMS19|TMS20",GID)~"PreGS")) %>%
relocate(GeneticGroup,.after = "predOf") %>%
relocate(Cohort,.after = "GeneticGroup") %>%
arrange(predOf,desc(SELIND)) %>%
write.csv(.,file = here::here("output","genomicPredictions_full_set_2021Aug09.csv"),
row.names = F)
NOTE: For cross predictions, check that the predMean from full and medium set are highly correlated. As long as that is true, combine the predMean from full set with pred var from medium set.
<-readRDS(file = here::here("output","genomicMatePredictions_full_set_2021Aug10.rds"))
crossPreds_full<-readRDS(file = here::here("output","genomicMatePredictions_medium_set_2021Aug10.rds"))
crossPreds_medium$rawPreds[[1]] crossPreds_medium
$tidyPreds[[1]] %>%
crossPreds_fullrename(predMean_full=predMean) %>%
left_join(crossPreds_medium$tidyPreds[[1]] %>%
rename(predMean_medium=predMean)) %>%
group_by(predOf,Trait) %>%
summarize(corPredMeans=cor(predMean_full,predMean_medium),.groups = 'drop') %>%
arrange(desc(corPredMeans)) %$% summary(corPredMeans)
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 0.9493 0.9798 0.9928 0.9855 0.9960 0.9981
The lowest corPredMeans was 0.95 for the SELIND, perhaps unsurprisingly.
Mean corPredMeans=0.9855. I think we are good to go.
Make a plot (below) to examine the scaling of predMean_medium vs. predMean_full to be sure that combining predMean_full with predSD_medium is safe. Seems like it. Everything is on the same scale as expected.
# crossPreds_full$tidyPreds[[1]] %>%
# rename(predMean_full=predMean) %>%
# left_join(crossPreds_medium$tidyPreds[[1]] %>%
# rename(predMean_medium=predMean)) %>%
# ggplot(aes(x=predMean_full,y=predMean_medium)) +
# geom_point() +
# geom_abline(slope=1,color='darkred') +
# facet_wrap(~Trait, scales='free')
Recompute predUsefulness using predMean_full before saving to disk.
$tidyPreds[[1]] %>%
crossPreds_fullleft_join(crossPreds_medium$tidyPreds[[1]] %>%
rename(predMean_medium=predMean)) %>%
mutate(predUsefulness=predMean+(2.0627128*predSD),
sireGroup=case_when(grepl("2013_|TMS13",sireID)~"TMS13",
grepl("TMS14",sireID)~"TMS14",
grepl("TMS15",sireID)~"TMS15",
grepl("TMS16",sireID)~"TMS16",
grepl("TMS17",sireID)~"TMS17",
grepl("TMS18",sireID)~"TMS18",
grepl("TMS19",sireID)~"TMS19",
grepl("TMS20",sireID)~"TMS20",
!grepl("2013_|TMS13|TMS14|TMS15|TMS16|TMS17|TMS18|TMS19|TMS20",sireID)~"PreGS"),
damGroup=case_when(grepl("2013_|TMS13",damID)~"TMS13",
grepl("TMS14",damID)~"TMS14",
grepl("TMS15",damID)~"TMS15",
grepl("TMS16",damID)~"TMS16",
grepl("TMS17",damID)~"TMS17",
grepl("TMS18",damID)~"TMS18",
grepl("TMS19",damID)~"TMS19",
grepl("TMS20",damID)~"TMS20",
!grepl("2013_|TMS13|TMS14|TMS15|TMS16|TMS17|TMS18|TMS19|TMS20",damID)~"PreGS"),
CrossGroup=paste0(sireGroup,"x",damGroup)) %>%
relocate(contains("Group"),.before = "Nsegsnps") %>%
relocate(predMean,.before = "predMean_medium") %>%
arrange(predOf,Trait,desc(predUsefulness)) %>%
write.csv(.,file = here::here("output","genomicMatePredictions_2021Aug10.csv"),
row.names = F)
NOTE: For cross predictions, check that the predMean from full and medium set are highly correlated. As long as that is true, combine the predMean from full set with pred var from medium set.
library(tidyverse); library(magrittr)
<-readRDS(file = here::here("output","genomicMatePredictions_full_set_2021Sep13.rds"))
crossPreds_full<-readRDS(file = here::here("output","genomicMatePredictions_medium_set_chunk1_2021Sep13.rds")) %>%
crossPreds_mediumbind_rows(readRDS(file = here::here("output","genomicMatePredictions_medium_set_chunk2_2021Sep13.rds"))) %>%
bind_rows(readRDS(file = here::here("output","genomicMatePredictions_medium_set_chunk3_2021Sep13.rds"))) %>%
select(tidyPreds) %>%
unnest(tidyPreds)
$tidyPreds[[1]] %>%
crossPreds_fullrename(predMean_full=predMean) %>%
left_join(crossPreds_medium %>%
rename(predMean_medium=predMean)) %>%
group_by(predOf,Trait) %>%
summarize(corPredMeans=cor(predMean_full,predMean_medium),.groups = 'drop') %>%
arrange(desc(corPredMeans)) %$% summary(corPredMeans)
# Joining, by = c("sireID", "damID", "predOf", "Trait")
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 0.9585 0.9732 0.9863 0.9818 0.9889 0.9964
The lowest corPredMeans was 0.95 for the SELIND, perhaps unsurprisingly.
Mean corPredMeans=0.98. I think we are good to go.
Make a plot (below) to examine the scaling of predMean_medium vs. predMean_full to be sure that combining predMean_full with predSD_medium is safe. Seems like it. Everything is on the same scale as expected.
Recompute predUsefulness using predMean_full before saving to disk.
$tidyPreds[[1]] %>%
crossPreds_fullleft_join(crossPreds_medium %>%
rename(predMean_medium=predMean)) %>%
mutate(predUsefulness=predMean+(2.0627128*predSD),
sireGroup=case_when(grepl("2013_|TMS13",sireID)~"TMS13",
grepl("TMS14",sireID)~"TMS14",
grepl("TMS15",sireID)~"TMS15",
grepl("TMS16",sireID)~"TMS16",
grepl("TMS17",sireID)~"TMS17",
grepl("TMS18",sireID)~"TMS18",
grepl("TMS19",sireID)~"TMS19",
grepl("TMS20",sireID)~"TMS20",
!grepl("2013_|TMS13|TMS14|TMS15|TMS16|TMS17|TMS18|TMS19|TMS20",sireID)~"PreGS"),
damGroup=case_when(grepl("2013_|TMS13",damID)~"TMS13",
grepl("TMS14",damID)~"TMS14",
grepl("TMS15",damID)~"TMS15",
grepl("TMS16",damID)~"TMS16",
grepl("TMS17",damID)~"TMS17",
grepl("TMS18",damID)~"TMS18",
grepl("TMS19",damID)~"TMS19",
grepl("TMS20",damID)~"TMS20",
!grepl("2013_|TMS13|TMS14|TMS15|TMS16|TMS17|TMS18|TMS19|TMS20",damID)~"PreGS"),
CrossGroup=paste0(sireGroup,"x",damGroup)) %>%
relocate(contains("Group"),.before = "Nsegsnps") %>%
relocate(predMean,.before = "predMean_medium") %>%
arrange(predOf,Trait,desc(predUsefulness)) %>%
write.csv(.,file = here::here("output","genomicMatePredictions_2021Sep18.csv"),
row.names = F)