GATK MUTECT2¶
Call somatic SNVs and indels via local assembly of haplotypes
Example¶
This wrapper can be used in the following way:
rule mutect2:
input:
fasta="genome/genome.fasta",
map="mapped/{sample}.bam",
output:
vcf="variant/{sample}.vcf",
message:
"Testing Mutect2 with {wildcards.sample}"
threads: 1
resources:
mem_mb=1024,
log:
"logs/mutect_{sample}.log",
wrapper:
"v1.19.1/bio/gatk/mutect"
rule mutect2_bam:
input:
fasta="genome/genome.fasta",
map="mapped/{sample}.bam",
output:
vcf="variant_bam/{sample}.vcf",
bam="variant_bam/{sample}.bam",
message:
"Testing Mutect2 with {wildcards.sample}"
threads: 1
resources:
mem_mb=1024,
log:
"logs/mutect_{sample}.log",
wrapper:
"v1.19.1/bio/gatk/mutect"
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://gatk.broadinstitute.org/hc/en-us/articles/360037593851-Mutect2
Software dependencies¶
gatk4=4.2
snakemake-wrapper-utils=0.5
Authors¶
- Thibault Dayris
- Filipe G. Vieira
Code¶
"""Snakemake wrapper for GATK4 Mutect2"""
__author__ = "Thibault Dayris"
__copyright__ = "Copyright 2019, Dayris Thibault"
__email__ = "thibault.dayris@gustaveroussy.fr"
__license__ = "MIT"
import tempfile
from snakemake.shell import shell
from snakemake.utils import makedirs
from snakemake_wrapper_utils.java import get_java_opts
log = snakemake.log_fmt_shell(stdout=True, stderr=True)
bam_output = "--bam-output"
if snakemake.output.get("bam", None) is not None:
bam_output = bam_output + " " + snakemake.output.bam
else:
bam_output = ""
extra = snakemake.params.get("extra", "")
java_opts = get_java_opts(snakemake)
with tempfile.TemporaryDirectory() as tmpdir:
shell(
"gatk --java-options '{java_opts}' Mutect2" # Tool and its subprocess
" --native-pair-hmm-threads {snakemake.threads}"
" --input {snakemake.input.map}" # Path to input mapping file
" --reference {snakemake.input.fasta}" # Path to reference fasta file
" {extra}" # Extra parameters
" --tmp-dir {tmpdir}"
" --output {snakemake.output.vcf}" # Path to output vcf file
" {bam_output}" # Path to output bam file, optional
" {log}" # Logging behaviour
)