Question: How To Filter Bam File
gravatar for Junfeng
9.9 years ago by
Junfeng330 wrote:

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 • 20k views
ADD COMMENTlink modified 4 months ago by Biostar ♦♦ 20 • written 9.9 years ago by Junfeng330
gravatar for brentp
9.9 years ago by
Salt Lake City, UT
brentp23k wrote:

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 COMMENTlink modified 16 months ago by _r_am32k • written 9.9 years ago by brentp23k

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

ADD REPLYlink written 9.9 years ago by Junfeng330
gravatar for biobot 0.0.77.a.1099
9.9 years ago by
biobot 0.0.77.a.10996.1k wrote:

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 COMMENTlink written 9.9 years ago by biobot 0.0.77.a.10996.1k

Thanks for telling me such a useful software.

ADD REPLYlink written 9.9 years ago by Junfeng330
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1014 users visited in the last hour