Question: BWA: Read flagged as unmapped, but mate says mate is mapped.
gravatar for i.sudbery
4 months ago by
Sheffield, UK
i.sudbery3.8k wrote:

I have mapped a paired end file against a list of elements I'd like to filter out of my reads using BWA, and then tried to extract the unmapped reads using samtools view -f12 my_bam.bam | samtools fastq -1 reads1.fastq -2 reads2.fastq

However I'm getting different numbers of reads in the two files. Looking at what was present in one, but not the other, I come accross this pair:

ST-E00192:703:HMV2VCCXY:4:2208:20202:1362 77 ENSG00000207113|ENST00000384385 114 37 9M1I8M = 114 0 TTTTAAAAGATGGGGTCT AAFFFJJJJJJJJJJAJJ XT:A:U NM:i:2 SM:i:37 AM:i:0 X0:i:1 X1:i:0 XM:i:1XO:i:1 XG:i:1 MD:Z:13C3
ST-E00192:703:HMV2VCCXY:4:2208:20202:1362 133 ENSG00000207113|ENST00000384385 114 0 * = 114 0 NGACCCCATCTTTTAAAA #A<AAA<J7FJFJJAJJJ

The flag for the first read (77) is read_paired, read_unmapped, mate_unmapped, first_in_pair.

The flag for the second read is read_paired, read_unmapped, second_in_pair.

Note that "mate_unmapped" is missing for the second read, dispite the fact is has no mate information, while the first read says it is unmapped, despite have a location, only 2 mismatches and not mapping anywhere else.

Any ideas?

bwa • 215 views
ADD COMMENTlink modified 4 months ago by t.kuilman720 • written 4 months ago by i.sudbery3.8k
gravatar for swbarnes2
4 months ago by
United States
swbarnes24.8k wrote:

Bwa will count a read as 'unmapped' if it hangs off of one reference sequence onto another. Check to see if that's what's happening.

ADD COMMENTlink written 4 months ago by swbarnes24.8k

So this is what is happening, the first read extends off the end of a contig. But how come the flags for the second read says that the first read is mapped?

ADD REPLYlink written 4 months ago by i.sudbery3.8k

Well, it pretty much is mapped. It has a mapping location, after all.

ADD REPLYlink written 4 months ago by swbarnes24.8k

But I would expect the flags on the two reads to match. In anycase, any ideas how I extract unmapped pairs of reads from the BAM file?

ADD REPLYlink written 4 months ago by i.sudbery3.8k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1723 users visited in the last hour