DeepMod2 icon indicating copy to clipboard operation
DeepMod2 copied to clipboard

Encountering errors running aligned BAM files

Open tewing4 opened this issue 1 year ago • 6 comments

I am trying to call 5mc on a bacterial genome and I am encountering the error below. I have run this genome on a Gridion R.10 flowcell and performed the basecalling and alignment using MinKnow/Guppy

Error: 2025-01-14 15:20:24.492709: Starting Per Read Methylation Detection. 2025-01-14 15:20:24.580958: Getting motif positions from the reference. multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/scicomp/home-pure/otg1/miniconda3/envs/deepmod2/lib/python3.12/multiprocessing/pool.py", line 125, in worker result = (True, func(*args, **kwds)) ^^^^^^^^^^^^^^^^^^^ File "/scicomp/home-pure/otg1/miniconda3/envs/deepmod2/lib/python3.12/multiprocessing/pool.py", line 48, in mapstar return list(map(*args)) ^^^^^^^^^^^^^^^^ File "/scicomp/home-pure/otg1/DeepMod2/src/utils.py", line 275, in get_ref_info seq=ref_fasta.fetch(chrom).upper() ^^^^^^^^^^^^^^^^^^^^^^ File "pysam/libcfaidx.pyx", line 301, in pysam.libcfaidx.FastaFile.fetch KeyError: "sequence 'NC_000913.3' not present" """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/scicomp/home-pure/otg1/DeepMod2/deepmod2", line 172, in detect.call_manager(params) File "/scicomp/home-pure/otg1/DeepMod2/src/detect.py", line 741, in call_manager res=pool.map(get_ref_info, zip(repeat(params), params['chrom_list'])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/scicomp/home-pure/otg1/miniconda3/envs/deepmod2/lib/python3.12/multiprocessing/pool.py", line 367, in map return self._map_async(func, iterable, mapstar, chunksize).get() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/scicomp/home-pure/otg1/miniconda3/envs/deepmod2/lib/python3.12/multiprocessing/pool.py", line 774, in get raise self._value KeyError: "sequence 'NC_000913.3' not present"

I appreciate any help, thank you.

tewing4 avatar Jan 14 '25 20:01 tewing4

Hi,

It seems like your BAM file has a reference sequence named "NC_000913.3" in the BAM header, but this reference sequence is not found in the reference FASTA file that you supplied. Please make sure any reference sequence you want to find methylation for in the BAM file is also present in the FASTA file. Here are some options to fix this:

1- Use a reference FASTA file that contains all the reference sequences use for alignment in the BAM file. The reference sequence names should be same. 2- If there are particular chromosomes/contigs you want to assess that are in both FASTA and BAM header, you can provide the names of those chromosomes/contigs as --chrom parameter. This will fix any issues where a contig names in BAM header is not present in FASTA if you do not care about methylation in that contig. 3- Use DeepMod2 detect module without reference FASTA file provided as --ref parameter. It will produce a BAM file file modification tags, but it just wont use reference sequence as a feature in methylation calling.

Best, Umair

umahsn avatar Jan 15 '25 02:01 umahsn

Hi Umair,

Thank you for this response this was helpful and replacing the reference sequence with "NC_00913.3" did allow me to run the tool. However, the next issue I ran into was not having the move tables. I performed the sequencing run on a Gridion and then followed the run with basecalling/alignment through Minknow so I'm assuming that was performed on Dorado but I'm not sure. Do you know if I am able to retrospectively locate those move tables for the run or does that have to be done prior to run set up? or prior to analysis?

Thanks, Thomas

tewing4 avatar Jan 15 '25 14:01 tewing4

Hi Thomas,

I believe that Minknow does not allow move tables to be produced. In this case, you would need to rebasecall with Dorado and enable --emit-moves parameter. You would need a GPU to run Dorado however, and you can use the one inside Gridion if you do not have another available. In case if you don't want to rebasecall or dont have a GPU available, I would recommend using f5c, which can perform signal alignment without move table and can run on CPU.

You can follow the steps here for running DeepMod2. You would need to perform basecalling with move tables, perform alignment during basecalling or after, and then run DeepMod2. If you align reads during basecalling with Dorado then you can skip Step 2.

umahsn avatar Jan 15 '25 16:01 umahsn

Hi Umair,

I hope you've been well. I managed to re-basecall using the gpu on the Gridion but now im encountering a different error. Can you provide some guidance?

Image

Image

osee44 avatar Feb 19 '25 14:02 osee44

I am also getting a message stating: "Pausing input due to INPUT queue size limit. Signal_qsize=180" and that qsize jsut counts up. My output file does have processed reads though before the pause. "Number of reads processed: 20153" and that number is also increasing. Can I assume the process is working but pausing due to computational availability?

osee44 avatar Feb 19 '25 14:02 osee44

DeepMod2 has one process that reads the signal and bam file data and passes the data to model inference process. If there is a huge backlog in inference processes, DeepMod2 will pause reading more data in order to prevent out of memory error. This backlog is likely occurring due to slow inference as you mentioned, and can be fixed by using a GPU or using more threads (up to around 12 or 16) if you are working with CPUs only.

umahsn avatar Feb 21 '25 20:02 umahsn