samtools index cannot index concatenated bam?
1
0
Entering edit mode
3.4 years ago
Kai_Qi ▴ 130

Hi:

I have a quick question. I have 2 bam files generated from STAR. I used cat file1.bam file2.bam > combined.bam to put them together. Now I want to get it index using samtools index combined.bam but got an error:

samtools index: failed to create index for "GRCh37_combined_Aligned.sortedByCoord.out.bam": No such file or directory

.

Is this normal?

Thanks,

alignment rna-seq RNA-Seq next-gen • 1.1k views
ADD COMMENT
5
Entering edit mode
3.4 years ago

You can't just cat bam files. Use samtools merge instead.

ADD COMMENT
1
Entering edit mode

As explanation, cat simply concatenates two files. Inappropriate for BAM files since they have header structures etc. samtools cat would be more appropriate whereas merge keeps the sort order. The index command requires coordinate-sorted files. In any case you have to sort the files, either the input files and then use merge or use samtools cat and then sort this file, then index.

ADD REPLY

Login before adding your answer.

Traffic: 3720 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6