rrazaghi / modbamtools

Set of tools to manipulate and visualize modified base bam files
Apache License 2.0
49 stars 4 forks source link

ValueError: If mode is 'interp', window_length must be less than or equal to the size of x. #14

Closed biorococo closed 2 years ago

biorococo commented 2 years ago

Hi,

I'm getting the following error when using modbamtools, version 0.4.3:

[E::bam_parse_basemod] Insufficient number of entries in ML tag [E::bam_parse_basemod] Insufficient number of entries in ML tag Traceback (most recent call last): File "modbamtools_env/bin/modbamtools", line 8, in sys.exit(cli()) File "modbamtools_env/lib/python3.8/site-packages/click/core.py", line 1128, in call return self.main(args, kwargs) File "modbamtools_env/lib/python3.8/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "modbamtools_env/lib/python3.8/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "modbamtools_env/lib/python3.8/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, ctx.params) File "modbamtools_env/lib/python3.8/site-packages/click/core.py", line 754, in invoke return __callback(args, **kwargs) File "modbamtools_env/lib/python3.8/site-packages/modbamtools/cli.py", line 300, in plot fig = Plotter( File "/modbamtools_env/lib/python3.8/site-packages/modbamtools/modbamviz.py", line 36, in init self.tracks, self.num_tracks = get_tracks( File "modbamtools_env/lib/python3.8/site-packages/modbamtools/tracks.py", line 267, in get_tracks freq_traces, single_read_traces, het_traces = make_modbam_trace( File "modbamtools_env/lib/python3.8/site-packages/modbamtools/tracks.py", line 176, in make_modbam_trace freq = plot_frequencies(sample_dict, start, end, color=colors[i]) File "modbamtools_env/lib/python3.8/site-packages/modbamtools/tracks.py", line 71, in plot_frequencies freq, freq_smooth = calc_freq(dict_per_read_mod, start, end) File "modbamtools_env/lib/python3.8/site-packages/modbamtools/utils.py", line 78, in calc_freq freq_smooth["y"] = savgol_filter(freq["y"], window, poly) File "modbamtools_env/lib/python3.8/site-packages/scipy/signal/_savitzky_golay.py", line 339, in savgol_filter raise ValueError("If mode is 'interp', window_length must be less " ValueError: If mode is 'interp', window_length must be less than or equal to the size of x.

The command used is the following: modbamtools plot --region chr2:25227609-25230989 --out modbamplot -tr "test" --can_prob 0.2 --mod_prob 0.8 --samples test --fmt pdf -p test test_files/test.bam

I'm attaching the BAM file in case is useful: test_files.tar.gz

Thanks!

rrazaghi commented 2 years ago

Hi! I can reproduce this but I'm concerned about the [E::bam_parse_basemod] Insufficient number of entries in ML tag This error is from the htslib parse API so my guess is the file is corrupt or the methylation caller is not adapted to the latest format. Do you know the methylation caller and its version?

biorococo commented 2 years ago

Hi, thanks for the quick reply!

I have had no problems with other downstream analysis using this mod BAM files. Do you think this can be related to the new mod tags specification allowing for "?" in the Mm tag (see section 1.7 here: https://samtools.github.io/hts-specs/SAMtags.pdf)?

Is the only difference I can see with previous BAM files processed with modbamtools.

rrazaghi commented 2 years ago

Ah right! I just bumped the API version in modbamtools v0.4.4 and now it works. let me know if you still have issues!

biorococo commented 2 years ago

Working perfect now! :) Thank you very much!

rainwala commented 1 year ago

Hello, I get this error now. Using pip, it seems i can only instal;l version 0.2.2 . How can I install version 0.4.4 or 0.4.8?