0
$\begingroup$

I am doing an RNA seq analysis with mouse samples. I had my reads in several lanes, so I concatenated those fastq reads. Then I've mapped my reads with Hisat2 against the new version of mouse "GCA_000001635.9_GRCm39_genomic.fna".

Apparently everything works well up to here. Now I'm using samtools 1.9 to convert sam to bam, to sort those bam and create the index, just like this:

samtools view -bS ${file} > ${file}.bam

samtools sort -n ${file} -o ${file}_sorted.bam

samtools index  ${file}_sorted.bam

But when indexing I get this error:

[bam_sort_core] merging from 11 files and 1 in-memory blocks... [E::hts_idx_push] NO_COOR reads not in a single block at the end 0 -1 samtools index: failed to create index for "CD4_1A_concat.bam_sorted.bam": No such file or directory

[bam_sort_core] merging from 11 files and 1 in-memory blocks... [E::hts_idx_push] NO_COOR reads not in a single block at the end 23 -1 samtools index: failed to create index for "CD4_1B_concat.bam_sorted.bam": No such file or directory [bam_sort_core] merging from 11 files and 1 in-memory blocks...

And more...

Any help would be appreciated!

$\endgroup$
0
2
$\begingroup$

This is essentially a duplicate of Samtools Index: Chromosome Blocks not Continuous but with different error messages, and a duplicate of Error given while trying to index a BAM file with Samtools Index - NO COOR?.

samtools sort -n ${file} -o ${file}_sorted.bam

These error messages also indicate that the reads are not sorted by coordinate — in particular, that the unplaced unmapped reads with RNAME * are not all together at the end of the file.

This is because samtools sort -n has been used to sort the reads by name instead. Remove -n to sort by position, which is what is needed to prepare a BAM file for indexing with samtools index.

$\endgroup$
1
  • $\begingroup$ Thank you! problem solved :) $\endgroup$
    – user9393
    Aug 20 '20 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.