Question: bwa mem on a bam file
0
gravatar for vimartin
3.8 years ago by
vimartin30
France
vimartin30 wrote:

Hi,

I'm trying to use bwa mem for the first time and I wonder, is it possible to run it on a bam file instead of a fastq file? I noticed that bwa aln can be runned on bam file using '-b' but this option is invalid for bwa mem. The manual does not mention whether it is possible or not. I tried to simply run bwa mem on bam file and the output seems to be a header only sam file.

Does anyone has experience on the question?

 

Thanks in advance.

 

bam ngs bwa-mem • 5.1k views
ADD COMMENTlink modified 2.5 years ago by Biostar ♦♦ 20 • written 3.8 years ago by vimartin30
3
gravatar for vimartin
3.8 years ago by
vimartin30
France
vimartin30 wrote:

Ok, I should have wait I guess. Finally I found the answer which is : no.  This was detailed in the mail archive announcing the release of bwa mem. I put it as an answer in case someone else ask himself the same question.

http://sourceforge.net/p/bio-bwa/mailman/message/30527151/

ADD COMMENTlink written 3.8 years ago by vimartin30
2

you could try piping samtools fastq (former samtools bam2fq) to bwa and save both disk and time:

samtools fastq reads.bam | bwa mem ref.fa -

note: this works only for non-paired-end reads.

ADD REPLYlink modified 4 weeks ago • written 22 months ago by Jorge Amigo11k

Nice solution, but are you sure the -p parameter works well? Does bwa correctly pairs the paired end if they come from the stdin ? Have you tested it?

ADD REPLYlink modified 5 weeks ago • written 5 weeks ago by rgiannico90

from bwa manual page:

If -p is used, the command assumes the 2i-th and the (2i+1)-th read in reads.fq constitute a read pair (such input file is said to be interleaved)

but unfortunately samtools fastq does not output interleaved reads.

you can either try sorting reads by name BEFORE fastq generation:

samtools sort -n reads.bam | samtools fastq - | bwa mem -p ref.fa -

or you can either try sorting reads by name AFTER fastq generation (which is slightly faster):

samtools fastq reads.bam | paste - - - - | sort -k1,1 -S 3G | tr '\t' '\n' | bwa mem -p ref.fa -
ADD REPLYlink modified 4 weeks ago • written 4 weeks ago by Jorge Amigo11k
1

you could use samtofastq from Picard to convert your bam to fastq prior BWA mem alignment.

ADD REPLYlink written 3.8 years ago by Nicolas Rosewick7.2k
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: 1716 users visited in the last hour