rrazaghi / modbamtools

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

error running modbamtools #9

Closed DiegoZavallo closed 2 years ago

DiegoZavallo commented 2 years ago

Hi! I´m trying to run modbamtools with my megalodon output to vizualize the data, but Iḿ getting some errors and I don´t spot the issue.

modbamtools plot -r CM039687.1:2914823-19333007 -bd ./modbamtools/ -o ./modbamtools/ ./modbamtools/mod_mappings_sorted.bam This is my code, and in the modbamtools/ folder I have the bam file (with its .csi index file), the modified_bases.5mC.bed and also a modified_bases.5mC.bedgraph which I parsed from the bed file.

I get this error.

Traceback (most recent call last):
  File "/usr/local/bin/modbamtools", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/modbamtools/cli.py", line 300, in plot
    fig = Plotter(
  File "/usr/local/lib/python3.8/dist-packages/modbamtools/modbamviz.py", line 36, in __init__
    self.tracks, self.num_tracks = get_tracks(
  File "/usr/local/lib/python3.8/dist-packages/modbamtools/tracks.py", line 235, in get_tracks
    b = parse_bedgraph(bedgraph, chrom, start, end)
  File "/usr/local/lib/python3.8/dist-packages/modbamtools/tracks.py", line 27, in parse_bedgraph
    with open(bedgraph_path) as b:
IsADirectoryError: [Errno 21] Is a directory: './modbamtools/'

I quite lost with the PATH options, maybe Iḿ run it wrong.

Could your give any hint?

Thanks!

rrazaghi commented 2 years ago

Hi!

option -bd should be used with a path to a bedgraph format file but you are providing a path to a directory. However if you are trying to point to megalodon bed files, that is unnecessary as modbamtools automatically plots methylation frequency on top of the single read plots. Let me know if that works!

DiegoZavallo commented 2 years ago

Ohhh, so I just could run it with the .bam file like this:

modbamtools plot -r CM039687.1:2914823-19333007 -o ./modbamtools/ ./modbamtools/mod_mappings_sorted.bam

Because I did, but my RAM can´t handle it. After a wile the process kiled. I have 16Gb, could it be because the range I selected is to wide? like 18 Mbs?

DiegoZavallo commented 2 years ago

Hi! As expected I selected a shorter window and run just fine! Thanks! Let me ask you another question. Is it possible to plot two samples (i.e. two genotypes) in the same plot? What do you recommend for the downstream analysis like find DMRs between experiments?

Thanks again

rrazaghi commented 2 years ago

yes you can! just do modbamtools plot options bam1.bam bam2.bam ... you can change the sample names to whatever you want with --samples option.

as far as DMR detection, this is something I am actively working on but it's not available yet. you could potentially use megalodon bed files with other tools to find DMRs in the meantime

DiegoZavallo commented 2 years ago

Hi! Great! Thanks for the replay! Late night yesterday I run the modbamtools calcMeth and it run till morning (8hrs aprox) and then the RAM colapse and kill the processes. Could it take that long? is because have to calculate de methylation on all the bed file (all the genome?)

modbamtools calcMeth -t 10 -o ./modbamtools/ -b ./modbamtools/modified_bases.5mC.bed ./modbamtools/mod_mappings_sorted.bam

rrazaghi commented 2 years ago

you are using the megalodon single CpGs bed file as an input for the regions for calcMeth which does not make that much sense. It has to calculate for thousands of single sites which is why resulted in RAM max out. You'd need to provide a bed file with regions of interest (promoter regions for example).

DiegoZavallo commented 2 years ago

Ohh, you are right!!! My bad. I don´t have an annotation file for this organism (a grass), but I think I could "make" a file with region of interest.

Is it possible that the plot also display others methylation contexts? like CHG and CHH (very important in plants?) Or the bam file don´t have that information? I think I have read on one of the megalodon issues that is something the want to adress.

An another quick question, what are representing the colors of the reads on the plot?

thanks a lot!

Diego

rrazaghi commented 2 years ago

there is an all context 5mC model available for megalodon or guppy/bonito that you can use.

Red color represents methylated bases and blue represents unmethylated bases.