Biostar Beta. Not for public use.
Is the order of records in the bam file produced by bwa the same as the order in the input fastq file?
2
Entering edit mode
6.2 years ago
Lina F • 150
@Lina F14166

Hi all,

I was wondering if the order of records in a bamfile produced by bwa aln/mem/sampe is guaranteed to be the same as in the fastq files that were used as input.

I checked the bwa manual but the only thing I found is this: "Repetitive read pairs will be placed randomly" (part of sampe description).

If anyone has an idea, I'd welcome your feedback!

Best,
~Lina

bwa aln mem sampe fastq • 2.4k views
ADD COMMENTlink
4
Entering edit mode
6.2 years ago
lh3 31k
@lh310932

Yes, the same.

ADD COMMENTlink
0
Entering edit mode
6.2 years ago
Renesh ♦ 1.6k
@Renesh13393

Not necessarily. Sometime this can be in sorted in target mapping position. You can check this easily by command;

samtools view file.bam

ADD COMMENTlink
1
Entering edit mode

bwa won't coordinate-sort for you. It's possible that the default output order matches the input. One would just need to compare an input and output to see. If it doesn't and https://www.biostars.org/u/14166/ needs that, then bowtie2 with the --reorder option will work.

ADD REPLYlink
0
Entering edit mode

I apologize for any mistaken assumption.

ADD REPLYlink
0
Entering edit mode

No worries, https://www.biostars.org/u/10932/ just replied anyway and he's obviously the definitive source on this sort of thing :)

ADD REPLYlink
0
Entering edit mode
6.2 years ago
Lina F • 150
@Lina F14166

Thanks for the feedback!

It looks like the default order matches the input for my data, but I just wanted to find out if that is guaranteed by bwa. To be on the safe side, I'll assume it's not guaranteed.

ADD COMMENTlink
0
Entering edit mode

A wild guess without having checked anything...: If bwa runs on one thread then output order = input order. If bwa runs on multiple threads input and output orders might differ.

ADD REPLYlink
0
Entering edit mode

sounds reasonable! Currently I'm running bwa on a single thread but I might have to move to more than one in the future...

ADD REPLYlink

Login before adding your answer.

Similar Posts
Loading Similar Posts
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.3