When I use Samtools (v1.7 or v.1.10) mpileup with -l option to specify the positions I want, many REF bases are incorrect. When I use the -r command (in addition to -l), however, I get the correct bases.
For instance, I use these two commands to test consistency between using the -l vs -r options (just looking at one spot in chr1):
with -l only:
samtools mpileup -B -R -a -f hg19.fa -l input.bed --min-BQ 22 --min-MQ 1 input.bam > tmp.with_l.mpileup
chr1 861398 G 2 .. FF
chr1 861399 A 2 .. F:
chr1 861400 T 2 .. FF
chr1 861401 G 2 .. FF
chr1 861402 C 2 .. FF
chr1 861403 G 2 .. FF
chr1 865525 t 0 * *
chr1 865526 g 0 * *
chr1 865527 g 0 * *
chr1 865528 t 0 * *
With -r and -l:
samtools mpileup -B -R -a -f hg19.fa -l input.bed -r chr1 --min-BQ 22 --min-MQ 1 input.bam > tmp.chr1_using_r.mpileup
chr1 861398 G 2 .. FF
chr1 861399 A 2 .. F:
chr1 861400 T 2 .. FF
chr1 861401 G 2 .. FF
chr1 861402 C 2 .. FF
chr1 861403 G 2 .. FF
chr1 865525 g 0 * *
chr1 865526 c 0 * *
chr1 865527 c 0 * *
chr1 865528 c 0 * *
Notice that everything matches until position 865525 (and every position after that differs).
So I asked, which one has the correct reference bases? Upon checking the Fasta used, it appears that the command that uses the -r option has the correct bases:
chr1:861398-861403 GATGCG
chr1:865525-865528 gccc
I know that using -r option allows for samtools mpileup to utilize the BAM index, but why would this change the way that the tool finds the reference bases for each position (i.e. why isn't the call using only -l not pulling the correct reference bases)? Has anyone else run into this?