Question: Is the order of records in the bam file produced by bwa the same as the order in the input fastq file?
2
gravatar for Lina F
3.8 years ago by
Lina F150
Boston, MA
Lina F150 wrote:

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

sampe bwa fastq mem aln • 2.0k views
ADD COMMENTlink modified 3.7 years ago by lh331k • written 3.8 years ago by Lina F150
4
gravatar for lh3
3.7 years ago by
lh331k
United States
lh331k wrote:

Yes, the same.

ADD COMMENTlink written 3.7 years ago by lh331k
0
gravatar for Renesh
3.8 years ago by
Renesh1.3k
United States
Renesh1.3k wrote:

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 written 3.8 years ago by Renesh1.3k
1

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 REPLYlink written 3.8 years ago by Devon Ryan81k

I apologize for any mistaken assumption. 

ADD REPLYlink written 3.7 years ago by Renesh1.3k

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

ADD REPLYlink written 3.7 years ago by Devon Ryan81k
0
gravatar for Lina F
3.7 years ago by
Lina F150
Boston, MA
Lina F150 wrote:

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 written 3.7 years ago by Lina F150

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 written 3.7 years ago by dariober9.3k

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 written 3.7 years ago by Lina F150
Please log in to add an answer.

Help
Access

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