I produced a bam file by aligning reads to a small set of synthetic sequences using bwa-mem.I am heavily filtering reads that are not paired and of a certain orientation.Applying the filtering, I get a few thousands of reads:samtools view -h $myfilebam | \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 -  | wc -lGives me 89502 reads.If I then pipe this into samtools mpileup, I get no results:samtools view -h $myfilebam | \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 -lReturns 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 $myfilebam | \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 -lReturns 1056.Any ideas why? My thinking was that it would work with --excl-flags 0.EDIT: substituting mpileup for depth does work, and prints out each position and the depth as expected.EDIT2: adding -q 0 to mpileup gives the same empty result.Thanks in advance
samtools mpileup empty when filtering out flags
bam;samtools;mpileup
By using -h in the samtools view command, you're including all the header lines in your word count. If you happen to have about 89500 reference sequences, then the lengths of those would all appear in the header and inflate the -h word count, but not the mpileup count. Try piping it through an additional samtools view (i.e. without -h) and see if the counts change:...samtools view -h -f32 -  | \samtools view | wc -lAlso, samtools mpileup by default only considers high-quality bases and concordant reads. Try adding a -A to your mpileup line (which stops anomalous read pairs from being discarded):...samtools mpileup -A -Q0 -B -d 999999 - | wc -l