This is a test version of Biostars. For the public version, visit https://www.biostars.org.
ref and alt allele count from BAM file

Hi All,

I would like to calculate the allele ratio of ref/alt at a specific position. How can I determine the ref and alt counts from the BAM file? (or is it better to extract this info from the VCF?)

Thank you

rna-seq allele_count bam

1 answer

Both BAM and VCF can be used for this. In VCF, you would be looking for the values in the AD field for each sample. For BAM, you may want to consider using PySAM's pileup engine to query the position and reads stacked at that position. Just be careful with indels when using PySAM, you'll have to add special code to distinguish no coverage and deletions at these positions.

To tap into VCF, use PyVCF

https://pyvcf.readthedocs.io/en/latest/

To tap into BAM, use PySAM

https://pysam.readthedocs.io/en/latest/

Log in to answer this question.