Hello!
I am trying to filter my BAM file (paired-end read alignment) to 1) Remove pairs that did not map and 2) Contain reads where both reads mapped in their proper pair, and one read mapped but one did not (include the unmapped read if its pair mapped properly) 3) Minimum mapping quality of 10
I have been referring to these pages for for help:
The "Mate-Unmapped PeterpanWendy" reads are what I want: http://gatkforums.broadinstitute.org/gatk/discussion/7067/ahoy-mates-be-ye-unmapped
From these, it seems like I want -f 11 to keep: read paired, read mapped in proper pair, mate unmapped http://www.samformat.info/sam-format-flag http://broadinstitute.github.io/picard/explain-flags.html
Therefore, my samtools filtering command would look like this: samtools view -b -F 4 -f 11 -q 10 FILENAME
I am unsure of whether my interpretation of these filters is correct, and I am also not certain how to check my filtering. Possibly one way is to search the BAM (or SAM file) to see if one read mapped, its mate has a MAPQ of 0 with a * in the CIGAR field like GATK suggests the unmapped read has. Because I'm imposing a mapping quality threshold and removing unmapped reads, I want to be sure that I kept the unmapped mate.
Thank you so much! I appreciate your comments.
Alternatively
reformat.sh
from BBMap suite has following filter options that will help.