Question: How To Filter Reads With Bowtie ?
0
gravatar for madkitty
7.1 years ago by
madkitty580
Canada
madkitty580 wrote:

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

bowtie • 2.6k views
ADD COMMENTlink written 7.1 years ago by madkitty580

Are you working with BWA or bowtie?

ADD REPLYlink written 7.1 years ago by Arun2.3k

I'm working with Bowtie :)

ADD REPLYlink written 7.1 years ago by madkitty580
2
gravatar for Arun
7.1 years ago by
Arun2.3k
Germany
Arun2.3k wrote:

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 COMMENTlink modified 7.1 years ago • written 7.1 years ago by Arun2.3k

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 REPLYlink written 7.1 years ago by madkitty580

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 REPLYlink written 7.1 years ago by Arun2.3k
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: 831 users visited in the last hour