GATK FILTERMUTECTCALLS¶
Run gatk FilterMutectCalls to filter variants in a Mutect2 VCF callset.
URL: https://gatk.broadinstitute.org/hc/en-us/articles/360042476952-FilterMutectCalls
Example¶
This wrapper can be used in the following way:
rule gatk_filtermutectcalls:
input:
vcf="calls/snvs.vcf",
ref="genome.fasta",
output:
vcf="calls/snvs.mutect.filtered.vcf",
log:
"logs/gatk/filter/snvs.log",
params:
extra="--max-alt-allele-count 3", # optional arguments, see GATK docs
java_opts="", # optional
resources:
mem_mb=1024,
wrapper:
"v1.12.2/bio/gatk/filtermutectcalls"
rule gatk_filtermutectcalls_complete:
input:
vcf="calls/snvs.vcf",
ref="genome.fasta",
bam="mapped/a.bam",
intervals="intervals.bed",
# contamination="", # from gatk CalculateContamination
# segmentation="", # from gatk CalculateContamination
# f1r2="", # from gatk LearnReadOrientationBias
output:
vcf="calls/snvs.mutect.filtered.b.vcf",
log:
"logs/gatk/filter/snvs.log",
params:
extra="--max-alt-allele-count 3", # optional arguments, see GATK docs
java_opts="", # optional
resources:
mem_mb=1024,
wrapper:
"v1.12.2/bio/gatk/filtermutectcalls"
Note that input, output and log file paths can be chosen freely.
When running with
snakemake --use-conda
the software dependencies will be automatically deployed into an isolated environment before execution.
Notes¶
- The java_opts param allows for additional arguments to be passed to the java compiler, e.g. “-XX:ParallelGCThreads=10” (not for -XmX or -Djava.io.tmpdir, since they are handled automatically).
- The extra param allows for additional program arguments.
- For more information see, https://software.broadinstitute.org/gatk/documentation/article?id=11050
Software dependencies¶
gatk4=4.2
snakemake-wrapper-utils=0.3
Input/Output¶
Input:
vcf
: Path to vcf file (pbgzipped, indexed)ref
: Path to reference genome (with .dict file alongside)aln
: Optional path to SAM/BAM/CRAM filescontamination
: Optional path tosegmentation
: Optional path to tumor segmentsf1r2
: Optional path to prior artefact (tar.gz2)intervels
: Optional file to BED intervals
Output:
vcf
: filtered vcf filestats
: Optional stats from Mutect2
Authors¶
- Patrik Smeds
- Filipe G. Vieira
- Thibault Dayris
Code¶
__author__ = "Patrik Smeds"
__copyright__ = "Copyright 2021, Patrik Smeds"
__email__ = "patrik.smeds@gmail.com"
__license__ = "MIT"
import tempfile
from snakemake.shell import shell
from snakemake_wrapper_utils.java import get_java_opts
extra = snakemake.params.get("extra", "")
java_opts = get_java_opts(snakemake)
log = snakemake.log_fmt_shell(stdout=True, stderr=True)
aln = snakemake.input.get("aln", "")
if aln:
aln = f"--input {aln}"
contamination = snakemake.input.get("contemination_table", "")
if contamination:
contamination = f"--contamination-table {contamination}"
segmentation = snakemake.input.get("segmentation", "")
if segmentation:
segmentation = f"--tumor-segmentation {segmentation}"
f1r2 = snakemake.input.get("f1r2", "")
if f1r2:
f1r2 = f"--orientation-bias-artifact-priors {f1r2}"
intervals = snakemake.input.get("bed", "")
if intervals:
intervals = f"--intervals {intervals}"
with tempfile.TemporaryDirectory() as tmpdir:
shell(
"gatk --java-options '{java_opts}' FilterMutectCalls"
" --variant {snakemake.input.vcf}"
" --reference {snakemake.input.ref}"
" {aln}" # BAM/SAM/CRAM file containing reads
" {contamination}" # Tables containing contamination information
" {segmentation}" # Tumor segments' minor allele fractions
" {f1r2}" # .tar.gz files containing tables of prior artifact
" {intervals}" # Genomic intervals over which to operate
" {extra}"
" --tmp-dir {tmpdir}"
" --output {snakemake.output.vcf}"
" {log}"
)