I have a total RNAseq dataset that I aligned using STAR producing BAM files (sorted by coordinates). I am now trying to get counts for the lncRNA sequences using htseq-count, with the command:

htseq-count -m intersection-nonempty -f bam -i gene_id -r pos -s reverse ./OVCA429_Aligned.sortedByCoord.out.bam ./GRCh38_latest_genomic.gtf > ./OVCA429.counts.txt

This is the output:

[E::idx_find_and_load] Could not retrieve index file for './OVCA429_587680_1_1.rnaseq.fastqAligned.sortedByCoord.out.bam'
100000 GFF lines processed.
200000 GFF lines processed.
300000 GFF lines processed.
400000 GFF lines processed.
...(truncated output here)...
3775001 GFF lines processed.
[E::idx_find_and_load] Could not retrieve index file for './OVCA429_587680_1_1.rnaseq.fastqAligned.sortedByCoord.out.bam'
100000 alignment records processed.
200000 alignment records processed.
300000 alignment records processed.
...(truncated output here)...

Output text file:
__no_feature    20368875
__ambiguous 0
__too_low_aQual 0
__not_aligned   0
__alignment_not_unique  2634439

I've read through the htseq-count literature but it never asks to include an index file, therefore i'm not sure how to deal with this problem. Any help/ suggestions would be welcome! Thank you, in advance.


1 Answer 1


The problem seems to be missing index files of the bam files (therefore the error message that the index file is missing). You should be able to generate those with samtools, e.g.

samtools index ./OVCA429_587680_1_1.rnaseq.fastqAligned.sortedByCoord.out.bam
  • $\begingroup$ As it happens I did have the index file as well, I just ended up naming it differently and so the application probably didn't recognise it. Once I changed the name to match the bam file, it worked out perfectly file. Nevertheless, thank you for your help! :) $\endgroup$
    – anjali_yen
    Commented Sep 13, 2020 at 18:56
  • $\begingroup$ Ah, I did not even think this could be a problem as samtools do not give you an option to give it a different name. GLad you resolved it! $\endgroup$ Commented Sep 14, 2020 at 10:20
  • $\begingroup$ I have created the index using what Kamil suggested but I am not able to generate the counts file. This is what I use: for i in *fastqAligned.sortedByCoord.out.bam; do htseq-count -r pos -f bam $i /gpfs/scratch/mice/GCA-000001635.90-GRCm39-genomic.gtf > $i_output_basename.counts ; done $\endgroup$ Commented Jan 12, 2022 at 17:05
  • $\begingroup$ @christosnoutsos 1. that was not an answer. You should open a new question, link this one and explain why the solution did not work for you. 2. I would put quotation marks around $i in $i_output_basename.counts, i.e. "$i"_output_basename.counts. You probably created a bunch of files .count that replaced each other. $\endgroup$ Commented Jan 12, 2022 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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