Mapping BAM/SAM file back to reference?!?!
0
2
Entering edit mode
6.6 years ago
ab.tsubaki ▴ 50

Hi all

So I have used BWA to align fastq files (mate pair, Illumina HiSeq) to a reference sequence. I then extracted the unmapped reads using samtools which gives me a bam file.

 

I would like to take this bam file and map it back to my reference sequence using BWA again. However bam files don't seem compatible - I do get an output sam file but the flagstat and other downstream tests then do not work. I have tried converting the bam to fastq and to fasta, same story. Though I get an output sam file from BWA alignment, I can either not visualize the sam file or downstream tests yield no results?

 

Is there something I'm missing here? Is it the paired end reads that are messing things up? Has anyone done something like this before?

 

Thanks!

BWA BAM SAM reference • 2.6k views
ADD COMMENT
2
Entering edit mode

If you use bwa, you should run bamshuf first.

ADD REPLY
0
Entering edit mode

Oh good point lh3!
I remember reading somewhere than in some tools you have to shuffle the reads but also sort them by name so the pairs are together in the BAM file (but pairs are still randomly distributed). Im not sure if that's still required by bedtools's bamtofastq or other tools these days. Do you know anything about that? It's been a while since I did a bam -> fastq.

ADD REPLY
2
Entering edit mode

Bamshuf groups reads by names. Bwa reads a batch of reads and infers insert size distribution from the batch. When input reads are coordinate sorted, the inference is inaccurate and sometimes may fail. For bwa, it is important to use bamshuf. Those bam2fastq won't work well.

ADD REPLY
1
Entering edit mode

As a quick caveat, bamshuf has been renamed to collate in samtools. This is what I needed as well! Thanks!

ADD REPLY

Login before adding your answer.

Traffic: 779 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