Entering edit mode
10.0 years ago
alvastrand
▴
10
Hi,
I am trying to split my bam file into individual files containing data for each chromosome, and I know how to do that. The problem is that when I write:
samtools view myfile.bam 1
(for example, to just view the data for chromosome 1)
I get the following error message:
[bam_index_load] fail to load BAM index.
[main_samview] random alignment retrieval only works for indexed BAM files.
The strange thing is that I already have indexed myfile.bam, so I don't understand why it would fail to load the index if it's there, ready to use.
If anyone could help, that would be great.
Thanks,
Alva
Maybe the index file does not follow the expected naming. What is the name of the index file? It should be myfile.bai
It shouldn't fail if you have a myfile.bam.bai in the same folder. Other than that, if you want to view data from chr1,
Someone else had indexed the bam file using another method; when I copied the file and used
samtools index myfile.bam
, it worked. Thanks for the help, both here and below.