Entering edit mode
4.7 years ago
wrab425
▴
50
I have been given the following command to extract unmapped reads from a bam file
samtools view -b -f 141 ${SAMPLE_ID}.ecoli.bwamem.bam > ${SAMPLE_ID}.unmapped_ecoli_2.bam
- I am unsure what the
-f
flag and141
means - Is it necessary to sort the bam file before running this command?
- I have consulted the samtools view manual and it is not clear why this command should extract unmapped reads.
Thanks
Thanks ATpoint, that was very helpful. I am just getting rid of contaminating reads that map to ecoli before mapping to my host genome so I do not think that I need to sort. Is that correct? I think your command is doing the same thing as mine and that if I use the o flag with a bam file then I do not need a b flag and the > sign. Is that correct?
Yes, this all sounds correct.