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
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
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
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.