Snakemake workflow to genotype any type of NGS samples.
To install the workflow simply pull it from githib.
git clone https://github.com/TimothyStephens/Genotype_Samples.gitThen setup the conda environment which we will use to run the snakemake workflow.
conda env create -f environment.yaml
conda activate Genotype_SamplesTo run the workflow you will need to have two config/metadata files prepared.
The first config/metadata file is the config/config.*.yaml file.
- The
config/config.Genotyping.yamlfile is a template for the genotyping workflow - The
config/config.crossMapping.yamlfile is a template for the cross_mapping workflow When you want to run one of thse workflows make a copy of the relevant config file and fill it out. The main params that need to be changed are: project_nameThe name of this project. A directory with the same name will be created inresults/and is where the final analysis will be stored.samples: The path to thesamples.tsvfile to use for analysis.ref_genomes: The name and location of the reference genome to use for analysis.
The second config/metadata file is the config/samples.tsv file.
This file lists the names and locations of all samples that will be considered by the workflow. Any additional columns that are present in this file will be considered metadata that is to be plotted along with the results (e.g., putative species, collection location, etc.). Colors will be automatically assigned but can be changed manually after the workflow has finished.
sample_idThe ID of the sampleunitA number used to differentiate samples with multiple input read sets. If you only have one set of reads per sample then keep this number as1. If you have multiple seqs of reads per sample then give each set a different number. Reads from the same sample_id but different "units" will be QC'ed, trimmed, and aligned separatly, but combine after that for final variant calling, genotyping, and ploidy analysis.lib_typeLets you specify if the reads aredna-se,dna-pe,rna-se,rna-pe,dna-long, orrna-longsequencing.fq1Location (absolute path) of the 1st read file OR the SRA ID of the sample which you wish the workflow to download and process for you.fq2Location (absolute path) of the 2nd read file (if present) OR the SRA ID of the sample which you wish the workflow to download and process for you. If you have samples that are single end, omit this column for those samples.
NOTE:
- For SRA ID samples. You need to tell the workflow to expect the downloaded files to be single or paired-end. To specify paired-end you simply need to list the SRA ID in the
fq1andfq2columns, to specify single-end specify the SRA ID in just thefq1column and omit thefq2column. - You can run each workflow multiple times with different subsets of samples. Just change the
project_namein the config file and snakemake will do the rest. - If you wish to add more samples to an existing project, simply add them to the config file and let snakemake do the rest.
- Default config values are stored in
workflow/config.default.yaml. If you want to modify them globally then do so in theconfig.default.yamlfile, if you want to do it for a single project, simply add them to your project config file. The project config file provided by the user will overwrite any params in the global default file, so it is OK for a param to be set in both. - In the
samples.tsvfile, theunitcolumn allows samples split across multiplefastqfiles to be combined. - Colors will be automatically assigned to each category in the additional metadata included in the
samples.tsvfile provided by the user. Once the workflow has finished the user can change the colors used by altering the hex values inresults/{project_name}/final/colors.tsv, removing theresults/{project_name}/*.donefile, and rerunning the original workflow command.
This workflow is broken down into two parts that can be run separatly but using the same underlying datasets.
The Genotype_Samples.py script handels the high level running and organization of the workflow.
Compare samples against multiple genomes and report mapping stats (% mapped reads) as a way of checking/determining the "species" that a sample is from/has highest similarity to.
conda activate Genotype_Samples
./Genotype_Samples.py --module cross_mapping --configfile config/config.CrossMapping.yamlOnce the workflow has finished it should have generated a report for all the major outputs and plots. This report will be in the project results directory, it will the form of a HTML file which will be contained in a zip file, and will be named after the workflow that you ran (i.e., the report HTML will be in /results/project_name/module_type.zip).
Full genotyping workflow. Call variants, calculate relatedness stats, estimate ploidy, and generate QC and results plots.
conda activate Genotype_Samples
./Genotype_Samples.py --module genotyping --configfile config/config.Genotyping.yamlProfile the ploidy of DNA samples using GenomeScope2 and Smudgeplot.
After inspecting the plots, if you wish to change some of the cutoffs used for plotting you can do so for each sample in results/kmer_analysis/cutoffs/.
conda activate Genotype_Samples
./Genotype_Samples.py --module kmer_analysis --configfile config/config.KmerAnalysis.yamlRun test analyses using the following commands.
conda activate Genotype_Samples
# Cross-mapping
./Genotype_Samples.py --module cross_mapping --configfile tests/config/config.crossMapping_small.yaml
./Genotype_Samples.py --module cross_mapping --configfile tests/config/config.crossMapping_big.yaml
# Genotyping
./Genotype_Samples.py --module genotyping --configfile tests/config/config.Genotyping_small.yaml
./Genotype_Samples.py --module genotyping --configfile tests/config/config.Genotyping_big.yaml
# K-mer analysis
./Genotype_Samples.py --module kmer_analysis --configfile tests/config/config.KmerAnalysis_small.yaml
# Cleanup
rm -fr .cache .keras .parallel .snakemake resources resultsIf you want to stop the scheduling of new jobs and wait for all running jobs to be finished, you can send a TERM signal, e.g., via
killall -TERM snakemakeResults files produced by this workflow will be in results/project_name/final/, where project_name is whatever you specified in the config file.
A HTML report that summarizes all plots and run stats for the given workflow. All of the R Markdown scripts and data to generate plots shown in the report are present in the final/ directory, so the user can adjust the final plots as they wish.
The ploidy and "group" (determined by vcf_clone_detect.py using the user specified threshold) of the input samples.
Relatedness results from the NgsRelate program.
Ploidy estimated by nQuire. Estimates are for both raw (normal) and denoised biallelic sites.
Admixture results produced by PCAngsd - number of ancestral populations chosen by PCAngsd.
PCA results produced by PCAngsd with individual allele frequencies estimated.
PCA results produced by PCAngsd without individual allele frequencies estimated.
Matrix of the percent shared variants between each pairwise combination of samples, calculated by vcf_clone_detect.py.
Matrix of the relatedness values between each pairwise combination of samples, calculated by vcftools.
Original png images (for use in publications) will be in results/project_name/kmer_analysis/genomescope2/
Original png images (for use in publications) will be in results/project_name/kmer_analysis/smudgeplot/
This workflow is based on the deepvariant workflow. It also takes inspiration from the design of Metagenome-Atlas.
Conda packages used by this workflow:
for F in workflow/envs/*.yaml; do awk '{ if($1=="dependencies:"){F=1}else{if(F==1){print}} }' $F; done | sort | uniq
- bcftools=1.16
- bwa-mem2=2.2.1
- fastp=0.23.2
- fastqc=0.11.9
- multiqc=1.14
- numpy=1.24.2
- pbmm2=1.10.0
- pigz=2.6
- python=3.11.0
- python=3.8.0
- qualimap=2.2.2a
- r-cowplot=1.1.1
- r-ggdendro=0.1.23
- r-ggplot2=3.4.1
- r-heatmaply=1.4.2
- r-RColorBrewer=1.1_3
- r-reshape2=1.4.4
- r-rmarkdown=2.14
- r-tibble=3.2.1
- samtools=1.16.1
- scikit-network=0.29.0
- sra-tools=3.0.5
- star=2.7.10b
- vcftools=0.1.16