Thank you. Your answer is very useful, I will try it.
How To Filter Bam File
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.
• 27,650 views
•
link
2 answers
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.
• 1 views
•
link
• 0 views
•
link
Log in to answer this question.