I'm trying to extract the unmapped reads that appear in the "*" region when samtools idxstats is run. However, when I run samtools view -b [filename] '*' and then convert to a fastq using samtools bam2fq, the resulting fastq file is empty, and I get the message that 0 reads were processed. However, samtools idxstats definitely shows that there were unmapped reads under "*". Did I extract the reads incorrectly? If not, what else could be the problem? Thanks in advance!
Doing
samtools view -f 4 foo.bam | samtools bam2fq -
may be better.Thanks for the feedback. I'm aware of that flag and will use it if necessary, but I'd love to make my original command work as it would be much more efficient. Is there any way this could be possible?
I am not sure what version of
samtools
you are using butsamtools view -b [filename] '*'
does not work for me withsamtools v. 1.8
.The related bug report is here, that should work provided the unmapped reads don't have mapped mates.
In which way would that be much more efficient?
It would only go through the reads classified with '*' rather than the entire genome, thus drastically reducing the number of reads to search
Interesting, I didn't think of it that way. However, you will miss "placed unmapped" reads when you do it like that.
Edit: formatting