Is the order of records in the bam file produced by bwa the same as the order in the input fastq file?
3
3
Entering edit mode
10.1 years ago
Lina F ▴ 200

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

mem fastq bwa aln sampe • 4.6k views
ADD COMMENT
4
Entering edit mode
10.1 years ago
lh3 33k

Yes, the same.

ADD COMMENT
0
Entering edit mode
10.1 years ago
Renesh ★ 2.2k

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

samtools view file.bam
ADD COMMENT
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 Lina F needs that, then bowtie2 with the --reorder option will work.

ADD REPLY
0
Entering edit mode

I apologize for any mistaken assumption.

ADD REPLY
0
Entering edit mode

No worries, lh3 just replied anyway and he's obviously the definitive source on this sort of thing :)

ADD REPLY
0
Entering edit mode
10.1 years ago
Lina F ▴ 200

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 COMMENT
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 REPLY
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 REPLY

Login before adding your answer.

Traffic: 1709 users visited in the last hour
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.6