How To Filter Reads With Bowtie ?
1
0
Entering edit mode
11.9 years ago
madkitty ▴ 690

We did an alignment with BWA and have 4 BAM files. How can I filter only mitochondria reads with Bowtie ?

bowtie • 4.2k views
ADD COMMENT
0
Entering edit mode

Are you working with BWA or bowtie?

ADD REPLY
0
Entering edit mode

I'm working with Bowtie :)

ADD REPLY
2
Entering edit mode
11.9 years ago
Arun 2.4k

EDIT: You should read the SAM format specification. The 3rd column tells the name of your chromosome in the reference. If ChrM is your mitochondrial chromosome name, and you want to merge filtered multiple bam (with corresponding .bai files available) files, then you could do:

samtools merge -r -h file1.bam -R ChrM ChrM_merged.bam *.bam

OLD REPLY:

samtools view my_file.bam | grep "ChrM" > mitochondria_alone.txt

samtools view decodes the binary sam file (bam file) for you and displays on screen. I write here .txt because, for it to be a sam format, you should have the header as well which you can obtain by

samtools view -H my_file.bam
ADD COMMENT
0
Entering edit mode

But we have 4 BAM files to search .. Is it gonna work If I type

samtools view file1.bam file2.bam file3.bam file4.bam | grep "ChrM" > mitochondria_alone.txt
ADD REPLY
0
Entering edit mode

Had to change the reply quite sometimes. Sorry about that. samtools merge is what you want. It has changed a little from the last time I used it.

ADD REPLY

Login before adding your answer.

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