Sorry for such a silly mistake... You were completely right!
filter -region 3R:15000000..15100000 -in IV75_realigned_reads.bam -out test.bam
bamtools count -in test.bam
28034
Thank you very much for your answer
When extracting reads aligned to a certain region, what is the difference between using samtools view and bamtools filter region?
Here is the code and the counts of the number of reads recovered. I don't understand why the number of reads recovered are so different between the two approaches. Any help??
samtools index IV75_realigned_reads.bam
samtools view -hb IV75_realigned_reads.bam 3R:15,000,000-15,100,000 > Control_region.bam
bamtools count -in Control_region.bam
# 28034
bamtools filter -region 3R:15,000,000-15,100,000 -in IV75_realigned_reads.bam -out test.bam
bamtools count -in test.bam
# 7523775
as far as I can read in the manual of bamtools, region are defined with two dots and not using a hyphen. You should try (and don't play with fire, remove the commas):
3R:15000000..15100000
REGION string format: A proper REGION string can be formatted like any of the following examples (where 'chr1' is the name of a reference (not its ID)and '' is any valid integer position within that reference.):
-region chr1
only alignments on (entire) reference 'chr1'
-region chr1:500
only alignments overlapping the region starting at chr1:500 and continuing to the end of chr1
-region chr1:500..1000
only alignments overlapping the region starting at chr1:500 and continuing to chr1:1000
-region chr1:500..chr3:750
only alignments overlapping the region starting at chr1:500 and continuing to chr3:750. T
Sorry for such a silly mistake... You were completely right!
filter -region 3R:15000000..15100000 -in IV75_realigned_reads.bam -out test.bam
bamtools count -in test.bam
28034
Thank you very much for your answer
Log in to answer this question.
It is not clear what is more maddening
The addition of both terms + the interaction... ;-)