Skip to content

iam28th/hap-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hap-counter.py

Given read alignments (in BAM format with haplotype tags) and a set of variants (in phased VCF format) computes support for ALT and REF alleles across reads assigned to individual haplotypes.

Installation

git clone git@github.com:iam28th/hap-counter.git --recurse-submodules
# submodules contain specification and test files, 
# omit if they are not necessary

cd hap-counter
python hap-counter.py --help

The only dependency is pysam, which can be installed with pip.

Usage

python hap-counter.py --bam alignments.bam --vcf variants.vcf

Assumes indexes (.bai for .bam and .tbi for .vcf) are present. Produces output in .tsv format, e.g.:

chrom   pos     h1_REF  h1_ALT  h2_REF  h2_ALT
chr16   28001380        11      4       3       12
chr16   28002343        11      5       3       12
chr16   28003017        12      4       3       13
chr16   28003087        12      4       3       11
chr16   28004800        13      4       3       9
...

where:

  • chrom - chromosome name
  • pos - position on chromosome
  • h<H>_<A> with H in {1,2} and A in {'ALT, 'REF'} (last 4 columns) - number of primary alignments with HP==H supporting allele A

Limitations

  • requires both .vcf and .bam files to be sorted by position
  • currently only calculates support for SNVs

About

Сompute support for ALT and REF alleles from aligned reads

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published