Softwares used in the snv_indels module

bcbio_variation_recall_ensemble

Ensemble variants in the .vcf file format from different callers in one .vcf file.

🐍 Rule

rule bcbio_variation_recall_ensemble:
    input:
        vcfs=expand(
            "snv_indels/{caller}/{{sample}}_{{type}}.normalized.merged_af.sorted.vcf.gz",
            caller=config.get("bcbio_variation_recall_ensemble", {}).get("callers", []),
        ),
        tabix=expand(
            "snv_indels/{caller}/{{sample}}_{{type}}.normalized.merged_af.sorted.vcf.gz.tbi",
            caller=config.get("bcbio_variation_recall_ensemble", {}).get("callers", []),
        ),
        ref=config["reference"]["fasta"],
    output:
        vcf=temp("snv_indels/bcbio_variation_recall_ensemble/{sample}_{type}.ensembled.vcf.gz"),
        bcbio_work=temp(directory("snv_indels/bcbio_variation_recall_ensemble/{sample}_{type}.ensembled-work/")),
    params:
        support=config.get("bcbio_variation_recall_ensemble", {}).get("support", "1"),
        sort_order=get_bvre_params_sort_order,
    log:
        "snv_indels/bcbio_variation_recall_ensemble/{sample}_{type}.ensembled.vcf.gz.log",
    benchmark:
        repeat(
            "snv_indels/bcbio_variation_recall_ensemble/{sample}_{type}.ensembled.vcf.gz.benchmark.tsv",
            config.get("bcbio_variation_recall_ensemble", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("bcbio_variation_recall_ensemble", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("bcbio_variation_recall_ensemble", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("bcbio_variation_recall_ensemble", {}).get(
            "mem_per_cpu", config["default_resources"]["mem_per_cpu"]
        ),
        partition=config.get("bcbio_variation_recall_ensemble", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("bcbio_variation_recall_ensemble", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("bcbio_variation_recall_ensemble", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("bcbio_variation_recall_ensemble", {}).get("container", config["default_container"])
    message:
        "{rule}: combine vcfs from different callers into {output.vcf} {params.sort_order}"
    shell:
        "(bcbio-variation-recall ensemble -n {params.support} --names {params.sort_order} {output.vcf} {input.ref} {input.vcfs}) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input vcfs expand( "snv_indels/{caller}/{{sample}}_{{type}}.normalized.merged_af.sorted.vcf.gz", caller=config.get("bcbio_variation_recall_ensemble", {}).get("callers", []), ) list of .vcf.gz files from different callers of the same sample
tabix expand( "snv_indels/{caller}/{{sample}}_{{type}}.normalized.merged_af.sorted.vcf.gz.tbi", caller=config.get("bcbio_variation_recall_ensemble", {}).get("callers", []), ) list of .vcf.gz.tbi index files
ref config["reference"]["fasta"] fasta reference genome file
output vcf "snv_indels/bcbio_variation_recall_ensemble/{sample}_{type}.ensembled.vcf.gz" ensembled .vcf file
bcbio_work "snv_indels/bcbio_variation_recall_ensemble/{sample}_{type}.ensembled-work/" temporary directory used by the program

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
callers array list of callers that are included in the ensemble vcf in sort order
container string name or path to docker/singularity container
support integer number of callers to support variant to be included in ensemble vcf

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

bcftools_concat

Concatenate .vcf files from different chromosomes using bcftools concat.

🐍 Rule

rule bcftools_concat:
    input:
        calls=expand(
            "{{file}}_{chr}.{{vcf}}.gz",
            chr=extract_chr(
                "%s.fai" % (config["reference"]["fasta"]), filter_out=config.get("reference", {}).get("skip_chrs", [])
            ),
        ),
        index=expand(
            "{{file}}_{chr}.{{vcf}}.gz.tbi",
            chr=extract_chr(
                "%s.fai" % (config["reference"]["fasta"]), filter_out=config.get("reference", {}).get("skip_chrs", [])
            ),
        ),
    output:
        vcf=temp("{file}.merged.{vcf}"),
    params:
        extra=config.get("bcftools_concat", {}).get("extra", ""),
    log:
        "{file}.merged.{vcf}.log",
    benchmark:
        repeat(
            "{file}.merged.{vcf}.benchmark.tsv",
            config.get("bcftools_concat", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("bcftools_concat", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("bcftools_concat", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("bcftools_concat", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("bcftools_concat", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("bcftools_concat", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("bcftools_concat", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("bcftools_concat", {}).get("container", config["default_container"])
    message:
        "{rule}: concatenate {input.calls}"
    wrapper:
        "v1.25.0/bio/bcftools/concat"

↔ input / output files

Rule parameters Key Value Description
input calls expand( "{{file}}_{chr}.{{vcf}}.gz", chr=extract_chr( "%s.fai" % (config["reference"]["fasta"]), filter_out=config.get("reference", {}).get("skip_chrs", []) ), ) list of .vcf files that should be concatenated
in this case one for each chromosome from the same sample
index expand( "{{file}}_{chr}.{{vcf}}.gz.tbi", chr=extract_chr( "%s.fai" % (config["reference"]["fasta"]), filter_out=config.get("reference", {}).get("skip_chrs", []) ), ) list of tabix index files
output vcf "{file}.merged.{vcf}" concatenated .vcf file.

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

bcftools_norm

Normalise a .vcf file with bcftools norm

🐍 Rule

rule bcftools_norm:
    input:
        vcf="snv_indels/{caller}/{sample}_{type}.fix_af.vcf.gz",
        ref=config.get("reference", {}).get("fasta", ""),
    output:
        vcf="snv_indels/{caller}/{sample}_{type}.bcftools_norm.vcf.gz",
    params:
        extra=config.get("bcftools_norm", {}).get("extra", ""),
    log:
        "snv_indels/{caller}/{sample}_{type}.bcftools_norm.vcf.gz.log",
    benchmark:
        repeat(
            "snv_indels/{caller}/{sample}_{type}.bcftools_norm.vcf.gz.benchmark.tsv",
            config.get("bcftools_norm", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("bcftools_norm", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("bcftools_norm", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("bcftools_norm", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("bcftools_norm", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("bcftools_norm", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("bcftools_norm", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("bcftools_norm", {}).get("container", config["default_container"])
    message:
        "{rule}: normalize {input.vcf}"
    wrapper:
        "v1.25.0/bio/bcftools/norm"

↔ input / output files

Rule parameters Key Value Description
input vcf "snv_indels/{caller}/{sample}_{type}.fix_af.vcf.gz" vcf to be normalised
ref config.get("reference", {}).get("fasta", "") fasta reference genome file
output vcf "snv_indels/{caller}/{sample}_{type}.bcftools_norm.vcf.gz" normalised vcf

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

bcftools_sort

Sort a .vcf file using bcfools sort.

🐍 Rule

rule bcftools_sort:
    input:
        vcf="{file}.vcf.gz",
    output:
        vcf=temp("{file}.sorted.vcf.gz"),
    log:
        "{file}.sorted.vcf.gz.log",
    benchmark:
        repeat(
            "{file}.sorted.vcf.gz.benchmark.tsv",
            config.get("bcftools_sort", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("bcftools_sort", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("bcftools_sort", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("bcftools_sort", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("bcftools_sort", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("bcftools_sort", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("bcftools_sort", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("bcftools_sort", {}).get("container", config["default_container"])
    message:
        "{rule}: sort {input.vcf}"
    wrapper:
        "v1.25.0/bio/bcftools/sort"

↔ input / output files

Rule parameters Key Value Description
input vcf "{file}.vcf.gz" the .vcf file that should be sorted.
output vcf "{file}.sorted.vcf.gz" sorted .vcf file.

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

bcftools_view

Convert bcftools .bcf binary file format to a .vcf file using bcftools.

🐍 Rule

rule bcftools_view:
    input:
        bcf="{file}.bcf",
    output:
        vcf=temp("{file}.vcf.gz"),
    log:
        "{file}.vcf.gz.log",
    params:
        extra=config.get("bcftools_view", {}).get("extra", ""),
    benchmark:
        repeat(
            "{file}.vcf.gz.benchmark.tsv",
            config.get("bcftools_view", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("bcftools_view", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("bcftools_view", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("bcftools_view", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("bcftools_view", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("bcftools_view", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("bcftools_view", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("bcftools_view", {}).get("container", config["default_container"])
    message:
        "{rule}: convert {input.bcf} to {output.vcf}"
    wrapper:
        "v1.25.0/bio/bcftools/view"

↔ input / output files

Rule parameters Key Value Description
input bcf "{file}.bcf" the .bcf file (bcftools binary) that should be converted to .vcf format
output vcf "{file}.vcf.gz" the converted .vcf file

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

bed_split

Split a bed file into chromosomes using an awk command going by the first column (chromosome).

🐍 Rule

rule bed_split:
    input:
        bed=config.get("reference", {}).get("design_bed", ""),
    output:
        bed=temp("snv_indels/bed_split/design_bedfile_{chr}.bed"),
    log:
        "snv_indels/bed_split/bed_split_{chr}.bed.log",
    benchmark:
        repeat("snv_indels/bed_split/bed_split_{chr}.bed.benchmark.tsv", config.get("bed_split", {}).get("benchmark_repeats", 1))
    threads: config.get("bed_split", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("bed_split", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("bed_split", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("bed_split", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("bed_split", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("bed_split", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("bed_split", {}).get("container", config["default_container"])
    message:
        "{rule}: generate bed file containing only {wildcards.chr} from {input.bed}"
    shell:
        "(awk '{{if(/^{wildcards.chr}\t/) print($0)}}' {input.bed}  > {output}) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input bed config.get("reference", {}).get("design_bed", "") bed file that should be split into chromosome bed files
output bed "snv_indels/bed_split/design_bedfile_{chr}.bed" bed file of a specific chromosome

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

bgzip

Compress a .vcf file using bgzip.

🐍 Rule

rule bgzip:
    input:
        vcf="{file}.vcf",
    output:
        gz=temp("{file}.vcf.gz"),
    log:
        "{file}.vcf.gz.log",
    benchmark:
        repeat("{file}.vcf.gz.benchmark.tsv", config.get("bgzip", {}).get("benchmark_repeats", 1))
    threads: config.get("bgzip", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("bgzip", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("bgzip", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("bgzip", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("bgzip", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("bgzip", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("bgzip", {}).get("container", config["default_container"])
    message:
        "{rule}: bgzip {input.vcf}"
    wrapper:
        "v1.3.1/bio/bgzip"

↔ input / output files

Rule parameters Key Value Description
input vcf "{file}.vcf" the .vcf file that should be compressed
output gz "{file}.vcf.gz" the compressed .vcf.gz file

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

clairs_to_call

ClairS-TO (Somatic Tumor-Only) is a deep-learning tool in the Clair series to support long-read tumor-only somatic small variant calling.

🐍 Rule

rule clairs_to_call:
    input:
        bam=lambda wildcards: get_input_aligned_bam(wildcards, config)[0],
        bai=lambda wildcards: get_input_aligned_bam(wildcards, config)[1],
        ref=config.get("reference", {}).get("fasta", ""),
        bed=config.get("reference", {}).get("design_bed", ""),
    output:
        snv=temp("snv_indels/clairs_to/{sample}_{type}_snv.vcf.gz"),
        indel=temp("snv_indels/clairs_to/{sample}_{type}_indel.vcf.gz"),
    params:
        extra=config.get("clairs_to_call", {}).get("extra", ""),
        platform=config.get("clairs_to_call", {}).get("platform", ""),
        snv_min_af=config.get("clairs_to_call", {}).get("snv_min_af", 0.05),
        indel_min_af=config.get("clairs_to_call", {}).get("indel_min_af", 0.1),
        outdir=directory(lambda w, output: os.path.dirname(output[0])),
    log:
        "snv_indels/clairs_to/{sample}_{type}.output.log",
    benchmark:
        repeat(
            "snv_indels/clairs_to/{sample}_{type}.output.benchmark.tsv",
            config.get("clairs_to_call", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("clairs_to_call", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("clairs_to_call", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("clairs_to_call", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("clairs_to_call", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("clairs_to_call", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("clairs_to_call", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("clairs_to_call", {}).get("container", config["default_container"])
    message:
        "{rule}: Long-read somatic small variant calling in only tumor samples with ClairS-TO."
    shell:
        "run_clairs_to "
        "--tumor_bam_fn {input.bam} "
        "--ref_fn {input.ref} "
        "--threads {resources.threads} "
        "--platform {params.platform} "
        "--output_dir {params.outdir} "
        "-s {wildcards.sample} "
        "--bed_fn {input.bed} "
        "--snv_min_af {params.snv_min_af} "
        "--indel_min_af {params.indel_min_af} "
        "--disable_verdict "
        "--snv_output_prefix {wildcards.sample}_{wildcards.type}_snv "
        "--indel_output_prefix {wildcards.sample}_{wildcards.type}_indel "
        "{params.extra} "
        "> {log}"

↔ input / output files

Rule parameters Key Value Description
input bam lambda wildcards: get_input_aligned_bam(wildcards, config)[0] marked duplication, merged and sorted .bam file
bai lambda wildcards: get_input_aligned_bam(wildcards, config)[1] index file for .bam file
bed config.get("reference", {}).get("design_bed", "") the region where variants should be called
ref config.get("reference", {}).get("fasta", "") fasta reference genome file
output snv "snv_indels/clairs_to/{sample}_{type}_snv.vcf.gz" vcf file with snv calls only
indel "snv_indels/clairs_to/{sample}_{type}_indel.vcf.gz" vcf file with indel calls only

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded
platform string choose which platform, which chemistry, and which model to use (same as for the basecalling)

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

clairs_to_concat

ClairS-TO creates separate VCF output for indel and SNV calls while those types of variants are treated together in the hydra-genetics module. They are therefore concatenated together and sorted with bcftools.

🐍 Rule

rule clairs_to_concat:
    input:
        snv="snv_indels/clairs_to/{sample}_{type}_snv.vcf.gz",
        indel="snv_indels/clairs_to/{sample}_{type}_indel.vcf.gz",
    output:
        vcf=temp("snv_indels/clairs_to/{sample}_{type}.snv-indels.vcf.gz"),
    params:
        extra=config.get("clairs_to_concat", {}).get("extra", ""),
    log:
        "snv_indels/clairs_to/{sample}_{type}.concat.log",
    benchmark:
        repeat(
            "snv_indels/clairs_to/{sample}_{type}.concat.benchmark.tsv",
            config.get("clairs_to_concat", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("clairs_to_concat", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("clairs_to_concat", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("clairs_to_concat", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("clairs_to_concat", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("clairs_to_concat", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("clairs_to_concat", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("clairs_to_concat", {}).get("container", config["default_container"])
    message:
        "{rule}: Concatenate the output of ClairS-TO into the single VCF {output.vcf}."
    shell:
        """
        bcftools concat {params.extra} -a {input.snv} {input.indel} | bcftools sort -Oz -o {output.vcf} - > {log}
        """

↔ input / output files

Rule parameters Key Value Description
input snv "snv_indels/clairs_to/{sample}_{type}_snv.vcf.gz" vcf file with snv calls only
indel "snv_indels/clairs_to/{sample}_{type}_indel.vcf.gz" vcf file with indel calls only
output vcf "snv_indels/clairs_to/{sample}_{type}.snv-indels.vcf.gz" vcf file with position-sorted snv and indel calls

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

deepmosaic_draw

DeepMosaic is a deep-learning-based mosaic single nucleotide classification tool without the need of matched control information. Firstly, feature extraction and visualization of the candidate mosaic variants (Visualization Module)

🐍 Rule

rule deepmosaic_draw:
    input:
        annovar=config.get("reference", {}).get("annovar", ""),
        bam="alignment/samtools_merge_bam/{sample}_{type}.bam",
        bai="alignment/samtools_merge_bam/{sample}_{type}.bam.bai",
        txt="snv_indels/deepmosaic/{sample}_{type}.input.txt",
        vcf="snv_indels/deepsomatic_t_only/{sample}_{type}.vcf.gz",
    output:
        outdir=directory("snv_indels/deepmosaic/{sample}_{type}/"),
        txt="snv_indels/deepmosaic/{sample}_{type}/features.txt",
    params:
        extra=config.get("deepmosaic_draw", {}).get("extra", ""),
    log:
        "snv_indels/deepmosaic/{sample}_{type}.draw.log",
    benchmark:
        repeat(
            "snv_indels/deepmosaic/{sample}_{type}.draw.benchmark.tsv",
            config.get("deepmosaic_draw", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("deepmosaic_draw", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("deepmosaic_draw", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("deepmosaic_draw", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("deepmosaic_draw", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("deepmosaic_draw", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("deepmosaic_draw", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("deepmosaic_draw", {}).get("container", config["default_container"])
    message:
        """
        {rule}: DeepMosaic draw takes input from {input.vcf} and {input.bam} to find mosaic variants
        """
    shell:
        """/DeepMosaic/deepmosaic/deepmosaic-draw \
        -i {input.txt} \
        -o {output.outdir} \
        -a {input.annovar} \
        -b hg38 \
        -db gnomad41_genome \
        {params.extra} &> {log}"""

↔ input / output files

Rule parameters Key Value Description
input annovar config.get("reference", {}).get("annovar", "") the path to where annovar is installed
bam "alignment/samtools_merge_bam/{sample}_{type}.bam" marked duplication, merged and sorted .bam file
txt "snv_indels/deepmosaic/{sample}_{type}.input.txt" info file with sample_id, '.bam' and '.vcf' file locations, depth and sex
vcf "snv_indels/deepsomatic_t_only/{sample}_{type}.vcf.gz" the .vcf file, preferrably from deepSomatic or Mutect2 (a tool that can find somatic/mosaic variation)
output outdir "snv_indels/deepmosaic/{sample}_{type}/" vcf file with snv and indels calls (add "--output_gvcf={path to output gVCF}" to rule for .g.vcf)
txt "snv_indels/deepmosaic/{sample}_{type}/features.txt" a '.txt' file with the features extracted for the candidates to use in deepmosaic_predict

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
gres string generic resource scheduling
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

[deepmosaic_input]

Run python script to create the information txt-file needed in deepmosaic_draw. It contains sample_id, path to .bam and .vcf file, average depth and sex (predicted with Peddy).

🐍 Rule

rule deepmosaic_input:
    input:
        bam="alignment/samtools_merge_bam/{sample}_{type}.bam",
        sex="qc/peddy/peddy.sex_check.csv",
        vcf="snv_indels/deepsomatic_t_only/{sample}_{type}.vcf.gz",
    output:
        txt=temp("snv_indels/deepmosaic/{sample}_{type}.input.txt"),
    params:
        extra=config.get("deepmosaic_input", {}).get("extra", ""),
        name=lambda wildcards: f"{wildcards.sample}_{wildcards.type}",
    log:
        temp("snv_indels/deepmosaic/{sample}_{type}.input.log"),
    benchmark:
        repeat(
            "snv_indels/deepmosaic/{sample}_{type}.input.benchmark.tsv",
            config.get("deepmosaic_input", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("deepmosaic_input", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("deepmosaic_input", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("deepmosaic_input", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("deepmosaic_input", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("deepmosaic_input", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("deepmosaic_input", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("deepmosaic_input", {}).get("container", config["default_container"])
    message:
        """
        {rule}: Creates an input file {output.txt} for DeepMosaic with info: {input.bam}, {input.vcf}, depth and sex
        """
    script:
        "../scripts/deepmosaic_input.py"

↔ input / output files

Rule parameters Key Value Description
input bam "alignment/samtools_merge_bam/{sample}_{type}.bam" marked duplication, merged and sorted .bam file
sex "qc/peddy/peddy.sex_check.csv" file containing predicted sex based on bioinformatics (e.g Peddy)
vcf "snv_indels/deepsomatic_t_only/{sample}_{type}.vcf.gz" the .vcf file, preferrably from deepSomatic or Mutect2 (a tool that can find somatic/mosaic variation)
output txt "snv_indels/deepmosaic/{sample}_{type}.input.txt" info file with sample_id, '.bam' and '.vcf' file locations, depth and sex to be used in deepmosaic_draw

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
gres string generic resource scheduling
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

deepsomatic_predict

DeepMosaic is a deep-learning-based mosaic single nucleotide classification tool without the need of matched control information. Secondly, prediction for mosaicism (Classification Module)

🐍 Rule

rule deepmosaic_predict:
    input:
        txt="snv_indels/deepmosaic/{sample}_{type}/features.txt",
        dir="snv_indels/deepmosaic/{sample}_{type}/",
    output:
        txt="snv_indels/deepmosaic/{sample}_{type}/final_predictions.txt",
    params:
        extra=config.get("deepmosaic_predict", {}).get("extra", ""),
        model=config.get("deepmosaic_predict", {}).get("model", ""),
    log:
        "snv_indels/deepmosaic/{sample}_{type}.predict.log",
    benchmark:
        repeat(
            "snv_indels/deepmosaic/{sample}_{type}.predict.benchmark.tsv",
            config.get("deepmosaic_predict", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("deepmosaic_predict", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("deepmosaic_predict", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("deepmosaic_predict", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("deepmosaic_predict", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("deepmosaic_predict", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("deepmosaic_predict", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("deepmosaic_predict", {}).get("container", config["default_container"])
    message:
        """
        {rule}:  DeepMosaic predict takes output from draw {input.txt} to predict mosaic variants {output.txt}.
        """
    shell:
        """/DeepMosaic/deepmosaic/deepmosaic-predict \
        -i {input.txt} \
        -o {output.txt} \
        -gb hg38 \
        -b 10 \
        {params.model}\
        {params.extra} &> {log}"""

↔ input / output files

Rule parameters Key Value Description
input txt "snv_indels/deepmosaic/{sample}_{type}/features.txt" a '.txt' file with the features extracted for the candidates from deepmosaic_draw
output txt "snv_indels/deepmosaic/{sample}_{type}/final_predictions.txt" a '.txt' file with the predictions based on the features

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
gres string generic resource scheduling
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

deepsomatic_t_only

Using only tumor to call somatic SNV and indel variant from both short and long-read with DeepSomatic. The tool is the somatic version of DeepVariant.

🐍 Rule

rule deepsomatic_t_only:
    input:
        bam=lambda wildcards: get_input_aligned_bam(wildcards, config)[0],
        bai=lambda wildcards: get_input_aligned_bam(wildcards, config)[1],
        ref=config.get("reference", {}).get("fasta", ""),
        bed=config.get("reference", {}).get("design_bed", ""),
    output:
        tmpdir=temp(directory("snv_indels/deepsomatic_t_only/{sample}_{type}.tmp")),
        vcf=temp("snv_indels/deepsomatic_t_only/{sample}_{type}.vcf.gz"),
    params:
        extra=config.get("deepsomatic_t_only", {}).get("extra", ""),
        model=config.get("deepsomatic_t_only", {}).get("model", ""),
        name=lambda wildcards: f"{wildcards.sample}_{wildcards.type}",
        pon=config.get("deepsomatic_t_only", {}).get("pon", ""),
    log:
        "snv_indels/deepsomatic_t_only/{sample}_{type}.deepsomatic.log",
    benchmark:
        repeat(
            "snv_indels/deepsomatic_t_only/{sample}_{type}.output.benchmark.tsv",
            config.get("deepsomatic_t_only", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("deepsomatic_t_only", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("deepsomatic_t_only", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("deepsomatic_t_only", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("deepsomatic_t_only", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("deepsomatic_t_only", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("deepsomatic_t_only", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("deepsomatic_t_only", {}).get("container", config["default_container"])
    message:
        "{rule}: Calling small variants from short read data in tumour only sample with DeepSomatic from {input.bam}"
    shell:
        """
        run_deepsomatic \
        --model_type={params.model} \
        --ref={input.ref} \
        --reads_tumor={input.bam} \
        --output_vcf={output.vcf} \
        --sample_name_tumor={params.name} \
        --num_shards={resources.threads} \
        --logging_dir={log} \
        --vcf_stats_report=true \
        --intermediate_results_dir {output.tmpdir} \
        --regions={input.bed} \
        {params.pon} \
        {params.extra} 
        """

↔ input / output files

Rule parameters Key Value Description
input bam lambda wildcards: get_input_aligned_bam(wildcards, config)[0] marked duplication, merged and sorted .bam file
bai lambda wildcards: get_input_aligned_bam(wildcards, config)[1] index file for .bam file
bed config.get("reference", {}).get("design_bed", "") the region where variants should be called
ref config.get("reference", {}).get("fasta", "") fasta reference genome file
output vcf "snv_indels/deepsomatic_t_only/{sample}_{type}.vcf.gz" vcf file with snv and indels calls (add "--output_gvcf={path to output gVCF}" to rule for .g.vcf)

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded (e.g. --make_examples_extra_args="vsc_min_fraction_snps=0.04")
model string choose which model to use based on the data (e.g. WGS_TUMOR_ONLY)
pon string choose what option for panel of normal filtering of variants (FILTER flag PON) you want, "--use_default_pon_filtering=true" or --pon_filtering="pon.vcf" --process_somatic=true or ""

Resources settings (resources.yaml)

Key Type Description
gres string generic resource scheduling
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

deepsomatic_tn

Tumor/normal analysis to call somatic SNV and indel variant from both short and long-read with DeepSomatic. The tool is the somatic version of DeepVariant.

🐍 Rule

rule deepsomatic_tn:
    input:
        normal="alignment/samtools_merge_bam/{sample}_N.bam",
        tumor="alignment/samtools_merge_bam/{sample}_T.bam",
        bai_n="alignment/samtools_merge_bam/{sample}_N.bam.bai",
        bai_t="alignment/samtools_merge_bam/{sample}_T.bam.bai",
        ref=config.get("reference", {}).get("fasta", ""),
        bed=config.get("reference", {}).get("design_bed", ""),
    output:
        tmpdir=temp(directory("snv_indels/deepsomatic_tn/{sample}.tmp")),
        vcf=temp("snv_indels/deepsomatic_tn/{sample}.vcf.gz"),
    params:
        extra=config.get("deepsomatic_tn", {}).get("extra", ""),
        model=config.get("deepsomatic_tn", {}).get("model", ""),
        name_n=lambda wildcards: f"{wildcards.sample}_N",
        name_t=lambda wildcards: f"{wildcards.sample}_T",
    log:
        "snv_indels/deepsomatic_tn/{sample}.deepsomatic.log",
    benchmark:
        repeat(
            "snv_indels/deepsomatic_tn/{sample}.output.benchmark.tsv",
            config.get("deepsomatic_tn", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("deepsomatic_tn", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("deepsomatic_tn", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("deepsomatic_tn", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("deepsomatic_tn", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("deepsomatic_tn", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("deepsomatic_tn", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("deepsomatic_tn", {}).get("container", config["default_container"])
    message:
        "{rule}: Calling small variants from short read data in tumour/normal samples with DeepSomatic from {input.tumor}"
    shell:
        """
        run_deepsomatic \
        --model_type={params.model} \
        --ref={input.ref} \
        --reads_normal={input.normal} \
        --reads_tumor={input.tumor} \
        --output_vcf={output.vcf} \
        --sample_name_normal={params.name_n} \
        --sample_name_tumor={params.name_t} \
        --num_shards={resources.threads} \
        --logging_dir={log} \
        --vcf_stats_report=true \
        --intermediate_results_dir {output.tmpdir} \
        --regions={input.bed} \
        {params.extra}
        """

↔ input / output files

Rule parameters Key Value Description
input normal "alignment/samtools_merge_bam/{sample}_N.bam" marked duplication, merged and sorted tumor .bam file
tumor "alignment/samtools_merge_bam/{sample}_T.bam" marked duplication, merged and sorted normal .bam file
bai_n "alignment/samtools_merge_bam/{sample}_N.bam.bai" index file for tumor .bam file
bai_t "alignment/samtools_merge_bam/{sample}_T.bam.bai" index file for normal .bam file
bed config.get("reference", {}).get("design_bed", "") the region where variants should be called
ref config.get("reference", {}).get("fasta", "") fasta reference genome file
output vcf "snv_indels/deepsomatic_tn/{sample}.vcf.gz" vcf file with snv and indels calls (add "--output_gvcf={path to output gVCF}" to rule for .g.vcf)

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded (e.g. --make_examples_extra_args="vsc_min_fraction_snps=0.04")
model string choose which model to use based on the data (e.g. WGS)

Resources settings (resources.yaml)

Key Type Description
gres string generic resource scheduling
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

deeptrio_call_variants

Step 2 of 3 in the calling of SNVs and INDELs using deeptrio.

🐍 Rule

rule deeptrio_call_variants:
    input:
        examples=expand(
            "snv_indels/deeptrio/{{sample}}_{{type}}/make_examples_{{trio_member}}.tfrecord-{shard}-of-{nshards:05}.gz",
            shard=[f"{x:05}" for x in range(config.get("deeptrio_make_examples", {}).get("n_shards", 2))],
            nshards=config.get("deeptrio_make_examples", {}).get("n_shards", 2),
        ),
    output:
        outfile=temp("snv_indels/deeptrio/{sample}_{type}/call_variants_output_{trio_member}.tfrecord.gz"),
    params:
        cuda="CUDA_VISIBLE_DEVICES={}".format(os.getenv("CUDA_VISIBLE_DEVICES"))
        if os.getenv("CUDA_VISIBLE_DEVICES") is not None
        else "",
        examples=lambda wildcards, output: get_make_examples_tfrecord(
            wildcards, output, config.get("deeptrio_make_examples", {}).get("n_shards", 2), program="deeptrio"
        ),
        extra=config.get("deeptrio_call_variants", {}).get("extra", ""),
        model=lambda wildcards: get_deeptrio_model(wildcards),
    log:
        "snv_indels/deeptrio/{sample}_{type}/call_variants_{trio_member}.output.log",
    benchmark:
        repeat(
            "snv_indels/deeptrio/{sample}_{type}/call_variants_{trio_member}.output.benchmark.tsv",
            config.get("deeptrio_call_variants", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("deeptrio_call_variants", {}).get("threads", config["default_resources"]["threads"])
    resources:
        gres=config.get("deeptrio_call_variants", {}).get("gres", ""),
        mem_mb=config.get("deeptrio_call_variants", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("deeptrio_call_variants", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("deeptrio_call_variants", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("deeptrio_call_variants", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("deeptrio_call_variants", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("deeptrio_call_variants", {}).get("container", config["default_container"])
    message:
        "{rule}: Run deeptrio call_variants on {params.examples}"
    shell:
        "({params.cuda} call_variants "
        "--checkpoint {params.model} "
        "--outfile {output.outfile} "
        "--examples {params.examples} "
        "{params.extra}) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input examples expand( "snv_indels/deeptrio/{{sample}}_{{type}}/make_examples_{{trio_member}}.tfrecord-{shard}-of-{nshards:05}.gz", shard=[f"{x:05}" for x in range(config.get("deeptrio_make_examples", {}).get("n_shards", 2))], nshards=config.get("deeptrio_make_examples", {}).get("n_shards", 2), ) files generated by deeptrio_make_examples
output outfile "snv_indels/deeptrio/{sample}_{type}/call_variants_output_{trio_member}.tfrecord.gz" file used by deeptrio to generate the final vcf file (deeptrio_postprocess_variants)

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded
model object Path to the deepvariant model file

Resources settings (resources.yaml)

Key Type Description
gres string generic resource scheduling
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

deeptrio_make_examples

Step 1 of 3 in the calling of SNVs and INDELs using deeptrio.

🐍 Rule

rule deeptrio_make_examples:
    input:
        child_bam="alignment/samtools_merge_bam/{sample}_{type}.bam",
        child_bai="alignment/samtools_merge_bam/{sample}_{type}.bam.bai",
        parent_bams=lambda wildcards: get_parent_bams(wildcards),
        ref=config.get("reference", {}).get("fasta", ""),
    output:
        examples=temp(
            expand(
                "snv_indels/deeptrio/{{sample}}_{{type}}/make_examples_{trio_member}.tfrecord-{{shard}}-of-{nshards:05}.gz",
                nshards=config.get("deeptrio_make_examples", {}).get("n_shards", 2),
                trio_member=["child", "parent1", "parent2"],
            )
        ),
        gvcf_tfrecords=temp(
            expand(
                "snv_indels/deeptrio/{{sample}}_{{type}}/gvcf_{trio_member}.tfrecord-{{shard}}-of-{nshards:05}.gz",
                nshards=config.get("deeptrio_make_examples", {}).get("n_shards", 2),
                trio_member=["child", "parent1", "parent2"],
            )
        ),
    params:
        examples=lambda wildcards, output: get_make_examples_tfrecord(
            wildcards, output, config.get("deeptrio_make_examples", {}).get("n_shards", 2)
        ),
        extra=config.get("deeptrio_make_examples", {}).get("extra", ""),
        shard=lambda wildcards: int(wildcards.shard),
        nshards=config.get("deeptrio_make_examples", {}).get("n_shards", 2),
    log:
        "snv_indels/deeptrio/{sample}_{type}/make_examples_{shard}.output.log",
    benchmark:
        repeat(
            "snv_indels/deeptrio/{sample}_{type}/make_examples_{shard}.output.benchmark.tsv",
            config.get("deeptrio_make_examples", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("deeptrio_make_examples", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("deeptrio_make_examples", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("deeptrio_make_examples", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("deeptrio_make_examples", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("deeptrio_make_examples", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("deeptrio_make_examples", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("deeptrio_make_examples", {}).get("container", config["default_container"])
    message:
        "{rule}: Run deeptrio make_examples on {input.child_bam} and  {input.parent_bams} "
    shell:
        "(make_examples "
        "--mode 'calling' "
        "--ref {input.ref} "
        "--reads {input.child_bam} "
        "--reads_parent1 {input.parent_bams[0]}  "
        "--reads_parent2 {input.parent_bams[1]} "
        "--examples {params.examples} "
        "--gvcf snv_indels/deeptrio/{wildcards.sample}_{wildcards.type}/gvcf.tfrecord@{params.nshards}.gz "
        "{params.extra} --task {params.shard}) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input child_bam "alignment/samtools_merge_bam/{sample}_{type}.bam" the .bam file of the child in a trio
child_bai "alignment/samtools_merge_bam/{sample}_{type}.bam.bai" bam index file of the child in a trio
parent_bams lambda wildcards: get_parent_bams(wildcards) list of the parents bam files
ref config.get("reference", {}).get("fasta", "") fasta reference genome file
output examples expand( "snv_indels/deeptrio/{{sample}}_{{type}}/make_examples_{trio_member}.tfrecord-{{shard}}-of-{nshards:05}.gz", nshards=config.get("deeptrio_make_examples", {}).get("n_shards", 2), trio_member=["child", "parent1", "parent2"], ) files used by deeptrio to call variants (deeptrio_call_variants)
gvcf_tfrecords expand( "snv_indels/deeptrio/{{sample}}_{{type}}/gvcf_{trio_member}.tfrecord-{{shard}}-of-{nshards:05}.gz", nshards=config.get("deeptrio_make_examples", {}).get("n_shards", 2), trio_member=["child", "parent1", "parent2"], ) files used by deeptrio to postprocess variants

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded
n_shards integer Number of shards for deepvariant make_examples

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

deeptrio_postprocess_variants

Step 3 of 3 in the calling of SNVs and INDELs using deeptrio.

🐍 Rule

rule deeptrio_postprocess_variants:
    input:
        call_variants_record="snv_indels/deeptrio/{sample}_{type}/call_variants_output_{trio_member}.tfrecord.gz",
        gvcf_records=expand(
            "snv_indels/deeptrio/{{sample}}_{{type}}/gvcf_{{trio_member}}.tfrecord-{shard}-of-{nshards:05}.gz",
            shard=[f"{x:05}" for x in range(config.get("deeptrio_make_examples", {}).get("n_shards", 2))],
            nshards=config.get("deeptrio_make_examples", {}).get("n_shards", 2),
        ),
        ref=config.get("reference", {}).get("fasta", ""),
    output:
        vcf="snv_indels/deeptrio/{sample}_{type}/{trio_member}.vcf",
        gvcf="snv_indels/deeptrio/{sample}_{type}/{trio_member}.g.vcf",
    params:
        extra=lambda wildcards, input: deeptrio_postprocess_variants_args(
            wildcards,
            input,
            "deeptrio_make_examples",
            config.get("deeptrio_postprocess_variants", {}).get("extra", ""),
        ),
    log:
        "snv_indels/deeptrio/{sample}_{type}/postprocess_variants_{trio_member}.output.log",
    benchmark:
        repeat(
            "snv_indels/deeptrio/{sample}_{type}/postprocess_variants_{trio_member}.output.benchmark.tsv",
            config.get("deeptrio_postprocess_variants", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("deeptrio_postprocess_variants", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("deeptrio_postprocess_variants", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("deeptrio_postprocess_variants", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("deeptrio_postprocess_variants", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("deeptrio_postprocess_variants", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("deeptrio_postprocess_variants", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("deeptrio_postprocess_variants", {}).get("container", config["default_container"])
    message:
        "{rule}: Run deeptrio postprocess_variants on {input.call_variants_record}"
    shell:
        "(postprocess_variants "
        "--infile {input.call_variants_record} "
        "--ref {input.ref} "
        "--outfile {output.vcf} "
        "--gvcf_outfile {output.gvcf} "
        "--novcf_stats_report "
        "{params.extra} ) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input call_variants_record "snv_indels/deeptrio/{sample}_{type}/call_variants_output_{trio_member}.tfrecord.gz" files generated by deeptrio_call_variants
gvcf_records expand( "snv_indels/deeptrio/{{sample}}_{{type}}/gvcf_{{trio_member}}.tfrecord-{shard}-of-{nshards:05}.gz", shard=[f"{x:05}" for x in range(config.get("deeptrio_make_examples", {}).get("n_shards", 2))], nshards=config.get("deeptrio_make_examples", {}).get("n_shards", 2), ) files generated by deeptrio_make_examples
ref config.get("reference", {}).get("fasta", "") fasta reference genome file
output vcf "snv_indels/deeptrio/{sample}_{type}/{trio_member}.vcf" final vcf file
gvcf "snv_indels/deeptrio/{sample}_{type}/{trio_member}.g.vcf" genome vcf file with allele information for all positions

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

deepvariant

Calling of SNVs and INDELs using deepvariant.

🐍 Rule

rule deepvariant:
    input:
        bam="alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam",
        bai="alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam.bai",
        ref=config.get("reference", {}).get("fasta", ""),
    output:
        vcf=temp("snv_indels/deepvariant/{sample}_{type}_{chr}.vcf.gz"),
        gvcf=temp("snv_indels/deepvariant/{sample}_{type}_{chr}.g.vcf.gz")
        if config.get("deepvariant", {}).get("output_gvcf", False)
        else [],
    params:
        model_type=config.get("deepvariant", {}).get("model_type", ""),
        output_gvcf=lambda wildcards: get_gvcf_output(wildcards, "deepvariant"),
        int_res=lambda wildcards: f"snv_indels/deepvariant/{wildcards.sample}_{wildcards.type}_{wildcards.chr}",
        regions=lambda wildcards: f" --regions {wildcards.chr} ",
        extra=config.get("deepvariant", {}).get("extra", ""),
    log:
        "snv_indels/deepvariant/{sample}_{type}_{chr}.vcf.gz.log",
    benchmark:
        repeat(
            "snv_indels/deepvariant/{sample}_{type}_{chr}.vcf.gz.benchmark.tsv",
            config.get("deepvariant", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("deepvariant", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("deepvariant", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("deepvariant", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("deepvariant", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("deepvariant", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("deepvariant", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("deepvariant", {}).get("container", config["default_container"])
    message:
        "{rule}: Run deepvariant on {input.bam}"
    shell:
        "(run_deepvariant "
        "--model_type {params.model_type} "
        "--ref {input.ref} "
        "--reads {input.bam} "
        "{params.regions} "
        "{params.extra} "
        "--output_vcf {output.vcf} "
        "{params.output_gvcf} "
        "--intermediate_results_dir {params.int_res} "
        "--num_shards {threads} ) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input ref config.get("reference", {}).get("fasta", "") fasta reference genome file
bam "alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam" chromosome split bam file
bai "alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam.bai" bam index file
output vcf "snv_indels/deepvariant/{sample}_{type}_{chr}.vcf.gz" vcf file with snv and indels calls
gvcf "snv_indels/deepvariant/{sample}_{type}_{chr}.g.vcf.gz" gVCF file with snv and indels calls and non-variant blocks (optional output configured in config.yaml as a boolean variable called output_gvcf under deepvariant)

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded
model_type string Specify which model type to use with deepvariant
output_gvcf boolean Specify if a gVCF should be written

Resources settings (resources.yaml)

Key Type Description
gres string generic resource scheduling
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

fix_af

Python script that fixes missing AF in the format field of a vcf file as this is not generated by all callers.

🐍 Rule

rule fix_af:
    input:
        vcf="snv_indels/{caller}/{sample}_{type}.merged.vcf.gz",
    output:
        vcf=temp("snv_indels/{caller}/{sample}_{type}.fix_af.vcf"),
    log:
        "snv_indels/{caller}/{sample}_{type}.fix_af.vcf.log",
    benchmark:
        repeat(
            "snv_indels/{caller}/{sample}_{type}.fix_af.vcf.benchmark.tsv",
            config.get("fix_af", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("fix_af", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("fix_af", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("fix_af", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("fix_af", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("fix_af", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("fix_af", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("fix_af", {}).get("container", config["default_container"])
    message:
        "{rule}: fix missing allele frequency field in format column in {input.vcf}"
    script:
        "../scripts/fix_af.py"

↔ input / output files

Rule parameters Key Value Description
input vcf "snv_indels/{caller}/{sample}_{type}.merged.vcf.gz" vcf file where AF should be added to INFO field if missing
output vcf "snv_indels/{caller}/{sample}_{type}.fix_af.vcf" vcf file with added AF to the INFO filed
NOTE: only uses first sample if multiple samples available

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

freebayes

Somatic variant caller for SNVs and small indels.

🐍 Rule

rule freebayes:
    input:
        ref=config["reference"]["fasta"],
        samples="alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam",
        indexes="alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam.bai",
        regions="snv_indels/bed_split/design_bedfile_{chr}.bed",
    output:
        vcf=temp("snv_indels/freebayes/{sample}_{type}_{chr}.vcf"),
    params:
        extra="--target snv_indels/bed_split/design_bedfile_{chr}.bed %s"
        % config.get("freebayes", {}).get("extra", "--min-alternate-fraction 0.01 --genotype-qualities --strict-vcf"),
    log:
        "snv_indels/freebayes/{sample}_{type}_{chr}.unfilt.vcf.log",
    benchmark:
        repeat(
            "snv_indels/freebayes/{sample}_{type}_{chr}.benchmark.tsv", config.get("freebayes", {}).get("benchmark_repeats", 1)
        )
    threads: config.get("freebayes", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("freebayes", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("freebayes", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("freebayes", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("freebayes", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("freebayes", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("freebayes", {}).get("container", config["default_container"])
    message:
        "{rule}: call variants in {input.samples}"
    wrapper:
        "v1.3.1/bio/freebayes"

↔ input / output files

Rule parameters Key Value Description
input ref config["reference"]["fasta"] fasta reference genome file
samples "alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam" chromosome split bam file
indexes "alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam.bai" bam index file
regions "snv_indels/bed_split/design_bedfile_{chr}.bed" chromosome split bed file with regions in that should be used in calling
output vcf "snv_indels/freebayes/{sample}_{type}_{chr}.vcf" vcf file with snv and indels calls

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

gatk_mutect2

Step 1 of 4 of Mutect2 variant calling generating chromosome split unfiltered calls as well as variant statistic files (used for variant filtering) and INDEL-bam files.

🐍 Rule

rule gatk_mutect2:
    input:
        map="alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam",
        bai="alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam.bai",
        fasta=config.get("reference", {}).get("fasta", ""),
        bed="snv_indels/bed_split/design_bedfile_{chr}.bed",
    output:
        bam=temp("snv_indels/gatk_mutect2/{sample}_{type}_{chr}.unfiltered.bam"),
        bai=temp("snv_indels/gatk_mutect2/{sample}_{type}_{chr}.unfiltered.bai"),
        stats=temp("snv_indels/gatk_mutect2/{sample}_{type}_{chr}.unfiltered.vcf.gz.stats"),
        vcf=temp("snv_indels/gatk_mutect2/{sample}_{type}_{chr}.unfiltered.vcf.gz"),
        tbi=temp("snv_indels/gatk_mutect2/{sample}_{type}_{chr}.unfiltered.vcf.gz.tbi"),
        f1f2=temp("snv_indels/gatk_mutect2/{sample}_{type}_{chr}.unfiltered.f1r2.tar.gz"),
    params:
        extra=lambda wildcards: get_gatk_mutect2_extra(wildcards, "gatk_mutect2"),
    log:
        "snv_indels/gatk_mutect2/{sample}_{type}_{chr}.unfiltered.vcf.gz.log",
    benchmark:
        repeat(
            "snv_indels/gatk_mutect2/{sample}_{type}_{chr}.unfiltered.vcf.gz.benchmark.tsv",
            config.get("gatk_mutect2", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("gatk_mutect2", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("gatk_mutect2", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("gatk_mutect2", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("gatk_mutect2", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("gatk_mutect2", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("gatk_mutect2", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("gatk_mutect2", {}).get("container", config["default_container"])
    message:
        "{rule}: call variants in {input.map}"
    wrapper:
        "v1.5.0/bio/gatk/mutect"

↔ input / output files

Rule parameters Key Value Description
input map "alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam" chromosome split bam file
bai "alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam.bai" bam index file
fasta config.get("reference", {}).get("fasta", "") fasta reference genome file
bed "snv_indels/bed_split/design_bedfile_{chr}.bed" chromosome split bed file with regions in that should be used in calling
output bam "snv_indels/gatk_mutect2/{sample}_{type}_{chr}.unfiltered.bam" chromosome split bam file with regions containing candidate indels that can be used to confirm them in e.g. IGV
bai "snv_indels/gatk_mutect2/{sample}_{type}_{chr}.unfiltered.bai" bam index file
stats "snv_indels/gatk_mutect2/{sample}_{type}_{chr}.unfiltered.vcf.gz.stats" variant statistics file used for variant filtering by gatk_mutect2_filter
vcf "snv_indels/gatk_mutect2/{sample}_{type}_{chr}.unfiltered.vcf.gz" unfiltered compressed .vcf.gz file for one chromosome
tbi "snv_indels/gatk_mutect2/{sample}_{type}_{chr}.unfiltered.vcf.gz.tbi" tabix file index (.vcf.gz.tbi)
f1f2 "snv_indels/gatk_mutect2/{sample}_{type}_{chr}.unfiltered.f1r2.tar.gz" file with an orientation bias model that can be used for variant filtering

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

gatk_mutect2_gvcf

Mutect2 is used to generate a genome vcf file containing allele information for all positions in the bed file.

🐍 Rule

rule gatk_mutect2_gvcf:
    input:
        map="alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam",
        bai="alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam.bai",
        fasta=config.get("reference", {}).get("fasta", ""),
        bed="snv_indels/bed_split/design_bedfile_{chr}.bed",
    output:
        stats=temp("snv_indels/gatk_mutect2_gvcf/{sample}_{type}_{chr}.g.vcf.gz.stats"),
        vcf=temp("snv_indels/gatk_mutect2_gvcf/{sample}_{type}_{chr}.g.vcf.gz"),
        tbi=temp("snv_indels/gatk_mutect2_gvcf/{sample}_{type}_{chr}.g.vcf.gz.tbi"),
    params:
        extra=lambda wildcards: get_gatk_mutect2_extra(wildcards, "gatk_mutect2_gvcf"),
    log:
        "snv_indels/gatk_mutect2_gvcf/{sample}_{type}_{chr}.g.vcf.gz.log",
    benchmark:
        repeat(
            "snv_indels/gatk_mutect2_gvcf/{sample}_{type}_{chr}.g.vcf.gz.benchmark.tsv",
            config.get("gatk_mutect2_gvcf", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("gatk_mutect2_gvcf", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("gatk_mutect2_gvcf", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("gatk_mutect2_gvcf", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("gatk_mutect2_gvcf", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("gatk_mutect2_gvcf", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("gatk_mutect2_gvcf", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("gatk_mutect2_gvcf", {}).get("container", config["default_container"])
    message:
        "{rule}: generate gvcf from {input.map}"
    wrapper:
        "v1.5.0/bio/gatk/mutect"

↔ input / output files

Rule parameters Key Value Description
input map "alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam" chromosome split bam file
bai "alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam.bai" bam index file
fasta config.get("reference", {}).get("fasta", "") fasta reference genome file
bed "snv_indels/bed_split/design_bedfile_{chr}.bed" chromosome split bed file with regions in that should be used in calling
output stats "snv_indels/gatk_mutect2_gvcf/{sample}_{type}_{chr}.g.vcf.gz.stats" variant statistics file used for variant filtering
vcf "snv_indels/gatk_mutect2_gvcf/{sample}_{type}_{chr}.g.vcf.gz" compressed genome .g.vcf.gz file for one chromosome containing allele information for all positions in the bed file
tbi "snv_indels/gatk_mutect2_gvcf/{sample}_{type}_{chr}.g.vcf.gz.tbi" tabix file index (.g.vcf.gz.tbi)

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

gatk_mutect2_filter

Step 3 of 4 of Mutect2 variant calling filtering the called variants using the merged statistics file.

🐍 Rule

rule gatk_mutect2_filter:
    input:
        vcf="snv_indels/gatk_mutect2/{sample}_{type}.merged.unfiltered.vcf.gz",
        tbi="snv_indels/gatk_mutect2/{sample}_{type}.merged.unfiltered.vcf.gz.tbi",
        stats="snv_indels/gatk_mutect2/{sample}_{type}.unfiltered.vcf.gz.stats",
        ref=config.get("reference", {}).get("fasta", ""),
    output:
        vcf=temp("snv_indels/gatk_mutect2/{sample}_{type}.merged.softfiltered.vcf.gz"),
    params:
        extra=lambda wildcards, input: "%s --stats %s" % (config.get("gatk_mutect2_filter", {}).get("extra", ""), input.stats),
    log:
        "snv_indels/gatk_mutect2/{sample}_{type}.merged.softfiltered.vcf.gz.log",
    benchmark:
        repeat(
            "snv_indels/gatk_mutect2/{sample}_{type}.merged.softfiltered.vcf.gz.benchmark.tsv",
            config.get("gatk_mutect2_filter", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("gatk_mutect2_filter", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("gatk_mutect2_filter", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("gatk_mutect2_filter", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("gatk_mutect2_filter", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("gatk_mutect2_filter", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("gatk_mutect2_filter", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("gatk_mutect2_filter", {}).get("container", config["default_container"])
    message:
        "{rule}: softfilter mutect2 variants in {input.vcf} to {output.vcf}"
    wrapper:
        "v1.5.0/bio/gatk/filtermutectcalls"

↔ input / output files

Rule parameters Key Value Description
input vcf "snv_indels/gatk_mutect2/{sample}_{type}.merged.unfiltered.vcf.gz" chromosome merged unfiltered .vcf.gz file from gatk_mutect2
tbi "snv_indels/gatk_mutect2/{sample}_{type}.merged.unfiltered.vcf.gz.tbi" tabix .vcf.gz index file
stats "snv_indels/gatk_mutect2/{sample}_{type}.unfiltered.vcf.gz.stats" merged stats file generated by gatk_mutect2_merge_stats
ref config.get("reference", {}).get("fasta", "") fasta reference genome file
output vcf "snv_indels/gatk_mutect2/{sample}_{type}.merged.softfiltered.vcf.gz" soft filtered .vcf.gz file with called snv and indels

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

gatk_mutect2_merge_stats

Step 2 of 4 of Mutect2 variant calling merging the statistics file.

🐍 Rule

rule gatk_mutect2_merge_stats:
    input:
        stats=expand(
            "snv_indels/gatk_mutect2/{{sample}}_{{type}}_{chr}.unfiltered.vcf.gz.stats",
            chr=extract_chr(
                "%s.fai" % (config["reference"]["fasta"]), filter_out=config.get("reference", {}).get("skip_chrs", [])
            ),
        ),
    output:
        stats=temp("snv_indels/gatk_mutect2/{sample}_{type}.unfiltered.vcf.gz.stats"),
    params:
        stats=lambda wildcards, input: " -stats ".join(input.stats),
    log:
        "snv_indels/gatk_mutect2/{sample}_{type}.unfiltered.vcf.gz.stats.log",
    benchmark:
        repeat(
            "snv_indels/gatk_mutect2/{sample}_{type}.unfiltered.vcf.gz.stats.benchmark.tsv",
            config.get("gatk_mutect2_merge_stats", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("gatk_mutect2_merge_stats", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("gatk_mutect2_merge_stats", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("gatk_mutect2_merge_stats", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("gatk_mutect2_merge_stats", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("gatk_mutect2_merge_stats", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("gatk_mutect2_merge_stats", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("gatk_mutect2_merge_stats", {}).get("container", config["default_container"])
    message:
        "{rule}: merge mutect2 stats files into {output.stats}"
    shell:
        "(gatk MergeMutectStats "
        "-O {output.stats} "
        "-stats {params.stats}) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input stats expand( "snv_indels/gatk_mutect2/{{sample}}_{{type}}_{chr}.unfiltered.vcf.gz.stats", chr=extract_chr( "%s.fai" % (config["reference"]["fasta"]), filter_out=config.get("reference", {}).get("skip_chrs", []) ), ) list of chromosome stats files generated by gatk_mutect2
output stats "snv_indels/gatk_mutect2/{sample}_{type}.unfiltered.vcf.gz.stats" merged stats file used by gatk_mutect2_filter

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

glnexus

Joint variant caller based on .g.vcf files from deeptrio or other sources. Can be used for family trios as well as larger cohorts.

🐍 Rule

rule glnexus:
    input:
        gvcfs=expand("snv_indels/deeptrio/{{sample}}_{{type}}/{trio_member}.g.vcf", trio_member=["child", "parent1", "parent2"]),
    output:
        bcf=temp("snv_indels/glnexus/{sample}_{type}.bcf"),
        dir=temp(directory("snv_indels/glnexus/{sample}_{type}/GLnexus.DB")),
    params:
        extra=config.get("glnexus", {}).get("extra", ""),
        glnexus_config=config.get("glnexus", {}).get("configfile", ""),
        in_gvcf=lambda wildcards, input: get_glnexus_input(wildcards, input),
    log:
        "snv_indels/glnexus/{sample}_{type}.bcf.log",
    benchmark:
        repeat(
            "snv_indels/glnexus/{sample}_{type}.bcf.benchmark.tsv",
            config.get("glnexus", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("glnexus", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("glnexus", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("glnexus", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("glnexus", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("glnexus", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("glnexus", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("glnexus", {}).get("container", config["default_container"])
    message:
        "{rule}: Run GLNexus for joint genotyping of gVCFs"
    shell:
        "(glnexus_cli "
        "--dir {output.dir} {params.extra} "
        "--config {params.glnexus_config} "
        "{params.in_gvcf} > {output.bcf}) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input gvcfs expand("snv_indels/deeptrio/{{sample}}_{{type}}/{trio_member}.g.vcf", trio_member=["child", "parent1", "parent2"]) list of .g.vcf files, e.g. a family trio produced by deeptrio
output bcf "snv_indels/glnexus/{sample}_{type}.bcf" a joint call vcf file in .bcf file format (bcftools)
dir "snv_indels/glnexus/{sample}_{type}/GLnexus.DB" directory with files containing a GLnexus database

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded
glnexus_config string path to the glnexus config file
in_gvcf string string listing the input files
created by the get_glnexus_input function in common.smk

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

haplotypecaller

Germline variant caller for SNVs and INDELs.

🐍 Rule

rule haplotypecaller:
    input:
        bam="alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam",
        bai="alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam.bai",
        fasta=config["reference"]["fasta"],
        bed="snv_indels/bed_split/design_bedfile_{chr}.bed",
    output:
        vcf=temp("snv_indels/haplotypecaller/{sample}_{type}_{chr}.vcf"),
    params:
        extra=config.get("haplotypecaller", {}).get("extra", ""),
        java_opts=get_java_opts,
    log:
        "snv_indels/haplotypecaller/{sample}_{type}_{chr}.vcf.log",
    benchmark:
        repeat(
            "snv_indels/haplotypecaller/{sample}_{type}_{chr}.vcf.benchmark.tsv",
            config.get("haplotypecaller", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("haplotypecaller", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("haplotypecaller", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("haplotypecaller", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("haplotypecaller", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("haplotypecaller", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("haplotypecaller", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("haplotypecaller", {}).get("container", config["default_container"])
    message:
        "{rule}: call variants in {wildcards.chr} in {input.bam}"
    shell:
        "(gatk --java-options '{params.java_opts}' HaplotypeCaller "
        "-R {input.fasta} "
        "-I {input.bam} "
        "-O {output.vcf} "
        "-L {input.bed} "
        "-A AlleleFraction "
        "{params.extra}) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input bam "alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam" chromosome split bam file
bai "alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam.bai" bam file index files
fasta config["reference"]["fasta"] fasta reference genome file
bed "snv_indels/bed_split/design_bedfile_{chr}.bed" chromosome split bed file with regions in that should be used in calling
output vcf "snv_indels/haplotypecaller/{sample}_{type}_{chr}.vcf" vcf file with snv and indels calls

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

hiphase

Hiphase jointly phases small, structural, and tandem repeat variants for PacBio sequencing data

🐍 Rule

rule hiphase:
    input:
        bam="alignment/pbmm2_align/{sample}_{type}.bam",
        bai="alignment/pbmm2_align/{sample}_{type}.bam.bai",
        ref=config.get("reference", {}).get("fasta", ""),
        snv_vcf="snv_indels/deepvariant/{sample}_{type}.merged.vcf.gz",
        snv_tbi="snv_indels/deepvariant/{sample}_{type}.merged.vcf.gz.tbi",
        sv_vcf="cnv_sv/pbsv/{sample}_{type}.vcf.gz" if config.get("hiphase", {}).get("sv_caller", False) else [],
        sv_tbi="cnv_sv/pbsv/{sample}_{type}.vcf.gz.tbi" if config.get("hiphase", {}).get("sv_caller", False) else [],
        str_vcf="cnv_sv/trgt/{sample}_{type}.vcf.gz" if config.get("hiphase", {}).get("str_caller", False) else [],
        str_tbi="cnv_sv/trgt/{sample}_{type}.vcf.gz.tbi" if config.get("hiphase", {}).get("str_caller", False) else [],
    output:
        bam=temp("snv_indels/hiphase/{sample}_{type}.haplotagged.bam"),
        bai=temp("snv_indels/hiphase/{sample}_{type}.haplotagged.bam.bai"),
        snv_vcf=temp("snv_indels/hiphase/{sample}_{type}.deepvariant.phased.vcf.gz"),
        sv_vcf=temp("snv_indels/hiphase/{sample}_{type}.pbsv.phased.vcf.gz")
        if config.get("hiphase", {}).get("sv_caller", False)
        else [],
        str_vcf=temp("snv_indels/hiphase/{sample}_{type}.trgt.phased.vcf.gz")
        if config.get("hiphase", {}).get("str_caller", False)
        else [],
    params:
        extra=config.get("hiphase", {}).get("extra", ""),
        in_sv_vcf=lambda wildcards: f"--vcf cnv_sv/pbsv/{wildcards.sample}_{wildcards.type}.vcf.gz"
        if config.get("hiphase", {}).get("sv_caller", False)
        else "",
        out_sv_vcf=lambda wildcards: f"--output-vcf snv_indels/hiphase/{wildcards.sample}_{wildcards.type}.pbsv.phased.vcf.gz"
        if config.get("hiphase", {}).get("sv_caller", False)
        else "",
        in_str_vcf=lambda wildcards: f"--vcf cnv_sv/trgt/{wildcards.sample}_{wildcards.type}.vcf.gz"
        if config.get("hiphase", {}).get("str_caller", False)
        else "",
        out_str_vcf=lambda wildcards: f"--output-vcf snv_indels/hiphase/{wildcards.sample}_{wildcards.type}.trgt.phased.vcf.gz"
        if config.get("hiphase", {}).get("str_caller", False)
        else "",
    log:
        "snv_indels/hiphase/{sample}_{type}.haplotagged.bam.log",
    benchmark:
        repeat("snv_indels/hiphase/{sample}_{type}.output.benchmark.tsv", config.get("hiphase", {}).get("benchmark_repeats", 1))
    threads: config.get("hiphase", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("hiphase", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("hiphase", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("hiphase", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("hiphase", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("hiphase", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("hiphase", {}).get("container", config["default_container"])
    message:
        "{rule}: phase variants and haplotag bam files using hiphase"
    shell:
        "hiphase "
        "--reference {input.ref} "
        "--vcf {input.snv_vcf} "
        "--output-vcf {output.snv_vcf} "
        "{params.in_sv_vcf} "
        "{params.out_sv_vcf} "
        "{params.in_str_vcf} "
        "{params.out_str_vcf} "
        "--bam {input.bam} "
        "--output-bam {output.bam} 2> {log}"

↔ input / output files

Rule parameters Key Value Description
input bam "alignment/pbmm2_align/{sample}_{type}.bam" bam file with aligned HIFI Pacbio reads
bai "alignment/pbmm2_align/{sample}_{type}.bam.bai" index for the bam file
ref config.get("reference", {}).get("fasta", "") fasta reference genome file
snv_vcf "snv_indels/deepvariant/{sample}_{type}.merged.vcf.gz" Deepvariant vcf file
snv_tbi "snv_indels/deepvariant/{sample}_{type}.merged.vcf.gz.tbi" Deepvariant vcf file tabix index
sv_vcf "cnv_sv/pbsv/{sample}_{type}.vcf.gz" if config.get("hiphase", {}).get("sv_caller", False) else [] PBSV vcf file
sv_tbi "cnv_sv/pbsv/{sample}_{type}.vcf.gz.tbi" if config.get("hiphase", {}).get("sv_caller", False) else [] PBSV vcf file index
str_vcf "cnv_sv/trgt/{sample}_{type}.vcf.gz" if config.get("hiphase", {}).get("str_caller", False) else [] TRGT vcf file
str_tbi "cnv_sv/trgt/{sample}_{type}.vcf.gz.tbi" if config.get("hiphase", {}).get("str_caller", False) else [] TRGT vcf file index
output bam "snv_indels/hiphase/{sample}_{type}.haplotagged.bam" Haplotagged bam file with aligned HIFI Pacbio reads
bai "snv_indels/hiphase/{sample}_{type}.haplotagged.bam.bai" Haplotagged bam file index
snv_vcf "snv_indels/hiphase/{sample}_{type}.deepvariant.phased.vcf.gz" Phased Deepvariant vcf file
sv_vcf "snv_indels/hiphase/{sample}_{type}.pbsv.phased.vcf.gz" Phased PBSV vcf file
str_vcf "snv_indels/hiphase/{sample}_{type}.trgt.phased.vcf.gz" Phased TRGT vcf file

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

merge_af_complex_variants

Python script for handling complex variants with several vcf record.

Some variant callers (e.g. vardict) will compose variants within close physical distance and report it as one complex variant. vt_decompose will separate these complex variants into separate records. However, during decomposition the same allele might be reported in several record, one originating from the single variant and one or more records reported from one or more complex variants, even if these records are corresponding to the same allele at the same position. The allele frequencies will also be different for these records since it might be derived from the frequency of the allele in combination with a specific allele at another position whithin the complex variant.

This python script can turn several records from the same allele at the same position into one record. Depending on the method given by the user the allele frequency and metrics derived from this will be reported differently. "skip" is the default method and in this case no alterations of the records will be made. All records for a complex variant will be returned in the output vcf. The method "max" will return the record with the highest allele frequency and discard any additional records, with the same allele and position, from the output vcf. The "sum" method will sum the allele frequencies from all records with the same allele and position.

🐍 Rule

rule merge_af_complex_variants:
    input:
        vcf="snv_indels/{caller}/{sample}_{type}.normalized.sorted.vcf.gz",
        tabix="snv_indels/{caller}/{sample}_{type}.normalized.sorted.vcf.gz.tbi",
    output:
        vcf=temp("snv_indels/{caller}/{sample}_{type}.normalized.merged_af.vcf.gz"),
    params:
        merge_method=config.get("merge_af_complex_variants", {}).get("merge_method", "skip"),
    log:
        "snv_indels/{caller}/{sample}_{type}.normalized.merged_af.vcf.gz.log",
    benchmark:
        repeat(
            "snv_indels/{caller}/{sample}_{type}.normalized.merged_af.vcf.gz.benchmark.tsv",
            config.get("merge_af_complex_variants", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("merge_af_complex_variants", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("merge_af_complex_variants", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("merge_af_complex_variants", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("merge_af_complex_variants", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("merge_af_complex_variants", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("merge_af_complex_variants", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("merge_af_complex_variants", {}).get("container", config["default_container"])
    message:
        "{rule}: For decomposed complex variants in {input.vcf} create one record with updated allele frequency"
    script:
        "../scripts/merge_af.py"

↔ input / output files

Rule parameters Key Value Description
input vcf "snv_indels/{caller}/{sample}_{type}.normalized.sorted.vcf.gz" path to a decomposed and normalized vcf file
tabix "snv_indels/{caller}/{sample}_{type}.normalized.sorted.vcf.gz.tbi" path to decomposed and normalized vcf index file
output vcf "snv_indels/{caller}/{sample}_{type}.normalized.merged_af.vcf.gz" vcf file with only one (if merge_method max or sum) record per complex variant

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
merge_method string method to handle allele frequencies from complex variants, skip, max or sum

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

[mosaicforecast_input]

Getting the information needed for MosaicForecast from the .vcf-file. A list of the position that should be evaluated for their mosaic potential. There are some options here, DeepSomatic vcf with filtered variants (only PASS) or Mutect2 with filters (filter suggestions in MosaicForecast article) for higher specificity.

🐍 Rule

rule mosaicforecast_input:
    input:
        vcf="snv_indels/deepsomatic_t_only/{sample}_{type}.vcf.gz",
    output:
        variants=temp("snv_indels/mosaicforecast_input/{sample}_{type}.input"),
    params:
        extra=config.get("mosaicforecast_input", {}).get("extra", ""),
        bcftools_filter=config.get("mosaicforecast_input", {}).get("bcftools_filter", ""),
        name=lambda wildcards: f"{wildcards.sample}_{wildcards.type}",
    log:
        "snv_indels/mosaicforecast_input/{sample}_{type}.input.log",
    benchmark:
        repeat(
            "snv_indels/mosaicforecast_input/{sample}_{type}.input_benchmark.tsv",
            config.get("mosaicforecast_input", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("mosaicforecast_input", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("mosaicforecast_input", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("mosaicforecast_input", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("mosaicforecast_input", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("mosaicforecast_input", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("mosaicforecast_input", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("mosaicforecast_input", {}).get("container", config["default_container"])
    message:
        "{rule}: make input file for mosaic forecast by making a file with candidate variants based in {input.vcf}"
    shell:
        "(bcftools query "
        "{params.bcftools_filter} "
        "{params.extra} "
        "-f '%CHROM\t%POS0\t%END\t%REF\t%ALT\t{params.name}\n' "
        "{input.vcf} "
        "> {output.variants} ) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input vcf "snv_indels/deepsomatic_t_only/{sample}_{type}.vcf.gz" the .vcf file, preferrably from deepSomatic or Mutect2 (a tool that can find somatic/mosaic variation)
output variants "snv_indels/mosaicforecast_input/{sample}_{type}.input" candidate variants for mosaicforecast with info about chr, start, stop, ref, alt, and sample

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

mosaicforecast_genotype_prediction

A machine learning method that leverages read-based phasing and read-level features to accurately detect mosaic SNVs (SNPs, small indels) from NGS data. It builds on existing algorithms to achieve a multifold increase in specificity.

🐍 Rule

rule mosaicforecast_genotype_prediction:
    input:
        features="snv_indels/mosaicforecast_readlevel/{sample}_{type}/features.txt",
    output:
        predict=temp("snv_indels/mosaicforecast_genotype_prediction/{sample}_{type}.{variant}.predictions"),
    params:
        extra=config.get("mosaicforecast_genotype_prediction", {}).get("extra", ""),
        model_trained=lambda wildcards: config.get("mosaicforecast_genotype_prediction", {}).get(
            f"model_trained_{wildcards.variant}", ""
        ),
        model_type=lambda wildcards: config.get("mosaicforecast_genotype_prediction", {}).get(
            f"model_type_{wildcards.variant}", ""
        ),
    log:
        "snv_indels/mosaicforecast_genotype_prediction/{sample}_{type}.{variant}.predictions.log",
    benchmark:
        repeat(
            "snv_indels/mosaicforecast_genotype_prediction/{sample}_{type}.{variant}.predictions.benchmark.tsv",
            config.get("mosaicforecast_genotype_prediction", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("mosaicforecast_genotype_prediction", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("mosaicforecast_genotype_prediction", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("mosaicforecast_genotype_prediction", {}).get(
            "mem_per_cpu", config["default_resources"]["mem_per_cpu"]
        ),
        partition=config.get("mosaicforecast_genotype_prediction", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("mosaicforecast_genotype_prediction", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("mosaicforecast_genotype_prediction", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("mosaicforecast_genotype_prediction", {}).get("container", config["default_container"])
    message:
        "{rule}: mosaicforecast predicts all input sites"
    wildcard_constraints:
        variant="SNP|INS|DEL",
    shell:
        "(Prediction.R "
        "{input.features} "
        "{params.model_trained} "
        "{params.model_type} "
        "{output.predict} "
        "{params.extra}) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input features "snv_indels/mosaicforecast_readlevel/{sample}_{type}/features.txt" the features.txt from mosaicforecast_readlevel, information from position
output predict "snv_indels/mosaicforecast_genotype_prediction/{sample}_{type}.{variant}.predictions" A text file mosaic predictions for all input site. Predictions are refhom, het, mosaic or repeat.

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded
model_trained string file with the model being used (e.g. 200xRFmodel_addRMSK_Refine.rds or deletions_250x.RF.rds(phase) or insertions_250x.RF.rds)
model_type string the type of model used Phase or Refine

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

mosaicforecast_phasing

Read-based phasing that predicts how many haplotypes that exist based on the variants in the bam file that is located close to the candidate variant.

🐍 Rule

rule mosaicforecast_phasing:
    input:
        bam="alignment/samtools_merge_bam/{sample}_{type}.bam",
        bai="alignment/samtools_merge_bam/{sample}_{type}.bam.bai",
        fasta=config.get("reference", {}).get("fasta", ""),
        variants="snv_indels/mosaicforecast_input/{sample}_{type}.input",
    output:
        all_candidates=temp("snv_indels/mosaicforecast_phasing/{sample}_{type}/all_candidates"),
        all_infor_snps=temp("snv_indels/mosaicforecast_phasing/{sample}_{type}/all.merged.inforSNPs.pos"),
        all_phasing=temp("snv_indels/mosaicforecast_phasing/{sample}_{type}/all.phasing"),
        multi_infor_snps=temp("snv_indels/mosaicforecast_phasing/{sample}_{type}/multiple_inforSNPs.log"),
        phase_table=temp("snv_indels/mosaicforecast_phasing/{sample}_{type}/all.phasing_2by2"),
        table=temp("snv_indels/mosaicforecast_phasing/{sample}_{type}/all_2x2table"),
        tmpdir=temp(directory("snv_indels/mosaicforecast_phasing/{sample}_{type}/tmp")),
    params:
        extra=config.get("mosaicforecast_phasing", {}).get("extra", ""),
        f_format=config.get("mosaicforecast_phasing", {}).get("f_format", ""),
        min_dp=config.get("mosaicforecast_phasing", {}).get("min_dp", "20"),
        path=lambda wildcards, input: os.path.dirname(input[0]),
        outdir=lambda wildcards: f"snv_indels/mosaicforecast_phasing/{wildcards.sample}_{wildcards.type}",
        umap=config.get("mosaicforecast_phasing", {}).get("umap", ""),
    log:
        "snv_indels/mosaicforecast_phasing/{sample}_{type}.mosaicforecast_phasing.log",
    benchmark:
        repeat(
            "snv_indels/mosaicforecast_phasing/{sample}_{type}.mosaicforecast_phasing.benchmark.tsv",
            config.get("mosaicforecast_phasing", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("mosaicforecast_phasing", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("mosaicforecast_phasing", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("mosaicforecast_phasing", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("mosaicforecast_phasing", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("mosaicforecast_phasing", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("mosaicforecast_phasing", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("mosaicforecast_phasing", {}).get("container", config["default_container"])
    message:
        "{rule}: mosaicforecast phasing evaluation of candidate variants"
    shell:
        "(Phase.py "
        "{params.path} "
        "{params.outdir} "
        "{input.fasta} "
        "{input.variants} "
        "{params.min_dp} "
        "{params.umap} "
        "{resources.threads} "
        "{params.f_format} "
        "{params.extra}) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input fasta config.get("reference", {}).get("fasta", "") the fasta file used for alignment
bai "alignment/samtools_merge_bam/{sample}_{type}.bam.bai" the .bam file index (or crai)
bam "alignment/samtools_merge_bam/{sample}_{type}.bam" marked duplication, merged and sorted .bam file (or cram), but in shell the path from params are used
variants "snv_indels/mosaicforecast_input/{sample}_{type}.input" candidate variants for mosaicforecast_input with info about chr, start, stop, ref, alt, and sample
output all_candidates "snv_indels/mosaicforecast_phasing/{sample}_{type}/all_candidates" file with candidate variants used in phasing
all_infor_snps "snv_indels/mosaicforecast_phasing/{sample}_{type}/all.merged.inforSNPs.pos" all nearby inforSNPs of candidate mosaics
all_phasing "snv_indels/mosaicforecast_phasing/{sample}_{type}/all.phasing" file with all phasing information for candidate variants and informative snps
multi_infor_snps "snv_indels/mosaicforecast_phasing/{sample}_{type}/multiple_inforSNPs.log" Phasing results of different pairs of inforSNPs.
phase_table "snv_indels/mosaicforecast_phasing/{sample}_{type}/all.phasing_2by2" Phasing results of mosaics and all nearby inforSNPs (2x2 table).
table "snv_indels/mosaicforecast_phasing/{sample}_{type}/all_2x2table" 2x2 tables by all nearby inforSNPs
tmpdir "snv_indels/mosaicforecast_phasing/{sample}_{type}/tmp" temporary directory used during mosaicforecast phasing

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded
f_format string if a cram or bam file is being used
path string the path to where the bam file is located
umap string location of the k24.umap.wg.bw

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

mosaicforecast_readlevel

Using read-level features to accurately detect mosaic SNVs (SNPs, small indels) from NGS data. Calculates AF, DP and mosaic likelihood to mention a few things, at the same time as it checks the regions GC content and mapability.

🐍 Rule

rule mosaicforecast_readlevel:
    input:
        bam="alignment/samtools_merge_bam/{sample}_{type}.bam",
        bai="alignment/samtools_merge_bam/{sample}_{type}.bam.bai",
        fasta=config.get("reference", {}).get("fasta", ""),
        variants="snv_indels/mosaicforecast_input/{sample}_{type}.input",
    output:
        features=temp("snv_indels/mosaicforecast_readlevel/{sample}_{type}/features.txt"),
        features_tmp=temp("snv_indels/mosaicforecast_readlevel/{sample}_{type}/features.txt.tmp"),
    params:
        extra=config.get("mosaicforecast_readlevel", {}).get("extra", ""),
        f_format=config.get("mosaicforecast_readlevel", {}).get("f_format", ""),
        path=lambda w, input: os.path.dirname(input[0]),
        umap=config.get("mosaicforecast_readlevel", {}).get("umap", ""),
    log:
        "snv_indels/mosaicforecast_readlevel/{sample}_{type}.mosaicforecast_readlevel.log",
    benchmark:
        repeat(
            "snv_indels/mosaicforecast_readlevel/{sample}_{type}.mosaicforecast_readlevel.benchmark.tsv",
            config.get("mosaicforecast_readlevel", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("mosaicforecast_readlevel", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("mosaicforecast_readlevel", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("mosaicforecast_readlevel", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("mosaicforecast_readlevel", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("mosaicforecast_readlevel", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("mosaicforecast_readlevel", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("mosaicforecast_readlevel", {}).get("container", config["default_container"])
    message:
        "{rule}: mosaicforecast extraction of read-level features"
    shell:
        "(ReadLevel_Features_extraction.py "
        "{input.variants} "
        "{output.features} "
        "{params.path} "
        "{input.fasta} "
        "{params.umap} "
        "{resources.threads} "
        "{params.f_format} "
        "{params.extra}) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input fasta config.get("reference", {}).get("fasta", "") the fasta file used for alignment
bai "alignment/samtools_merge_bam/{sample}_{type}.bam.bai" the .bam file index (or crai)
bam "alignment/samtools_merge_bam/{sample}_{type}.bam" marked duplication, merged and sorted .bam file, but in shell the path from params are used
variants "snv_indels/mosaicforecast_input/{sample}_{type}.input" candidate variants for mosaicforecast_input with info about chr, start, stop, ref, alt, and sample
output features "snv_indels/mosaicforecast_readlevel/{sample}_{type}/features.txt" A list of read-level features for each input site.
features_tmp "snv_indels/mosaicforecast_readlevel/{sample}_{type}/features.txt.tmp" temporary features file used during mosaicforecast readlevel

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded
f_format string if a cram or bam file is being used
path string the path to where the bam file is located
umap string location of the k24.umap.wg.bw

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

mutect2_pass_filter

Step 4 of 4 of Mutect2 somatic variant calling. A python script that hard filters the soft filtered vcf file from Mutect2 based on the FILTER column.

🐍 Rule

rule haplotypecaller:
    input:
        bam="alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam",
        bai="alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam.bai",
        fasta=config["reference"]["fasta"],
        bed="snv_indels/bed_split/design_bedfile_{chr}.bed",
    output:
        vcf=temp("snv_indels/haplotypecaller/{sample}_{type}_{chr}.vcf"),
    params:
        extra=config.get("haplotypecaller", {}).get("extra", ""),
        java_opts=get_java_opts,
    log:
        "snv_indels/haplotypecaller/{sample}_{type}_{chr}.vcf.log",
    benchmark:
        repeat(
            "snv_indels/haplotypecaller/{sample}_{type}_{chr}.vcf.benchmark.tsv",
            config.get("haplotypecaller", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("haplotypecaller", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("haplotypecaller", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("haplotypecaller", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("haplotypecaller", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("haplotypecaller", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("haplotypecaller", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("haplotypecaller", {}).get("container", config["default_container"])
    message:
        "{rule}: call variants in {wildcards.chr} in {input.bam}"
    shell:
        "(gatk --java-options '{params.java_opts}' HaplotypeCaller "
        "-R {input.fasta} "
        "-I {input.bam} "
        "-O {output.vcf} "
        "-L {input.bed} "
        "-A AlleleFraction "
        "{params.extra}) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input bam "alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam" chromosome split bam file
bai "alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam.bai" bam file index files
fasta config["reference"]["fasta"] fasta reference genome file
bed "snv_indels/bed_split/design_bedfile_{chr}.bed" chromosome split bed file with regions in that should be used in calling
output vcf "snv_indels/haplotypecaller/{sample}_{type}_{chr}.vcf" vcf file with snv and indels calls

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

tabix

Creates an index file for faster processing of positions in a bgzipped vcf file.

🐍 Rule

rule tabix:
    input:
        gz="{file}.vcf.gz",
    output:
        tbi=temp("{file}.vcf.gz.tbi"),
    params:
        extra=config.get("tabix", {}).get("extra", ""),
    log:
        "{file}.vcf.gz.tbi.log",
    benchmark:
        repeat(
            "{file}.vcf.gz.tbi.benchmark.tsv",
            config.get("tabix", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("tabix", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("tabix", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("tabix", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("tabix", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("tabix", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("tabix", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("tabix", {}).get("container", config["default_container"])
    message:
        "{rule}: index {input.gz}"
    wrapper:
        "v1.3.1/bio/tabix"

↔ input / output files

Rule parameters Key Value Description
input gz "{file}.vcf.gz" bgzipped vcf file
output tbi "{file}.vcf.gz.tbi" tabix index file

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

vardict

Somatic variant caller for SNVs and INDELs.

🐍 Rule

rule vardict:
    input:
        bam="alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam",
        bai="alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam.bai",
        reference=config["reference"]["fasta"],
        regions="snv_indels/bed_split/design_bedfile_{chr}.bed",
    output:
        vcf=temp("snv_indels/vardict/{sample}_{type}_{chr}.vcf"),
    params:
        extra=config.get("vardict", {}).get("extra", "-Q 1"),
        bed_columns=config.get("vardict", {}).get("bed_columns", "-c 1 -S 2 -E 3 -g 4"),
        allele_frequency_threshold=config.get("vardict", {}).get("allele_frequency_threshold", "0.01"),
        sample_name="{sample}_{type}",
    log:
        "snv_indels/vardict/{sample}_{type}_{chr}.vcf.log",
    benchmark:
        repeat("snv_indels/vardict/{sample}_{type}_{chr}.benchmark.tsv", config.get("vardict", {}).get("benchmark_repeats", 1))
    threads: config.get("vardict", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("vardict", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("vardict", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("vardict", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("vardict", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("vardict", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("vardict", {}).get("container", config["default_container"])
    message:
        "{rule}: call variants in {input.bam}"
    wrapper:
        "v1.3.1/bio/vardict"

↔ input / output files

Rule parameters Key Value Description
input bam "alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam" chromosome split bam file
bai "alignment/picard_mark_duplicates/{sample}_{type}_{chr}.bam.bai" bam file index files
reference config["reference"]["fasta"] fasta reference genome file
regions "snv_indels/bed_split/design_bedfile_{chr}.bed" chromosome split bed file with regions in that should be used in calling
output vcf "snv_indels/vardict/{sample}_{type}_{chr}.vcf" vcf file with snv and indels calls

🔧 Configuration

Software settings (config.yaml)

Key Type Description
allele_frequency_threshold string allele frequency threshold
bed_columns string columns to use in bed file
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

vt_decompose

Decomposition of vcf files. Uses both the decompose and the decompose_blocksub command. Decompose_blocksub divide clumped variants into separate records, while decompose divide multiallelic variants into separate records.

🐍 Rule

rule vt_decompose:
    input:
        vcf="snv_indels/{caller}/{sample}_{type}.fix_af.vcf.gz",
    output:
        vcf=temp("snv_indels/{caller}/{sample}_{type}.decomposed.vcf.gz"),
    log:
        "snv_indels/{caller}/{sample}_{type}.decomposed.vcf.gz.log",
    benchmark:
        repeat(
            "snv_indels/{caller}/{sample}_{type}.decomposed.vcf.gz.benchmark.tsv",
            config.get("vt_decompose", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("vt_decompose", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("vt_decompose", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("vt_decompose", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("vt_decompose", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("vt_decompose", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("vt_decompose", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("vt_decompose", {}).get("container", config["default_container"])
    message:
        "{rule}: decompose {input.vcf}"
    shell:
        "(vt decompose -s {input.vcf} | vt decompose_blocksub -o {output.vcf} -) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input vcf "snv_indels/{caller}/{sample}_{type}.fix_af.vcf.gz" vcf file that should be decomposed
output vcf "snv_indels/{caller}/{sample}_{type}.decomposed.vcf.gz" decomposed vcf file

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

vt_normalize

Normalization of vcf files. Left aligns INDELs and adds one reference allele. Affects variant position.

🐍 Rule

rule vt_normalize:
    input:
        vcf="snv_indels/{caller}/{sample}_{type}.decomposed.vcf.gz",
        ref=config["reference"]["fasta"],
    output:
        vcf=temp("snv_indels/{caller}/{sample}_{type}.normalized.vcf.gz"),
    log:
        "snv_indels/{caller}/{sample}_{type}.normalized.vcf.gz.log",
    benchmark:
        repeat(
            "snv_indels/{caller}/{sample}_{type}.normalized.vcf.gz.benchmark.tsv",
            config.get("vt_normalize", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("vt_normalize", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("vt_normalize", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("vt_normalize", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("vt_normalize", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("vt_normalize", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("vt_normalize", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("vt_normalize", {}).get("container", config["default_container"])
    message:
        "{rule}: normalize {input.vcf}"
    shell:
        "(vt normalize -n -r {input.ref} -o {output.vcf} {input.vcf} ) &> {log}"

↔ input / output files

Rule parameters Key Value Description
input vcf "snv_indels/{caller}/{sample}_{type}.decomposed.vcf.gz" vcf file that should be normalized
ref config["reference"]["fasta"] fasta reference genome file
output vcf "snv_indels/{caller}/{sample}_{type}.normalized.vcf.gz" normalized vcf file

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

whatshap_haplotag

If you already have a phased VCF and would like to know which reads in an alignment file belong to which haplotype, you can use whatshap haplotag. The tagged reads can then be visualized along with the variants.

🐍 Rule

rule whatshap_haplotag:
    input:
        aln=lambda wildcards: get_input_aligned_bam(wildcards, config)[0],
        bai=lambda wildcards: get_input_aligned_bam(wildcards, config)[1],
        ref=config.get("reference", {}).get("fasta", ""),
        fai=config.get("reference", {}).get("fai", ""),
        vcf="snv_indels/whatshap_phase/{sample}_{type}.phased.vcf.gz",
        tbi="snv_indels/whatshap_phase/{sample}_{type}.phased.vcf.gz.tbi",
    output:
        bam=temp("snv_indels/whatshap_haplotag/{sample}_{type}.haplotagged.bam"),
    params:
        extra=config.get("whatshap_haplotag", {}).get("extra", ""),
    log:
        "snv_indels/whatshap_haplotag/{sample}_{type}.haplotagged.bam.log",
    benchmark:
        repeat(
            "snv_indels/whatshap_haplotag/{sample}_{type}.haplotagged.bam.benchmark.tsv",
            config.get("whatshap_haplotag", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("whatshap_haplotag", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("whatshap_haplotag", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("whatshap_haplotag", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("whatshap_haplotag", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("whatshap_haplotag", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("whatshap_haplotag", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("whatshap_haplotag", {}).get("container", config["default_container"])
    message:
        "{rule}: do haplotagging on {input.aln}"
    wrapper:
        "v6.0.0/bio/whatshap/haplotag"

↔ input / output files

Rule parameters Key Value Description
input vcf "snv_indels/whatshap_phase/{sample}_{type}.phased.vcf.gz" phased variants in VCF format
aln lambda wildcards: get_input_aligned_bam(wildcards, config)[0] BAM file with reads to haplotag
bai lambda wildcards: get_input_aligned_bam(wildcards, config)[1] BAM file index to use for haplotagging
ref config.get("reference", {}).get("fasta", "") reference genome in FASTA format
fai config.get("reference", {}).get("fai", "") index file for the reference genome
tbi "snv_indels/whatshap_phase/{sample}_{type}.phased.vcf.gz.tbi" tabix index file for the VCF
output bam "snv_indels/whatshap_haplotag/{sample}_{type}.haplotagged.bam" BAM file with haplotagged reads

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time

whatshap_phase

WhatsHap is a read-based phasing tool. In the typical case, it expects 1) a VCF file with variants of an individual and 2) a BAM or CRAM file with sequencing reads from that same individual. WhatsHap uses the sequencing reads to reconstruct the haplotypes and then writes out the input VCF augmented with phasing information.

🐍 Rule

rule whatshap_phase:
    input:
        bam=lambda wildcards: get_input_aligned_bam(wildcards, config)[0],
        bai=lambda wildcards: get_input_aligned_bam(wildcards, config)[1],
        fasta=config.get("reference", {}).get("fasta", ""),
        vcf="snv_indels/deepsomatic_t_only/{sample}_{type}.vcf.gz",
    output:
        vcf=temp("snv_indels/whatshap_phase/{sample}_{type}.phased.vcf.gz"),
    params:
        extra=config.get("whatshap_phase", {}).get("extra", ""),
    log:
        "snv_indels/whatshap_phase/{sample}_{type}.phased.vcf.gz.log",
    benchmark:
        repeat(
            "snv_indels/whatshap_phase/{sample}_{type}.phased.vcf.gz.benchmark.tsv",
            config.get("whatshap_phase", {}).get("benchmark_repeats", 1),
        )
    threads: config.get("whatshap_phase", {}).get("threads", config["default_resources"]["threads"])
    resources:
        mem_mb=config.get("whatshap_phase", {}).get("mem_mb", config["default_resources"]["mem_mb"]),
        mem_per_cpu=config.get("whatshap_phase", {}).get("mem_per_cpu", config["default_resources"]["mem_per_cpu"]),
        partition=config.get("whatshap_phase", {}).get("partition", config["default_resources"]["partition"]),
        threads=config.get("whatshap_phase", {}).get("threads", config["default_resources"]["threads"]),
        time=config.get("whatshap_phase", {}).get("time", config["default_resources"]["time"]),
    container:
        config.get("whatshap_phase", {}).get("container", config["default_container"])
    message:
        "{rule}: do variants phasing on {input.vcf}"
    shell:
        "whatshap phase -o {output.vcf} --reference {input.fasta} {params.extra} {input.vcf} {input.bam} &> {log} "

↔ input / output files

Rule parameters Key Value Description
input vcf "snv_indels/deepsomatic_t_only/{sample}_{type}.vcf.gz" variants to phase in VCF format
bam lambda wildcards: get_input_aligned_bam(wildcards, config)[0] BAM file with mapped reads to use for phasing
bai lambda wildcards: get_input_aligned_bam(wildcards, config)[1] BAM file index to use for phasing
fasta config.get("reference", {}).get("fasta", "") reference genome in FASTA format
output vcf "snv_indels/whatshap_phase/{sample}_{type}.phased.vcf.gz" phased variants in VCF format (gzipped)

🔧 Configuration

Software settings (config.yaml)

Key Type Description
benchmark_repeats integer set number of times benchmark should be repeated
container string name or path to docker/singularity container
extra string parameters that should be forwarded

Resources settings (resources.yaml)

Key Type Description
mem_mb integer max memory in MB to be available
mem_per_cpu integer memory in MB used per cpu
partition string partition to use on cluster
threads integer number of threads to be available
time string max execution time