Last updated: 2021-08-19

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 182b83c. 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

Untracked files:
    Untracked:  data/DatabaseDownload_2021Aug08/
    Untracked:  data/DatabaseDownload_2021May04/
    Untracked:  data/GBSdataMasterList_31818.csv
    Untracked:  data/IITA_GBStoPhenoMaster_33018.csv
    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/

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/ImputeDCas21_6038.Rmd) and HTML (docs/ImputeDCas21_6038.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
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.
html a3150ab wolfemd 2021-08-09 Build site.
Rmd 6f2057f wolfemd 2021-08-09 Publish project. Imputation completed. Run and complete ‘cleanTPdata’ step.

Copy data

Copy the imputation reference panel from 2019 to the data/ folder.

mkdir /workdir/mw489/;
cp -r ~/IITA_2021GS /workdir/mw489/;
cp -r /home/jj332_cas/CassavaGenotypeData/CassavaGeneticMap /workdir/mw489/IITA_2021GS/data/;
cp /home/jj332_cas/CassavaGenotypeData/nextgenImputation2019/ImputationStageIII_72619/chr*_RefPanelAndGSprogeny_ReadyForGP_72719.vcf.gz  /workdir/mw489/IITA_2021GS/data/;

Impute with West Africa RefPanel

Impute with Beagle V5.0.

Use the “imputation reference panel” dataset from 2019 merged with the imputed GS progeny TMS13-14-15 + TMS18, e.g. chr1_RefPanelAndGSprogeny_ReadyForGP_72719.vcf.gz as reference for the current imputation.

Used 1 large memory Cornell CBSU machine (e.g. cbsulm17; 112 cores, 512 GB RAM), running 1 chromosome at a time.

# 1) start a screen shell 
screen; # or screen -r if re-attaching...
# Project directory, so R will use as working dir.
cd /workdir/mw489/IITA_2021GS/
# 3) Start R
R
targetVCFpath<-here::here("data/Report-DCas21-6038/") # location of the targetVCF
refVCFpath<-here::here("data/")
mapPath<-here::here("data/CassavaGeneticMap/")
outPath<-here::here("output/")
outSuffix<-"DCas21_6038"
library(tidyverse); library(magrittr); 
library(genomicMateSelectR)
purrr::map(1:18,
           ~genomicMateSelectR::runBeagle5(targetVCF=paste0(targetVCFpath,"chr",.,
                                                            "_DCas21_6038.vcf.gz"),
                                           refVCF=paste0(refVCFpath,"chr",.,
                                                         "_RefPanelAndGSprogeny_ReadyForGP_72719.vcf.gz"),
                                           mapFile=paste0(mapPath,"chr",.,
                                                          "_cassava_cM_pred.v6_91019.map"),
                                           outName=paste0(outPath,"chr",.,
                                                          "_DCas21_6038_WA_REFimputed"),
                                           nthreads=112))

Clean up Beagle log files after run. Move to sub-directory output/BeagleLogs/.

cd /workdir/mw489/IITA_2021GS/output/; 
mkdir BeagleLogs;
cp *_DCas21_6038_WA_REFimputed.log BeagleLogs/
cp -r BeagleLogs ~/IITA_2021GS/output/
cp *_DCas21_6038_WA_REFimputed* ~/IITA_2021GS/output/
cp *_DCas21_6038_WA_REFimputed.vcf.gz ~/IITA_2021GS/output/

Post-impute filter

Standard post-imputation filter: AR2>0.75 (DR2>0.75 as of Beagle5.0), P_HWE>1e-20, MAF>0.005 [0.5%].

Loop to filter all 18 VCF files in parallel

inPath<-here::here("output/")
outPath<-here::here("output/")
require(furrr); plan(multisession, workers = 18)
future_map(1:18,
           ~genomicMateSelectR::postImputeFilter(inPath=inPath,
                                                 inName=paste0("chr",.,"_DCas21_6038_WA_REFimputed"),
                                                 outPath=outPath,
                                                 outName=paste0("chr",.,"_DCas21_6038_WA_REFimputedAndFiltered")))
plan(sequential)

Check what’s left

purrr::map(1:18,~system(paste0("zcat ",here::here("output/"),"chr",.,"_DCas21_6038_WA_REFimputedAndFiltered.vcf.gz | wc -l")))
# 7580
# 3604
# 3685
# 3411
# 3721
# 3349
# 1716
# 3151
# 3286
# 2635
# 2897
# 2745
# 2625
# 5219
# 3519
# 2751
# 2612
# 2913
cd /workdir/mw489/IITA_2021GS/output/;
cp -r *_DCas21_6038_WA_REFimputed* ~/IITA_2021GS/output/

Formats for downstream analysis

Need to create a genome-wide VCF with the RefPanel + DCas21_6038 VCFs merged.

The downstream preprocessing steps in the pipeline will take that as input to create haplotype and dosage matrices, etc.

cd /workdir/mw489/IITA_2021GS/
R;
require(furrr); plan(multisession, workers = 18)
# 1. Subset RefPanel to sites remaining after post-impute filter of DCas21_6038
future_map(1:18,~system(paste0("vcftools --gzvcf ",
                               "/workdir/mw489/IITA_2021GS/data/chr",
                               .,"_RefPanelAndGSprogeny_ReadyForGP_72719.vcf.gz"," ",
                               "--positions ","/workdir/mw489/IITA_2021GS/output/chr",.,
                               "_DCas21_6038_WA_REFimputed.sitesPassing"," ",
                               "--recode --stdout | bgzip -c -@ 24 > ",
                               "/workdir/mw489/IITA_2021GS/output/chr",.,
                               "_RefPanelAndGSprogeny72719_SubsetAndReadyToMerge.vcf.gz")))
plan(sequential)

# 2. Merge RefPanel and DCas21_6038
library(tidyverse); library(magrittr); library(genomicMateSelectR)
inPath<-here::here("output/")
outPath<-here::here("output/")
future_map(1:18,~mergeVCFs(inPath=inPath,
                           inVCF1=paste0("chr",.,"_RefPanelAndGSprogeny72719_SubsetAndReadyToMerge"),
                           inVCF2=paste0("chr",.,"_DCas21_6038_WA_REFimputedAndFiltered"),
                           outPath=outPath,
                           outName=paste0("chr",.,"_RefPanelAndGSprogeny_ReadyForGP_2021Aug08")))
# 3. Concatenate chromosomes

## Index with tabix first
future_map(1:18,~system(paste0("tabix -f -p vcf ",inPath,
                               "chr",.,"_RefPanelAndGSprogeny_ReadyForGP_2021Aug08.vcf.gz")))
plan(sequential)
## bcftools concat
system(paste0("bcftools concat ",
              "--output ",outPath,
              "AllChrom_RefPanelAndGSprogeny_ReadyForGP_2021Aug08.vcf.gz ",
              "--output-type z --threads 18 ",
              paste0(inPath,"chr",1:18,
                     "_RefPanelAndGSprogeny_ReadyForGP_2021Aug08.vcf.gz",
                     collapse = " ")))

## Convert to binary blink (bed/bim/fam)
vcfName<-"AllChrom_RefPanelAndGSprogeny_ReadyForGP_2021Aug08"
system(paste0("export PATH=/programs/plink-1.9-x86_64-beta3.30:$PATH;",
              "plink --vcf ",inPath,vcfName,".vcf.gz ",
              "--make-bed --const-fid --keep-allele-order ",
              "--out ",outPath,vcfName))
cd /workdir/mw489/IITA_2021GS/output/
cp *_RefPanelAndGSprogeny_ReadyForGP_2021Aug08* ~/IITA_2021GS/output/
# vcftools --gzvcf AllChrom_RefPanelAndGSprogeny_ReadyForGP_2021Aug08.vcf.gz 
# After filtering, kept 23332 out of 23332 Individuals
# After filtering, kept 61239 out of a possible 61239 Sites