How To Filter Bam File
2
8
Entering edit mode
13.8 years ago
Junfeng ▴ 330

Hi, I have one BAM file which contains all alignments (include those not used in variant calling, such as non-PF, non-mapping and duplicate reads) generated for an assembly. How to filter these useless mapping? I know that Picard MarkDuplicates can be used to remove duplicates.Thank you.

filter • 26k views
ADD COMMENT
17
Entering edit mode
13.8 years ago
brentp 24k

You can use samtools to do this. e.g. to remove reads that did not align, you can do:

samtools view -F 0x04 -b in.bam > out.aligned.bam

to only include paired reads, use:

-f 0x02

Check the other bitwise flags on this page.

But you might not want to exclude those as they could be used for finding structural variations.

ADD COMMENT
0
Entering edit mode

Thank you. Your answer is very useful, I will try it.

ADD REPLY
2
Entering edit mode
13.8 years ago

The bamtools package offers a wide range of filters, including user-definable filters defined in JSON notation. It includes filters for reads failing vendor QC, unmapped reads and pre-marked duplicates.

ADD COMMENT
0
Entering edit mode

Thanks for telling me such a useful software.

ADD REPLY

Login before adding your answer.

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