Sniffles2 Documentation

repository·master·Indexed 20 days ago

https://github.com/fritzsedlazeck/sniffles

A high-performance structural variant (SV) caller for long-read sequencing data from PacBio and Oxford Nanopore. Sniffles2 supports germline, somatic (mosaic), and population-level SV calling. It provides tools for genotyping known SVs from VCF files and supports input formats including .bam, .cram, .snf, and .tsv, with outputs in .vcf and .snf formats.

Tokens
6.5K
Snippets
23
Records
38
Agent score
72%

What's inside Sniffles2

  1. Install Sniffles2 via pip or conda

    master

    You can install Sniffles2 using either pip or conda. If you are upgrading from Sniffles1 installed via conda, use the update command.

    # Using pip
    pip install sniffles
    
    # Using conda
    conda install sniffles=2.8.0
    
    # Upgrading from Sniffles1 via conda
    conda update sniffles=2.8.0
  2. Genotype a known set of SVs (Force Calling)

    master

    To determine the genotype of a specific set of SVs from an existing VCF file for a given sample, use the --genotype-vcf option.

    sniffles --input sample.bam --genotype-vcf input_known_svs.vcf --vcf output_genotypes.vcf
  3. Perform multi-sample SV calling (Population mode)

    master

    Multi-sample calling is a two-step process. First, generate .snf files for each individual sample. Second, combine those files into a single multi-sample VCF.

    Step 1: Create .snf files for each sample sniffles --input <sample>.bam --snf <sample>.snf

    Step 2: Combine files You can combine files by listing them individually or by providing a .tsv file containing a list of .snf files (and optional custom sample IDs in a second column).

    # Step 1: Generate .snf files
    sniffles --input sample1.bam --snf sample1.snf
    sniffles --input sample2.bam --snf sample2.snf
    
    # Step 2a: Combine using individual .snf files
    sniffles --input sample1.snf sample2.snf --vcf multisample.vcf
    
    # Step 2b: Combine using a .tsv list
    sniffles --input snf_files_list.tsv --vcf multisample.vcf
  4. How Sniffles2 handles phased genotypes

    master

    When phasing is enabled in the configuration (config.phase), Sniffles2 modifies the VCF output in two ways:

    1. Genotype Separator: The genotype separator changes from / (unphased) to | (phased) if the haplotype information is available.
    2. PS Tag: The PS (Phase-block) tag is added to the FORMAT column.

    Phasing logic uses hp_i (the index of the haplotype in config.phase_identifiers) to determine the orientation of the phased genotype (e.g., 1|0 vs 0|1).

  5. Configure Mosaic SV calling

    master

    Mosaic mode is activated if mosaic_include_germline is set. When in mosaic mode, Sniffles2 adjusts several QC and clustering parameters:

    • qc_nm_measure: Uses mosaic_qc_nm if the standard qc_nm is not provided.
    • cluster_merge_len: Uses default_cluster_merge_len_mosaic if the current cluster_merge_len matches the standard default_cluster_merge_len.
  6. Specialized genotyping logic by SV type

    master

    Sniffles2 applies different coverage and support calculation strategies depending on the type of Structural Variant (SV) to ensure accuracy:

    SV TypeGenotyper ClassCoverage Calculation Strategy
    INS (Insertion)InsertionGenotyperUses rescale_support to handle long insertions and focuses on coverage_center.
    DEL (Deletion)DeletionGenotyperUses coverage_start, center, and end, potentially offset by SUPPORT_SA if available.
    DUP (Duplication)DuplicationGenotyperUses coverage_start and coverage_end plus a factor of support (support * 0.75).
    INV (Inversion)InversionGenotyperUses coverage_upstream and coverage_downstream plus a factor of support (support * 0.5).
  7. How Sniffles2 calculates genotypes and quality

    master

    Sniffles2 uses a binomial probability model to estimate the likelihood of different genotypes (homozygous reference (0, 0), heterozygous (0, 1), and homozygous variant (1, 1)).

    Key aspects of the calculation:

    • Likelihoods: It calculates binomial probabilities based on support (variant reads) and coverage (total reads spanning the SV).
    • Normalization: To prevent overflow, support and coverage are normalized to a target of 250 if they exceed it.
    • Genotype Quality (GQ): Calculated as a log10 likelihood ratio between the best and second-best genotype, capped at 60.
    • Z-score: A score used to filter calls, calculated from the likelihood ratio of the homozygous reference genotype vs the best genotype.
    • Configuration Dependencies: The calculation relies on config.genotype_error (probability of error) and config.genotype_ploidy to determine the expected probabilities for each genotype.
  8. Perform multi-sample SV calling

    master

    Multi-sample calling is a two-step process:

    1. Generate SNF files: Run Sniffles2 for each individual sample using the --snf flag to produce a .snf file containing SV candidates.
    2. Combined calling: Run Sniffles2 using the generated .snf files as input to produce a combined VCF.

    You can provide multiple .snf files directly or use a .tsv file containing a list of .snf files (one per line).

    # Step 1: Create .snf for each sample
    sniffles --input sample1.bam --snf sample1.snf
    sniffles --input sample2.bam --snf sample2.snf
    
    # Step 2: Combined calling
    sniffles --input sample1.snf sample2.snf --vcf multisample.vcf
  9. Configure Genotyping parameters

    master

    When genotyping known structural variants, you can configure the output format and ploidy.

    • genotype_format: The VCF format string used for genotype information. The default is "GT:GQ:DR:DV".
    • genotype_ploidy: Specifies the ploidy of the sample. Note: Currently only --genotype-ploidy 2 is supported.
    • genotype_min_z_score: The minimum Z-score required for genotyping.
    # Example genotyping command
    sniffles --genotype-ploidy 2 --genotype-format "GT:GQ:DR:DV" ...
  10. Configure Consensus parameters

    master

    Consensus calling is governed by several parameters that define how k-mers are used to validate variants:

    • consensus_min_reads: Minimum reads required for consensus (default: 4).
    • consensus_kmer_len: Length of the k-mer (default: 6).
    • consensus_kmer_skip_base: Number of bases to skip between k-mers (default: 3).
    • consensus_kmer_skip_seqlen_mult: Multiplier for skipping based on sequence length (default: 1.0 / 500.0).
    • consensus_low_threshold: Threshold for low-confidence consensus (default: 0.0).