Last updated: 2021-02-01

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 883b1d4. 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:    code/.DS_Store
    Ignored:    data/.DS_Store
    Ignored:    output/.DS_Store
    Ignored:    output/crossRealizations/.DS_Store

Untracked files:
    Untracked:  .gitignore
    Untracked:  Icon
    Untracked:  PredictOutbredCrossVar.Rproj
    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

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/SupplementaryTables.Rmd) and HTML (docs/SupplementaryTables.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 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.

SI Dataset

Initiate

library(writexl)
suptables<-list()

Table S1: Selection indices

Table S1: Selection indices. For each trait, the standard deviation of BLUPs, which were divided by “unscaled” index weights for the StdSI and BiofortSI indices to get StdSI and BiofortSI weights used throughout the study.

library(tidyverse); library(magrittr); 
indices<-readRDS(file=here::here("data","selection_index_weights_4traits.rds"))
suptables[["TableS01"]]<-indices
indices %>% rmarkdown::paged_table()

Table S2: Summary of cross-validation scheme

Table S2: Summary of cross-validation scheme. For each fold of each Rep, the number of parents in the test-set (Ntestparents) is given along with the number of clones in the corresponding training (Ntraintset) and testing (Ntestset) datasets and the number of crosses to predict (NcrossesToPredict).

library(tidyverse); library(magrittr)
parentfolds<-readRDS(file = here::here("data","parentwise_crossVal_folds.rds"))
ped<-readRDS(here::here("data","ped_awc.rds")) %>%
  distinct(sireID,damID)
parentfolds %<>% 
  mutate(CrossesToPredict=map(testparents,~filter(ped,sireID %in% . | damID %in% .)))
parentfold_summary<-parentfolds %>% 
  rename(Rep=id,Fold=id2) %>% 
  mutate(Ntestparents=map_dbl(testparents,length),
         Ntrainset=map_dbl(trainset,length),
         Ntestset=map_dbl(testset,length),
         NcrossesToPredict=map_dbl(CrossesToPredict,nrow)) %>% 
  select(Rep,Fold,starts_with("N"))
suptables[["TableS02"]]<-parentfold_summary
parentfold_summary %>% rmarkdown::paged_table()

Table S3: Test-parents

Table S3: Test-parents. For each fold of each cross-validation repeat, the set of parents whose crosses are to be predicted is listed.

testparents<-parentfolds %>% 
  rename(Rep=id,Fold=id2) %>% 
  select(Rep,Fold,testparents) %>% 
  unnest(testparents)
suptables[["TableS03"]]<-testparents
testparents %>% head %>% rmarkdown::paged_table()

Table S4: Training-Testing partitions of germplasm

Table S4: Training-Testing partitions of germplasm. For each fold of each repeat, the genotype ID (germplasmName) of all clones in the “trainset” and “testset” are given.

train_test_germplasmNames<-parentfolds %>% 
  rename(Rep=id,Fold=id2) %>% 
  select(Rep,Fold,trainset,testset) %>% 
  pivot_longer(cols = c(trainset,testset), names_to = "Set", values_to = "germplasmName") %>% 
  unnest(germplasmName)
suptables[["TableS04"]]<-train_test_germplasmNames
train_test_germplasmNames %>% head %>% rmarkdown::paged_table()

Table S5: Crosses to predict each fold

Table S5: Crosses to predict each fold. For each fold of each repeat, the sireID and damID are given for each cross-to-be-predicted.

CrossesToPredict<-parentfolds %>% 
  rename(Rep=id,Fold=id2) %>% 
  select(Rep,Fold,CrossesToPredict) %>% 
  unnest(CrossesToPredict)
suptables[["TableS05"]]<-CrossesToPredict
CrossesToPredict %>% head %>% rmarkdown::paged_table()

Table S6: Predicted and observed cross means

Table S6: Predicted and observed cross means. For each fold of each repeat, each cross distinguished by a unique pair of sireID and damID is given. The genetic model used (Models A, AD, DirDomAD, DirDomBV), whether the prediction is of mean breeding value (predOf=MeanBV) or mean total genetic value (predOf=MeanTGV), the trait (BiofortSI or StdSI), type of observation (ValidationData: GBLUPs or iidBLUPs) and corresponding prediction (predMean) and observations (obsMean) are shown.

obsVSpredMeans<-readRDS(here::here("output","obsVSpredMeans.rds"))
write.csv(obsVSpredMeans,file = here::here("manuscript", "SupplementaryTable06.csv"), row.names = F)
# suptables[["TableS06"]]<-obsVSpredMeans
obsVSpredMeans %>% str
tibble [199,296 × 10] (S3: tbl_df/tbl/data.frame)
 $ Repeat        : chr [1:199296] "Repeat1" "Repeat1" "Repeat1" "Repeat1" ...
 $ Fold          : chr [1:199296] "Fold1" "Fold1" "Fold1" "Fold1" ...
 $ Model         : chr [1:199296] "A" "A" "A" "A" ...
 $ sireID        : chr [1:199296] "IITA-TMS-BAD9200068" "IITA-TMS-BAD9200068" "IITA-TMS-BAD9200068" "IITA-TMS-BAD9200068" ...
 $ damID         : chr [1:199296] "IITA-TMS-IBA000211" "IITA-TMS-IBA000211" "IITA-TMS-IBA940006" "IITA-TMS-IBA940006" ...
 $ predOf        : chr [1:199296] "MeanBV" "MeanBV" "MeanBV" "MeanBV" ...
 $ Trait         : chr [1:199296] "stdSI" "biofortSI" "stdSI" "biofortSI" ...
 $ predMean      : num [1:199296] 6.68 -3.63 4.74 4.26 6.42 ...
 $ obsMean       : num [1:199296] 8.056 -6.795 -4.541 -0.138 4.009 ...
 $ ValidationData: chr [1:199296] "GBLUPs" "GBLUPs" "GBLUPs" "GBLUPs" ...
obsVSpredMeans %>% count(Model,predOf,ValidationData) %>% spread(predOf,n) %>% rmarkdown::paged_table()

Table S7: Predicted cross variances

Table S7: Predicted cross variances. All predictions of cross-variance from the cross-validation scheme are detailed. For each fold of each repeat and each unique cross (sireID-damID). Both variances (Trait1==Trait2) and co-variances (Trait1!=Trait2) are given. The genetic model used (Models A, AD, DirDomAD, DirDomBV), the variance component being predict (VarA or VarD), along with the number of segregating SNPs in the family (Nsegsnps) and the time taken in seconds for computation, per family (totcomputetime) are given. The predictions based on the variance of posterior means (VPM) and the posterior mean variances (PMV) are both shown.

library(tidyverse); library(magrittr); library(predCrossVar)
# Tidy predicted Vars for Models A and AD
predictedCrossVars<-list.files(here::here("output/crossPredictions")) %>% 
  grep("predictedCrossVars_chunk",.,value = T) %>% 
  map_df(.,~readRDS(here::here("output/crossPredictions",.))) %>% 
  select(Repeat,Fold,Model,crossVars) %>% 
  mutate(crossVars=map(crossVars,
                       function(crossVars){
                         out<-crossVars$predictedCrossVars$varcovars %>% 
                           mutate(varcomps=map(varcomps,~.$predictedfamvars)) %>% 
                           unnest(varcomps) %>% 
                           unnest(predVars)
                         return(out)})) %>% 
  unnest(crossVars)

predictedDirDomCrossVars<-bind_rows(list.files(here::here("output/crossPredictions")) %>% 
                      grep("predictedDirectionalDomCrossVarBVs_chunk",.,value = T) %>% 
                      grep("_15Dec2020.rds",.,value = T) %>% 
                      map_df(.,~readRDS(here::here("output/crossPredictions",.))) %>% 
                      select(Repeat,Fold,crossVars) %>% 
                      mutate(Model="DirDomBV"),
                    list.files(here::here("output/crossPredictions")) %>% 
                      grep("predictedDirectionalDomCrossVarTGVs_chunk",.,value = T) %>% 
                      grep("_15Dec2020.rds",.,value = T) %>% 
                      map_df(.,~readRDS(here::here("output/crossPredictions",.))) %>% 
                      select(Repeat,Fold,crossVars) %>% 
                      mutate(Model="DirDomAD")) %>% 
  mutate(crossVars=map(crossVars,
                       function(crossVars){
                         out<-crossVars$predictedCrossVars$varcovars %>% 
                           mutate(varcomps=map(varcomps,~.$predictedfamvars)) %>% 
                           unnest(varcomps) %>% 
                           unnest(predVars)
                         return(out)})) %>% 
  unnest(crossVars)
# ### Combine all predicted vars into table
predictedCrossVars<-bind_rows(predictedCrossVars,
                              predictedDirDomCrossVars)
rm(predictedDirDomCrossVars); gc()
          used (Mb) gc trigger  (Mb) limit (Mb) max used  (Mb)
Ncells 1139614 60.9    3608520 192.8         NA  4510650 240.9
Vcells 7584317 57.9   15589054 119.0     102400 12835285  98.0
saveRDS(predictedCrossVars,file=here::here("output/crossPredictions","TableS7_predictedCrossVars.rds"))

predictedCrossVars<-readRDS(file=here::here("output/crossPredictions","TableS7_predictedCrossVars.rds"))
write.csv(predictedCrossVars,file = here::here("manuscript", "SupplementaryTable07.csv"), row.names = F)
#suptables[["TableS07"]]<-predictedCrossVars
predictedCrossVars %>% str
tibble [249,120 × 12] (S3: tbl_df/tbl/data.frame)
 $ Repeat        : chr [1:249120] "Repeat1" "Repeat1" "Repeat1" "Repeat1" ...
 $ Fold          : chr [1:249120] "Fold1" "Fold1" "Fold1" "Fold1" ...
 $ Model         : chr [1:249120] "A" "A" "A" "A" ...
 $ Trait1        : chr [1:249120] "DM" "DM" "DM" "DM" ...
 $ Trait2        : chr [1:249120] "DM" "DM" "DM" "DM" ...
 $ sireID        : chr [1:249120] "IITA-TMS-MM964019" "IITA-TMS-MM964019" "IITA-TMS-IBA960557" "IITA-TMS-IBA960869" ...
 $ damID         : chr [1:249120] "IITA-TMS-IBA011273" "IITA-TMS-IBA011371" "IITA-TMS-IBA940006" "IITA-TMS-IBA940006" ...
 $ VarComp       : chr [1:249120] "VarA" "VarA" "VarA" "VarA" ...
 $ VPM           : num [1:249120] 0.369 0.381 0.356 0.359 0.347 ...
 $ PMV           : num [1:249120] 4.29 4.4 4.05 4.31 4.15 ...
 $ Nsegsnps      : int [1:249120] 10583 10189 9788 10070 9749 9814 10601 9804 11309 11424 ...
 $ totcomputetime: Named num [1:249120] 16.6 15.6 13 14.1 12.9 ...
  ..- attr(*, "names")= chr [1:249120] "elapsed" "elapsed" "elapsed" "elapsed" ...
predictedCrossVars %>% count(Model,VarComp) %>% rmarkdown::paged_table()

Table S8: Predicted and observed cross variances

Table S8: Predicted and observed cross variances. For each fold of each repeat, each cross distinguished by a unique pair of sireID and damID is given. The genetic model used (Models A, AD, DirDomAD, DirDomBV), whether the prediction is of family variance in breeding value (predOf=VarBV) or variance in total genetic value (predOf=VarTGV), the trait (BiofortSI or StdSI), type of observation (ValidationData: GBLUPs or iidBLUPs) and corresponding prediction (predVar) and observations (obsVar) are shown. The predictions are based on either only the variance of posterior means (VarMethod=VPM) or the posterior mean variances (VarMethod=PMV). The family size (number of genotyped offspring, FamSize) or number of offspring with direct phenotypes (Nobs) are used (CorrWeight) to weight the correlation between observed and predicted family variances.

obsVSpredVars<-readRDS(here::here("output","obsVSpredVars.rds"))
write.csv(obsVSpredVars,file = here::here("manuscript", "SupplementaryTable08.csv"), row.names = F)
#suptables[["TableS08"]]<-obsVSpredVars
obsVSpredVars %>% str
tibble [797,184 × 15] (S3: tbl_df/tbl/data.frame)
 $ Repeat        : chr [1:797184] "Repeat1" "Repeat1" "Repeat1" "Repeat1" ...
 $ Fold          : chr [1:797184] "Fold1" "Fold1" "Fold1" "Fold1" ...
 $ Model         : chr [1:797184] "A" "A" "A" "A" ...
 $ sireID        : chr [1:797184] "IITA-TMS-BAD9200068" "IITA-TMS-BAD9200068" "IITA-TMS-BAD9200068" "IITA-TMS-BAD9200068" ...
 $ damID         : chr [1:797184] "IITA-TMS-IBA000211" "IITA-TMS-IBA000211" "IITA-TMS-IBA000211" "IITA-TMS-IBA000211" ...
 $ Trait1        : chr [1:797184] "biofortSI" "biofortSI" "DM" "DM" ...
 $ Trait2        : chr [1:797184] "biofortSI" "biofortSI" "DM" "DM" ...
 $ VarMethod     : chr [1:797184] "PMV" "VPM" "PMV" "VPM" ...
 $ predVar       : num [1:797184] 55.3669 5.8562 4.3495 0.355 -0.0762 ...
 $ predOf        : chr [1:797184] "VarBV" "VarBV" "VarBV" "VarBV" ...
 $ obsVar        : num [1:797184] 14.574 14.574 2.303 2.303 -0.045 ...
 $ ValidationData: chr [1:797184] "GBLUPs" "GBLUPs" "GBLUPs" "GBLUPs" ...
 $ FamSize       : num [1:797184] 13 13 13 13 13 13 13 13 13 13 ...
 $ Nobs          : num [1:797184] 6 6 6 6 6 6 6 6 6 6 ...
 $ CorrWeight    : num [1:797184] 13 13 13 13 13 13 13 13 13 13 ...
obsVSpredVars %>% count(Model,predOf,VarMethod,ValidationData) %>% spread(ValidationData,n) %>% rmarkdown::paged_table()

Table S9: Predicted and observed UC

Table S9: Predicted and observed UC. For each fold of each repeat, each cross distinguished by a unique pair of sireID and damID is given. The predicted usefulness criterion (predUC) was computed as the predMean + realIntensity*predSD, where predMean is the predicted family mean and predSD is the predicted genetic standard deviation. The genetic model used (Models A, AD, DirDomAD, DirDomBV), whether the prediction is of family variance in breeding value (predOf=VarBV) or variance in total genetic value (predOf=VarTGV), the trait (BiofortSI or StdSI) and corresponding prediction (predUC) and observations (obsUC) are shown. The family size (number of genotyped offspring, FamSize) is shown along with the realized selection intensity (realIntensity) for each selection stage in the breeding pipeline (Parent, CET, PYT, AYT, UYT) and also a constant intensity value (Stage=ConstIntensity).

obsVSpredUC<-readRDS(here::here("output","obsVSpredUC.rds"))
write.csv(obsVSpredUC,file = here::here("manuscript", "SupplementaryTable09.csv"), row.names = F)
#suptables[["TableS09"]]<-obsVSpredUC
obsVSpredUC %>% str
tibble [130,616 × 15] (S3: tbl_df/tbl/data.frame)
 $ Repeat       : chr [1:130616] "Repeat1" "Repeat1" "Repeat1" "Repeat1" ...
 $ Fold         : chr [1:130616] "Fold1" "Fold1" "Fold1" "Fold1" ...
 $ Model        : chr [1:130616] "A" "A" "A" "A" ...
 $ sireID       : chr [1:130616] "IITA-TMS-IBA030075" "IITA-TMS-IBA030075" "IITA-TMS-IBA030075" "IITA-TMS-IBA030075" ...
 $ damID        : chr [1:130616] "IITA-TMS-IBA940006" "IITA-TMS-IBA940006" "IITA-TMS-IBA940006" "IITA-TMS-IBA940006" ...
 $ Trait        : chr [1:130616] "biofortSI" "biofortSI" "stdSI" "stdSI" ...
 $ VarMethod    : chr [1:130616] "PMV" "VPM" "PMV" "VPM" ...
 $ predOf       : chr [1:130616] "BV" "BV" "BV" "BV" ...
 $ predMean     : num [1:130616] 4.49 4.49 9.21 9.21 -1.03 ...
 $ predSD       : num [1:130616] 7.26 2.29 8.82 3.03 7.34 ...
 $ FamSize      : num [1:130616] 38 38 38 38 7 7 7 7 28 28 ...
 $ realIntensity: num [1:130616] 2.32 2.32 2.32 2.32 1.58 ...
 $ Stage        : chr [1:130616] "Parent" "Parent" "Parent" "Parent" ...
 $ predUC       : num [1:130616] 21.33 9.81 29.65 16.23 10.57 ...
 $ obsUC        : num [1:130616] -0.886 -0.886 7.152 7.152 0.163 ...
obsVSpredUC %>% count(Model,predOf,VarMethod,Stage) %>% spread(VarMethod,n) %>% rmarkdown::paged_table()

Table S10: Accuracies predicting the mean

Table S10: Accuracies predicting the mean. For each fold of each repeat, the accuracy predicting family means (Accuracy) is given. The genetic model used (Models A, AD, DirDomAD, DirDomBV), whether the prediction is of mean breeding value (predOf=MeanBV) or mean total genetic value (predOf=MeanTGV), the trait (BiofortSI or StdSI), type of observation (ValidationData: GBLUPs or iidBLUPs) are shown.

accMeans<-readRDS(here::here("output","accuraciesMeans.rds"))
suptables[["TableS10"]]<-accMeans
accMeans %>% count(Model,predOf,ValidationData,Trait) %>% spread(Trait,n) %>% rmarkdown::paged_table()

Table S11: Accuracies predicting the variances

Table S11: Accuracy of predicting the variances. For each fold of each repeat the estimated accuracy of predicting family variances is given. Accuracy was computed the correlation between predicted and observed variance, either weighted by family size (AccuracyWtCor) or not (AccuracyCor). The genetic model used (Models A, AD, DirDomAD, DirDomBV), whether the prediction is of family variance in breeding value (predOf=VarBV) or variance in total genetic value (predOf=VarTGV), the trait (BiofortSI or StdSI), type of observation (ValidationData: GBLUPs or iidBLUPs) are shown. The predictions are based on either only the variance of posterior means (VarMethod=VPM) or the posterior mean variances (VarMethod=PMV).

accVars<-readRDS(here::here("output","accuraciesVars.rds"))
suptables[["TableS11"]]<-accVars
accVars %>% str
tibble [4,800 × 10] (S3: tbl_df/tbl/data.frame)
 $ Repeat        : chr [1:4800] "Repeat1" "Repeat1" "Repeat1" "Repeat1" ...
 $ Fold          : chr [1:4800] "Fold1" "Fold1" "Fold1" "Fold1" ...
 $ Model         : chr [1:4800] "A" "A" "A" "A" ...
 $ Trait1        : chr [1:4800] "biofortSI" "biofortSI" "DM" "DM" ...
 $ Trait2        : chr [1:4800] "biofortSI" "biofortSI" "DM" "DM" ...
 $ VarMethod     : chr [1:4800] "PMV" "VPM" "PMV" "VPM" ...
 $ predOf        : chr [1:4800] "VarBV" "VarBV" "VarBV" "VarBV" ...
 $ ValidationData: chr [1:4800] "GBLUPs" "GBLUPs" "GBLUPs" "GBLUPs" ...
 $ AccuracyWtCor : num [1:4800] 0.0679 0.1221 0.0302 0.1362 -0.0429 ...
 $ AccuracyCor   : num [1:4800] 0.0818 0.1916 0.0392 0.1186 -0.0373 ...
accVars %>% #mutate(Trait1_Trait2=paste0(Trait1,"_",Trait2)) %>% 
  count(Model,predOf,VarMethod,ValidationData) %>% rmarkdown::paged_table()

Table S12: Accuracies predicting the usefulness criteria

Table S12: Accuracy predicting the usefulness criteria. For each fold of each repeat the estimated accuracy of predicting family usefulness criteria is given. Accuracy was computed as the correlation between predicted UC and observed UC (mean of selected offspring), either weighted by family size (AccuracyWtCor) or not (AccuracyCor). The genetic model used (Models A, AD, DirDomAD, DirDomBV), whether the prediction is of UC in breeding value (predOf=VarBV) or UC in total genetic value (predOf=VarTGV), the trait (BiofortSI or StdSI), type of observation (ValidationData: GBLUPs or iidBLUPs) are shown.

accUC<-readRDS(here::here("output","accuraciesUC.rds"))
suptables[["TableS12"]]<-accUC
accUC %>% str
tibble [1,400 × 9] (S3: tbl_df/tbl/data.frame)
 $ Repeat       : chr [1:1400] "Repeat1" "Repeat1" "Repeat1" "Repeat1" ...
 $ Fold         : chr [1:1400] "Fold1" "Fold1" "Fold1" "Fold1" ...
 $ Model        : chr [1:1400] "A" "A" "A" "A" ...
 $ Trait        : chr [1:1400] "biofortSI" "biofortSI" "stdSI" "stdSI" ...
 $ VarMethod    : chr [1:1400] "PMV" "VPM" "PMV" "VPM" ...
 $ predOf       : chr [1:1400] "BV" "BV" "BV" "BV" ...
 $ Stage        : chr [1:1400] "Parent" "Parent" "Parent" "Parent" ...
 $ AccuracyWtCor: num [1:1400] 0.479 0.705 0.464 0.603 0.457 ...
 $ AccuracyCor  : num [1:1400] 0.187 0.472 0.189 0.452 0.137 ...
accUC %>%
  count(Model,predOf,VarMethod,Stage,Trait) %>% spread(Trait,n) %>% rmarkdown::paged_table()

Table S13: Realized within-cross selection metrics

Table S13: Realized within-cross selection metrics. Table summarizing measurements made of selection within each cross (unique sireID-damID). Summaries included: family size (FamSize), number and proportion of members used as parents, mean GEBV and GETGV of top 1% of each family, for each selection index (BiofortSI, StdSI), proportion of each family that has been phenotyped and past each stage of the breeding pipeline (past CET, PYT, AYT) and finally the corresponding realized intensity of selection for each stage.

realizedcrossmetrics<-readRDS(file=here::here("output/crossRealizations","realizedCrossMetrics.rds"))
realizedcrossmetrics %<>% 
  select(-Repeat,-Fold,-Model,-contains("realizedUC")) %>% 
  ungroup() %>% 
  distinct %>% 
  arrange(desc(FamSize))
suptables[["TableS13"]]<-realizedcrossmetrics
realizedcrossmetrics %>% str
tibble [8,304 × 22] (S3: tbl_df/tbl/data.frame)
 $ sireID                    : chr [1:8304] "IITA-TMS-IBA011412" "IITA-TMS-IBA011412" "IITA-TMS-IBA011412" "IITA-TMS-IBA011412" ...
 $ damID                     : chr [1:8304] "IITA-TMS-IBA020129" "IITA-TMS-IBA020129" "IITA-TMS-IBA020129" "IITA-TMS-IBA020129" ...
 $ FamSize                   : num [1:8304] 72 72 72 72 72 72 72 72 72 72 ...
 $ NmembersUsedAsParent      : num [1:8304] 5 5 5 5 5 5 5 5 5 5 ...
 $ propUsedAsParent          : num [1:8304] 0.0694 0.0694 0.0694 0.0694 0.0694 ...
 $ meanTop1pctGEBV_stdSI     : num [1:8304] 2.73 6.9 3.32 5.4 2.9 ...
 $ meanTop1pctGEBV_biofortSI : num [1:8304] 15.1 15.9 15.3 15.9 14.1 ...
 $ NmembersPhenotyped        : num [1:8304] 71 71 71 71 71 71 71 71 71 71 ...
 $ NmembersPastCET           : num [1:8304] 13 13 13 13 13 13 13 13 13 13 ...
 $ NmembersPastPYT           : num [1:8304] 6 6 6 6 6 6 6 6 6 6 ...
 $ NmembersPastAYT           : num [1:8304] 0 0 0 0 0 0 0 0 0 0 ...
 $ propPhenotyped            : num [1:8304] 0.986 0.986 0.986 0.986 0.986 ...
 $ propPastCET               : num [1:8304] 0.181 0.181 0.181 0.181 0.181 ...
 $ propPastPYT               : num [1:8304] 0.0833 0.0833 0.0833 0.0833 0.0833 ...
 $ propPastAYT               : num [1:8304] 0 0 0 0 0 0 0 0 0 0 ...
 $ meanTop1pctGETGV_stdSI    : num [1:8304] 4.92 6.45 5.98 7.12 1.6 ...
 $ meanTop1pctGETGV_biofortSI: num [1:8304] 14 14.5 15.1 15.9 17.4 ...
 $ realIntensityParent       : num [1:8304] 1.92 1.92 1.92 1.92 1.92 ...
 $ realIntensityCET          : num [1:8304] 0.0359 0.0359 0.0359 0.0359 0.0359 ...
 $ realIntensityPYT          : num [1:8304] 1.46 1.46 1.46 1.46 1.46 ...
 $ realIntensityAYT          : num [1:8304] 1.84 1.84 1.84 1.84 1.84 ...
 $ realIntensityUYT          : num [1:8304] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ...

Table S14: Proportion homozygous per clone

Table S14: Proportion homozygous per clone. Genome-wide proportion of SNPs that are homozygous, for each clone in the study.

library(tidyverse); library(magrittr); library(rsample); library(predCrossVar)
ped<-readRDS(here::here("data","ped_awc.rds"))
snps<-readRDS(here::here("data","dosages_awc.rds"))
snps %<>% 
  .[rownames(snps) %in% ped$FullSampleName,] %>% 
  remove_invariant(.); dim(snps) # [1]  3199 33370
f<-getPropHom(snps)
propHom<-tibble(GID=names(f), PropSNP_homozygous=as.numeric(f))
saveRDS(propHom,file=here::here("output","propHomozygous.rds"))
propHom<-readRDS(file=here::here("output","propHomozygous.rds"))
suptables[["TableS14"]]<-propHom
head(propHom) %>% rmarkdown::paged_table()

Table S15: Variance estimates for genetic groups

Table S15: Variance estimates for genetic groups. Summary of the population-level genetic variance estimates in each genetic group (GG, TMS13, TMS14, TMS15), for each genetic model (A, AD, DirDomA, DirDomAD), each variance (Trait1==Trait2) and covariance (Trait1!=Trait2). The estimates are computed both based on the variance of posterior means (VarMethod=VPM) and the posterior mean variances (VarMethod=PMV). The “Method” refers to whether linkage disequilibrium is accounted for (M2) or not (M1).

varcomps_geneticgroups<-readRDS(here::here("output","pmv_varcomps_geneticgroups_tidy_includingSIvars.rds"))
varcomps_geneticgroups %<>% 
  spread(VarComp,Var) %>% 
  mutate_if(is.numeric,~round(.,6)) %>% 
  mutate(propDom=ifelse(!is.na(VarD),round(VarD/(VarA+VarD),2),0)) %>% 
  select(-outName) %>%
  arrange(VarMethod,desc(Method))
suptables[["TableS15"]]<-varcomps_geneticgroups
varcomps_geneticgroups %>% rmarkdown::paged_table()
varcomps_geneticgroups %>% count(Method,VarMethod) %>% rmarkdown::paged_table()
varcomps_geneticgroups %>% count(Group,Model) %>% spread(Model,n) %>% rmarkdown::paged_table()

Table S16: Directional dominance effects estimates

Table S16: Directional dominance effects estimates. For each trait in each genetic group and each fold of each cross-validation repeat of the directional dominance model, the posterior mean and standard deviation of the effect of genome-wide homozygosity is given.

ddEffects<-readRDS(file=here::here("output","ddEffects.rds"))
ddEffects %<>% 
  mutate(Group=ifelse(is.na(Group),"ParentwiseCV",Group))
suptables[["TableS16"]]<-ddEffects
ddEffects %>% rmarkdown::paged_table()
ddEffects %>% count(Group,Dataset,Trait) %>% spread(Trait,n) %>% arrange(Dataset)
# A tibble: 7 x 6
  Group        Dataset          DM logFYLD MCMDS TCHART
  <chr>        <chr>         <int>   <int> <int>  <int>
1 All          GeneticGroups     1       1     1      1
2 GG           GeneticGroups     1       1     1      1
3 TMS13        GeneticGroups     1       1     1      1
4 TMS14        GeneticGroups     1       1     1      1
5 TMS15        GeneticGroups     1       1     1      1
6 ParentwiseCV testset          25      25    25     25
7 ParentwiseCV trainset         25      25    25     25

Table S17: Predictions of untested crosses

Table S17: Predictions of untested crosses. Compiled predictions of 47,083 possible crosses of 306 parents. Predictions were made either with the classic additive-plus-dominance (ClassicAD) or the directional dominance (DirDomAD) model. Whether the cross is a self and/or has previously been made is indicated along with the number of segregating SNPs expected in the family. The predicted mean, standard deviation and usefulness in terms of breeding values (BV) and total genetic values is given.

library(tidyverse); library(magrittr);
predUntestedCrossMeans<-readRDS(here::here("output/crossPredictions","predictedUntestedCrossMeans_SelIndices.rds"))
#predUntestedCrossMeans %>% count(Model)
predUntestedCrossVars<-readRDS(here::here("output/crossPredictions","predictedUntestedCrossVars_SelIndices.rds"))
#predUntestedCrossVars %>% count(Model,predOf)
predUntestedCrosses<-predUntestedCrossMeans %>% 
  left_join(predUntestedCrossVars %>% 
              rename(Trait=Trait1) %>% select(-Trait2) %>% 
              mutate(Model=ifelse(Model %in% c("A","AD"),"ClassicAD","DirDom")) %>% 
              spread(predOf,predVar))
#
predUntestedCrosses %<>% 
  mutate(VarTGV=VarA+VarD,
         predSdBV=sqrt(VarBV),
         predSdTGV=sqrt(VarTGV)) %>% 
  select(-VarBV,-VarTGV,-VarA,-VarD) %>% 
# Mean prop. selected is 2% for "parents" and 5% for "varieties" (AYT stage). 
# Since in general, we want to use fewer crosses with more progeny, let's use 1% (std. sel. intensity = 2.67) for predicting UC.
# predCrossVar::intensity(0.01) %>% round(.,2) # [1] 2.67
  mutate(predUCparent=predMeanBV+(2.67*predSdBV),
         predUCvariety=predMeanGV+(2.67*predSdTGV))
ped<-readRDS(here::here("data","ped_awc.rds"))
predUntestedCrosses %<>% 
  left_join(ped %>% distinct(sireID,damID) %>% mutate(CrossPrevMade="Yes")) %>% 
  mutate(CrossPrevMade=ifelse(is.na(CrossPrevMade),"No",CrossPrevMade),
         IsSelf=ifelse(sireID==damID,TRUE,FALSE))
rm(ped)

predUntestedCrosses %>% str
tibble [188,332 × 15] (S3: tbl_df/tbl/data.frame)
 $ sireID       : chr [1:188332] "IITA-TMS-BAD9200061" "IITA-TMS-BAD9200061" "IITA-TMS-BAD9200061" "IITA-TMS-BAD9200061" ...
 $ damID        : chr [1:188332] "IITA-TMS-BAD9200061" "IITA-TMS-BAD9200061" "IITA-TMS-BAD9200061" "IITA-TMS-BAD9200061" ...
 $ Model        : chr [1:188332] "ClassicAD" "ClassicAD" "DirDom" "DirDom" ...
 $ Trait        : chr [1:188332] "stdSI" "biofortSI" "stdSI" "biofortSI" ...
 $ sireGEBV     : num [1:188332] -1.86 -8.1 -2.77 -8.81 -1.86 ...
 $ damGEBV      : num [1:188332] -1.86 -8.1 -2.77 -8.81 1.52 ...
 $ predMeanBV   : num [1:188332] -1.86 -8.1 -2.77 -8.81 -0.17 ...
 $ predMeanGV   : num [1:188332] 4.07 -2.5 12.66 -1.76 12.32 ...
 $ Nsegsnps     : num [1:188332] 5223 5223 5223 5223 7789 ...
 $ predSdBV     : num [1:188332] 2.92 2.44 3.27 2.65 3.18 ...
 $ predSdTGV    : num [1:188332] 3.69 2.94 3.38 2.63 3.78 ...
 $ predUCparent : num [1:188332] 5.94 -1.58 5.95 -1.75 8.31 ...
 $ predUCvariety: num [1:188332] 13.93 5.36 21.68 5.26 22.42 ...
 $ CrossPrevMade: chr [1:188332] "No" "No" "No" "No" ...
 $ IsSelf       : logi [1:188332] TRUE TRUE TRUE TRUE FALSE FALSE ...
write.csv(predUntestedCrosses,file = here::here("manuscript", "SupplementaryTable17.csv"), row.names = F)
#suptables[["TableS17"]]<-predUntestedCrosses

Table S18: Long-form table of predictions about untested crosses

Table S18: Long-form table of predictions about untested crosses. Compiled predictions of 47,083 possible crosses of 306 parents. Predictions were made either with the classic additive-plus-dominance (ClassicAD) or the directional dominance (DirDomAD) model. Whether the cross is a self and/or has previously been made is indicated along with the number of segregating SNPs expected in the family. The predicted mean, standard deviation and usefulness in terms of breeding values (BV) and total genetic values is given.

predBVs<-predUntestedCrosses %>%
  select(sireID,damID,IsSelf,CrossPrevMade,Model,Trait,predMeanBV,predSdBV,predUCparent) %>% 
  rename(predMean=predMeanBV,
         predSd=predSdBV,
         predUC=predUCparent) %>% 
  pivot_longer(cols = c(predMean,predSd,predUC), names_to = "PredOf", values_to = "Pred",names_prefix = "pred")

predTGVs<-predUntestedCrosses %>%
  select(sireID,damID,IsSelf,CrossPrevMade,Model,Trait,predMeanGV,predSdTGV,predUCvariety) %>% 
  rename(predMean=predMeanGV,
         predSd=predSdTGV,
         predUC=predUCvariety) %>% 
  pivot_longer(cols = c(predMean,predSd,predUC), names_to = "PredOf", values_to = "Pred",names_prefix = "pred")

predUntestedCrosses_long<-bind_rows(predBVs %>% mutate(Component="BV"),
                                    predTGVs %>% mutate(Component="TGV"))
# predUntestedCrosses_long %<>% 
#   left_join(predUntestedCrosses_long %>% 
#               group_by(Trait,Model,PredOf,Component) %>%  
#               summarise(top1pct = quantile(Pred, 0.99)) %>% 
#               ungroup()) %>% 
#   mutate(Selected=ifelse(Pred>=top1pct,"Selected","NotSelected")) %>% 
#   mutate_all(~`attributes<-`(.,NULL))
predUntestedCrosses_long %>% str
tibble [1,129,992 × 9] (S3: tbl_df/tbl/data.frame)
 $ sireID       : chr [1:1129992] "IITA-TMS-BAD9200061" "IITA-TMS-BAD9200061" "IITA-TMS-BAD9200061" "IITA-TMS-BAD9200061" ...
 $ damID        : chr [1:1129992] "IITA-TMS-BAD9200061" "IITA-TMS-BAD9200061" "IITA-TMS-BAD9200061" "IITA-TMS-BAD9200061" ...
 $ IsSelf       : logi [1:1129992] TRUE TRUE TRUE TRUE TRUE TRUE ...
 $ CrossPrevMade: chr [1:1129992] "No" "No" "No" "No" ...
 $ Model        : chr [1:1129992] "ClassicAD" "ClassicAD" "ClassicAD" "ClassicAD" ...
 $ Trait        : chr [1:1129992] "stdSI" "stdSI" "stdSI" "biofortSI" ...
 $ PredOf       : chr [1:1129992] "Mean" "Sd" "UC" "Mean" ...
 $ Pred         : num [1:1129992] -1.86 2.92 5.94 -8.1 2.44 ...
 $ Component    : chr [1:1129992] "BV" "BV" "BV" "BV" ...
predUntestedCrosses_long %>% 
  count(Trait,Model,PredOf,Component) %>% spread(Trait,n) %>% rmarkdown::paged_table()
write.csv(predUntestedCrosses_long,file = here::here("manuscript", "SupplementaryTable18.csv"), row.names = F)
#suptables[["TableS18"]]<-predUntestedCrosses_long
rm(list=grep("suptables",ls(),invert = T, value = T)); gc()
          used (Mb) gc trigger  (Mb) limit (Mb) max used  (Mb)
Ncells 1165054 62.3    3608520 192.8         NA  4510650 240.9
Vcells 2717577 20.8   47115796 359.5     102400 56070129 427.8

Table S19: Top 50 crosses selected by each criterion

Table S19: Top 50 crosses selected by each criterion. For each of the 16 predictions of 47,083 crosses, select the top 50 ranked crosses.

library(tidyverse); library(magrittr); library(ggforce)
predUntestedCrosses<-read.csv(here::here("manuscript","SupplementaryTable18.csv"),stringsAsFactors = F)
top50crosses<-predUntestedCrosses %>% 
  filter(PredOf!="Sd") %>%
  group_by(Trait,Model,PredOf,Component) %>% 
  slice_max(order_by = Pred,n=50) %>% ungroup()
suptables[["TableS19"]]<-top50crosses

Write SupplementaryTables.xlsx

writexl::write_xlsx(suptables,path = here::here("manuscript","SupplementaryTables.xlsx"),format_headers =FALSE)

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] ggforce_0.3.2.9000 predCrossVar_0.1.0 magrittr_2.0.1     forcats_0.5.1     
 [5] stringr_1.4.0      dplyr_1.0.3        purrr_0.3.4        readr_1.4.0       
 [9] tidyr_1.1.2        tibble_3.0.6       ggplot2_3.3.3      tidyverse_1.3.0   
[13] writexl_1.3.1     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6        lubridate_1.7.9.2 here_1.0.1        ps_1.5.0         
 [5] assertthat_0.2.1  rprojroot_2.0.2   digest_0.6.27     utf8_1.1.4       
 [9] R6_2.5.0          cellranger_1.1.0  backports_1.2.1   reprex_1.0.0     
[13] evaluate_0.14     httr_1.4.2        pillar_1.4.7      rlang_0.4.10     
[17] readxl_1.3.1      rstudioapi_0.13   whisker_0.4       rmarkdown_2.6    
[21] polyclip_1.10-0   munsell_0.5.0     broom_0.7.4       compiler_4.0.2   
[25] httpuv_1.5.5      modelr_0.1.8      xfun_0.20         pkgconfig_2.0.3  
[29] htmltools_0.5.1.1 tidyselect_1.1.0  workflowr_1.6.2   fansi_0.4.2      
[33] crayon_1.3.4      dbplyr_2.0.0      withr_2.4.1       later_1.1.0.1    
[37] MASS_7.3-53       grid_4.0.2        jsonlite_1.7.2    gtable_0.3.0     
[41] lifecycle_0.2.0   DBI_1.1.1         git2r_0.28.0      scales_1.1.1     
[45] cli_2.3.0         stringi_1.5.3     farver_2.0.3      fs_1.5.0         
[49] promises_1.1.1    xml2_1.3.2        ellipsis_0.3.1    generics_0.1.0   
[53] vctrs_0.3.6       tools_4.0.2       glue_1.4.2        tweenr_1.0.1     
[57] hms_1.0.0         yaml_2.2.1        colorspace_2.0-0  rvest_0.3.6      
[61] knitr_1.31        haven_2.3.1