I am attempting to extract certain regions from a large .bam file into a smaller subsetted .bam file using samtools view. I'm doing so in order to have a smaller file to down/upload for viewing in IGV.
I have a .bed file with the regions of interest, tab-delimited, no extra white spaces (my "chromosomes" are actually specific genes in this case, so they each start with 0 and are comparatively short). This is a snippet of the first 3 rows. Total number of regions/rows/genes is between 60-90.
52283_0_001313 0 895 52283_0_001c02 0 3102 52283_0_001309 0 2203
I have used samtools view to attempt to extract these regions of interest:
samtools view -h -b -L regions.bed input.bam > output.bam
However, the output.bam file only consists of the first region from the .bed file (e.g., "52283_0_001313" only). I have double-checked that the "chromosome" names match in my .bam file and .bed file using
samtools view -H input.bam
I am using samtools version 1.10.
Any suggestions on why this is happening or how to remedy this issue? Thank you.