CNVKIT CALL

https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/cnvkit/call?label=version%20update%20pull%20requests

Given segmented log2 ratio estimates (.cns), derive each segment’s absolute integer copy number.

URL: https://cnvkit.readthedocs.io/en/stable/pipeline.html#call

Example

This wrapper can be used in the following way:

rule cnvkit_call:
    input:
        segment="test.cns",
        vcf="test.vcf",
    output:
        segment="test.call.cns",
    log:
        "logs/test.call.cns.log",
    params:
        extra = "" # optional
    wrapper:
        "v3.8.0-1-g149ef14/bio/cnvkit/call"

Note that input, output and log file paths can be chosen freely.

When running with

snakemake --use-conda

the software dependencies will be automatically deployed into an isolated environment before execution.

Software dependencies

  • cnvkit=0.9.10

Input/Output

Input:

  • segments: Copy ratios (.cnr or .cns)

  • vcf: VCF file name containing variants for calculation of b-allele frequencies

Output:

  • segments: Output table file name (CNR-like table of segments, .cns)

Params

  • filter: Merge segments flagged by the specified filter(s) with the adjacent segment(s), optional

  • purity: purity value of the tumor

  • ploidy: Ploidy of the sample cells.

  • extra: additional parameters that will be forwarded to cnvkit call

Authors

  • Patrik Smeds

Code

__author__ = "Patrik Smeds"
__copyright__ = "Copyright 2023, Patrik Smeds"
__email__ = "patrik.smeds@gmail.com"
__license__ = "MIT"

from snakemake.shell import shell

log = snakemake.log_fmt_shell(stdout=False, stderr=True)

vcf = snakemake.input.get("vcf", "")
if vcf:
    vcf = f"-v {vcf}"

purity = snakemake.params.get("purity", "")
if purity:
    purity = f"--purity {purity}"

ploidy = snakemake.params.get("ploidy", "")
if ploidy:
    ploidy = f"--ploidy {ploidy}"

filter = snakemake.params.get("filter", "")
if filter:
    filter = "--filter {filter}"

extra = snakemake.params.get("extra", "")

shell(
    "(cnvkit.py call {snakemake.input.segment} "
    "{vcf} "
    "-o {snakemake.output.segment} "
    "{purity} "
    "{ploidy} "
    "{filter} "
    "{extra}) "
    "{log}"
)