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

How to discard alignments from SAM/BAM file that have mismatches #1076

Closed
mahmad37 opened this issue Jun 24, 2023 · 2 comments
Closed

How to discard alignments from SAM/BAM file that have mismatches #1076

mahmad37 opened this issue Jun 24, 2023 · 2 comments
Labels

Comments

@mahmad37
Copy link

Hi,

I have sequenced the mRNA of a heterologous library expressed in human cells using nanopore. Then I mapped the reads from the fastq files to the reference database of the library using the minimap.

Then I filtered the SAM file to retain the primary reads with high mapping quality. After this, I visualised the BAM file in IGV:

igv_snapshot

As you can see there are some reads having mismatches to the reference database. I checked even the highest mapping quality reads are having mismatches. While I am guessing that these reads are mapping to more than one variant in the library dataset, I am looking for a command line that I could use to discard such alignments from SAM/BAM file. Unlike the BWA aligner, the minimap does not generate the MD (Mismatching positions/bases) & XM (Number of mismatches in the alignment) flags in the SAM file. It generates the NM:i flag that informs about the mismatches and INDELS together, so this is not really helpful as I am just looking to discard alignments with mismatches.

I would really appreciate the help to discard alignments with mismatches from SAM/BAM file (better if I can also give a mismatch threshold). Thanks alot.

@rob-p
Copy link

rob-p commented Jun 24, 2023

You can pass —-MD to minimap2 during alignment if you want it to generate those tags. See the man page for further details.

Best,
Rob

@lh3
Copy link
Owner

lh3 commented Jun 25, 2023

Thanks, Rob!

@lh3 lh3 closed this as completed Jun 25, 2023
@lh3 lh3 added the question label Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants