WHATSHAP HAPLOTAG

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

Phase BAM records by haplotype. For more information about whatshap see whatshap documentation.

URL: https://github.com/whatshap/whatshap

Example

This wrapper can be used in the following way:

rule whatshap_haplotag:
    input:
        "phased.vcf.gz.tbi",
        "alignment.bam.bai",
        "reference.fasta.fai",
        vcf ="phased.vcf.gz",
        aln ="alignment.bam",
        ref = "reference.fasta"
    output:
        "alignment.phased.bam"
    params:
        extra="" # optionally use --ignore-linked-read, --tag-supplementary, etc.
    log:
        "logs/haplotag.10X.phased.log"
    threads: 4
    wrapper:
        "v3.9.0/bio/whatshap/haplotag"

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

  • whatshap=2.2

Input/Output

Input:

  • vcf: Path to vcf.gz/bcf file of phased SNPs.

  • Path to vcf index file (.tbi for vcf.gz, .csi for .bcf).

  • aln: Path to alignments for the sample in BAM/CRAM format.

  • Path to alignment index file in .bai/.crai format.

  • ref: Path to FASTA reference used to create vcf file.

  • Path to FASTA index file in .fai format

Output:

  • P

  • a

  • t

  • h

  • t

  • o

  • o

  • u

  • t

  • p

  • u

  • t

  • p

  • h

  • a

  • s

  • e

  • d

  • B

  • A

  • M

  • f

  • i

  • l

  • e

  • .

Params

  • extra: additional program arguments (e.g. –ignore-linked-read to ignore BX tag, –linked-read-distance-cutoff to set distance after which to split molecules with same BX tag, –ignore-read-groups, –sample SAMPLE to only phase this sample, –tag-supplementary to also tag supplementary alignments.

Authors

  • Pavel Dimens

Code

"""Snakemake wrapper for whatshap haplotag."""

__author__ = "Pavel Dimens"
__copyright__ = "Copyright 2023, Pavel Dimens"
__email__ = "pdimens@gmail.com"
__license__ = "MIT"

from snakemake.shell import shell

extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=False, stderr=True)

shell(
    "whatshap haplotag"
    "{extra} "
    "--output-threads={snakemake.threads} "
    "-o {snakemake.output} "
    "--reference {snakemake.input.ref} "
    "{snakemake.input.vcf} "
    "{snakemake.input.aln} "
    "{log}"
)