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?
samtools extract unmapped reads
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
-fflag and141means - 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
• 4,886 views
•
link
1 answer
See this link that explains flags: http://broadinstitute.github.io/picard/explain-flags.html
For all unmapped reads do:
samtools view -f 4 -o ${SAMPLE_ID}.unmapped_ecoli_2.bam ${SAMPLE_ID}.ecoli.bwamem.bam
-f means keep and -F means do not keep so in the above command you keep only unmapped reads. Extraction of reads where both the read and the mate are unmapped would be -f 13 given it is paired-end.
You can then modify based on your needs with the linked tool that gives you the flags you want based on the read properties.
• 0 views
•
link
• 0 views
•
link
Yes, this all sounds correct.
• 0 views
•
link
Log in to answer this question.