jts / nanopolish

Signal-level algorithms for MinION data
MIT License
559 stars 159 forks source link

methylation tsv file from modified bam? #1094

Open lkerr34 opened 1 year ago

lkerr34 commented 1 year ago

Hi,

I know Nanopolish can output both tsv and modified bam when calling methylation but I wondered if you had (or knew of any) available scripts that would convert modified bam files into the Nanopolish tsv format? The repository https://github.com/jts/mbtools/tree/main seems to have scripts that provide methylation frequency information from modified bam files. However, I can't find anything that will take a modified bam and output the type of tsv file outputted by Nanopolish, where methylation information is given for each CpG independently in each read.

Thanks for providing such great software!

jts commented 1 year ago

Sorry @lkerr34 but I don't have a script to convert in that direction. If you have experience in python though, you might want to take a look at pysam's support for the base modification API as you could do the conversion using it:

https://pysam.readthedocs.io/en/latest/api.html#pysam.AlignedSegment.modified_bases

lkerr34 commented 1 year ago

Thanks for the suggestion - I really appreciate it!