Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountering errors running aligned BAM files #32

Open
tewing4 opened this issue Jan 14, 2025 · 3 comments
Open

Encountering errors running aligned BAM files #32

tewing4 opened this issue Jan 14, 2025 · 3 comments

Comments

@tewing4
Copy link

tewing4 commented Jan 14, 2025

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.

@umahsn
Copy link
Collaborator

umahsn commented Jan 15, 2025

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

@tewing4
Copy link
Author

tewing4 commented Jan 15, 2025

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

@umahsn
Copy link
Collaborator

umahsn commented Jan 15, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants