CompEpigen / figeno

Tool for plotting sequencing data along genomic coordinates.
GNU General Public License v3.0
240 stars 8 forks source link

basemod_freq track: "tag MM not present" #3

Closed PemLange closed 4 months ago

PemLange commented 4 months ago

When I generate a figure including a basemod_freq track I get the following error message:

Traceback (most recent call last): File "/home/u/miniconda3/lib/python3.10/site-packages/figeno/gui/gui_browser.py", line 90, in run figeno_make(data) File "/home/u/miniconda3/lib/python3.10/site-packages/figeno/figeno.py", line 402, in figeno_make tp.draw() File "/home/u/miniconda3/lib/python3.10/site-packages/figeno/figeno.py", line 217, in draw self.draw_horizontal(self.output) File "/home/u/miniconda3/lib/python3.10/site-packages/figeno/figeno.py", line 262, in draw_horizontal t.draw(regions=self.regions,box=box,hmargin=hmargin) File "/home/u/miniconda3/lib/python3.10/site-packages/figeno/track_basemodfreq.py", line 33, in draw self.draw_region(regions[i][0],boxes[i]) File "/home/u/miniconda3/lib/python3.10/site-packages/figeno/track_basemodfreq.py", line 43, in draw_region self.draw_region_bam(region,box,bam_params) File "/home/u/miniconda3/lib/python3.10/site-packages/figeno/track_basemodfreq.py", line 80, in draw_region_bam dfs = [smooth_methylation(create_basemod_table_bam(reads_all,base,mod,region.chr,region.start-200,region.end+200,min_coverage=4,samfile=samfile,fix_hardclip=fix_hardclip),w=4,start=region.start,end=region.end)] File "/home/u/miniconda3/lib/python3.10/site-packages/figeno/track_basemodfreq.py", line 203, in create_basemod_table_bam methyl = decode_read_basemods(read,[(base,mod,1)],samfile,fix_hardclip) File "/home/u/miniconda3/lib/python3.10/site-packages/figeno/bam.py", line 399, in decode_read_basemods MMs = read.get_tag("MM").rstrip(";").split(";") File "pysam/libcalignedsegment.pyx", line 2507, in pysam.libcalignedsegment.AlignedSegment.get_tag File "pysam/libcalignedsegment.pyx", line 2546, in pysam.libcalignedsegment.AlignedSegment.get_tag KeyError: "tag 'MM' not present"

PemLange commented 4 months ago

Here is the config file:

figeno-config-test1.json

e-sollier commented 4 months ago

The basemod_freq track expects a bam file with MM and ML tags (which contain methylation information), which are apparently missing in your bam file. These tags should be included if you call methylation, eg with dorado/remora for ONT data. What processing did you do to get your bam file ?

PemLange commented 4 months ago

Thank you for your input! I was unfamiliar with the MM tag, because I used bwa-meth to generate bam files, which predates the MM tag. I then used MethylDackel to call methylation which gives me a bedGraph file. So I will try to create a bam file with MM tag or see if I can convert the bedGraph file to bedmethyl format.

e-sollier commented 4 months ago

For base modifications, figeno was mainly designed for ONT data (with MM/ML tags) and currently does not directly support bisulfite sequencing, unless you can find a way to add these tags. But if you have a bedgraph file, you can either convert it to bedmethyl, or, maybe easier, convert it to bigwig with bedGraphToBigWig and use a bigwig track.