I'm trying to determine the best way to extract unmapped reads in which both mates in a pair did not map. Currently, it seems that my code is simply extracting all unmapped reads, regardless of their mate. I'm not sure how to go about this, as I'm already using the -f option to extract unmapped reads. Would I just do another iteration of samtools view?
samtools view -@ 4 -buh -f4 sample${r}_pe.remove.sam > sample${r}_pe.unmapped.bam