This is a test version of Biostars. For the public version, visit https://www.biostars.org.
samtools mpileup empty when filtering out flags

I have a bam file of alignments to a small synthetic set of sequences, and I am heavily filtering reads that are not paired and of a certain orientation. When I apply the filtering, samtools mpileup returns empty:

samtools view -h myfile.bam | \
samtools view -h -F4 - | \
samtools view -h -F8 - | \
samtools view -h -F256 - | \
samtools view -h -F512 - | \
samtools view -h -F1024 - | \
samtools view -h -F2048 - | \
samtools view -h -f16 - | \
samtools view -h -f32 -  | \
samtools mpileup --excl-flags 0 -Q0 -B -d 999999 - | wc -l

Returns 0.

I tried different combinations of filtering, and when I do both -f 16 and -f 32 returns empty, but if I do either of those, then it works:

samtools view -h myfile.bam | \
samtools view -h -F4 - | \
samtools view -h -F8 - | \
samtools view -h -F256 - | \
samtools view -h -F512 - | \
samtools view -h -F1024 - | \
samtools view -h -F2048 - | \
samtools view -h -f16 - | \
samtools mpileup --excl-flags 0 -Q0 -B -d 999999 - | wc -l

Returns 1056

Any ideas why? My thinking was that it would work with --excl-flags 0.

Thanks in advance

bam samtools mpileup

Cross-posted on the bioinfo stackexchange, where I've left a comment. BTW, you can skip all of the piping and have mpileup do all of the filtering.

0 answers

No answers yet.

Log in to answer this question.