Last updated: 2020-08-26

Checks: 7 0

Knit directory: EMBRAPA_2020GS/

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(20200826) 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 bcd83b4. 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:    .Rproj.user/
    Ignored:    analysis/.DS_Store
    Ignored:    data/.DS_Store

Untracked files:
    Untracked:  data/Report-DCas20-5360/

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/ImputeDCas20_5360.Rmd) and HTML (docs/ImputeDCas20_5360.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 bcd83b4 wolfemd 2020-08-26 Initial publish (prior to running imputation). Debugging will be
Rmd 9d4dfab wolfemd 2020-08-26 Code organized into functions. Ready to run imputation of C2?

DArTseqLD (DCas20-5360) arrived on Aug. 22, 2020. Contains GS C2 for EMBRAPA.

Last year’s reference panel for imputation had ~64K SNP. The C1 progeny imputed by it had <9K SNP after post-imputation filters.

Options to proceed with imputation of C2 (DCas20-5360):

  1. Last year’s reference panel, without C1 (64K SNP)
  2. Last year’s reference panel + C1 (reduce refpanel to sites passing post-impute filter in C1 = 9K SNP)
  3. Last year’s ref. panel + C1 (include unfiltered C1 data = 64K refpanel SNP)

If I can use Beagle5 or latest, should be possible (fast) to create all 3 and compare the results using PCA, prediction, correlation of kinship matrices, etc.

Impute EMBRAPA GS C2

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

cp /home/jj332_cas/CassavaGenotypeData/nextgenImputation2019/ImputationEMBRAPA_102419/chr*_ImputationReferencePanel_EMBRAPA_Phased_102619.vcf.gz /workdir/EMBRAPA_2020GS/data/
cp -r /home/jj332_cas/CassavaGenotypeData/CassavaGeneticMap /workdir/EMBRAPA_2020GS/data/

RefPanel: Exclude C1

Impute with Beagle V5.0.

Use the “imputation reference panel” dataset from 2019, e.g. chr1_ImputationReferencePanel_EMBRAPA_Phased_102619.vcf.gz as reference.

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

R functions are stored in the code/ sub-directory. Functions sourced from e.g. imputationFunctions.R are wrappers around e.g. Beagle, and other command line programs.

targetVCFpath<-here::here("data/Report-DCas20-5360/") # location of the targetVCF
refVCFpath<-here::here("data/")
mapPath<-here::here("data/CassavaGeneticMap/")
outPath<-here::here("output/")
outSuffix<-"DCas20_5360"
source(imputationFunctions.R)
purrr::map(1:18,~runBeagle5(targetVCF=paste0(targetVCFpath,"chr",.,"_DCas20_5360.vcf.gz"),
                            refVCF=paste0(refVCFpath,"chr",.,"_ImputationReferencePanel_EMBRAPA_Phased_102619.vcf.gz"),
                            mapFile=paste0(mapPath,"chr",.,"_cassava_cM_pred.v6_91019.map"),
                            outName=paste0(outPath,"chr",.,"_DCas20_5360_REFimputed"),
                            nthreads=112))

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

cd /workdir/EMBRAPA_2020GS/output/; 
mkdir BeagleLogs;
cp *_DCas20_5360_REFimputed.log BeagleLogs/

Post-impute filter

For now, the function will just do a fixed filter: AR2>0.75 (DR2>0.75 as of Beagle5.0), P_HWE>1e-20, MAF>0.005 [0.5%].

It can easily be modified in the future to include parameters to vary the filter specifications.

Input parameters

#' @inPath path to input VCF-to-be-filtered, can be left null if path included in @inName . Must end in "/"
#' @inName name of input VCF file EXCLUDING file extension. Assumes .vcf.gz
#' @outPath path where filtered VCF and related are to be stored.Can be left null if path included in @outName . Must end in "/".
#' @outName name desired for output EXCLUDING extension. Output will be .vcf.gz 
inPath<-here::here("output/")
outPath<-here::here("output/")

Loop to filter all 18 VCF files in parallel

source(imputationFunctions.R)
require(furrr); options(mc.cores=ncores); plan(multiprocess)
future_map(1:18,~postImputeFilter(inPath=inPath,
                                  inName=paste0("chr",.,"_DCas20_5360_REFimputed"),
                                  outPath=outPath,
                                  outName=paste0("chr",.,"_DCas20_5360_REFimputedAndFiltered")))

Check what’s left

purrr::map(list(Chr=1:18),~system(paste0("wc -l ",here::here("output/"),"chr",.,"_",outName,".vcf.gz")))

RefPanel: Include C1, filtered sites only

RefPanel: Include C1, all sites


sessionInfo()