This is a test version of Biostars. For the public version, visit https://www.biostars.org.
HTseq does not generate any counts file

Here is my code for generating counts from the BAM file.

bsub -J "htseq-count" htseq-count \
-e /scratch/workspace/rnaseq/counts/err.txt \
-o /scratch/workspace/rnaseq/counts/log.out \
-f bam \
-r name \
-s no \
-a 10 \
-t exon \
-i gene_id \
-m intersection-nonempty \
/scratch/workspace/rnaseq/bam/Aligned.sortedByCoord.out.bam \
/scratch/workspace/rnaseq/refs/gencode.v22.annotation.gtf > /scratch/workspace/rnaseq/counts/SRR3088529_counts.txt

But it only generates a txt file which have only one line of information telling the job number and time that I had submitted. Here is the error file.

Traceback (most recent call last):
  File "/scratch/shilpeelab/.local/bin/htseq-count", line 4, in <module>
    __import__('pkg_resources').run_script('HTSeq==0.11.1', 'htseq-count')
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 3007, in <module>
    working_set.require(__requires__)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 728, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 626, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pysam>=0.9.0

Based on this can you please help me as I am a newbie in this and could not figure out the problem. Thank you.

rna-seq htseq-count

You need pysam version 0.9.0 or higher as indicated in the error message. Install it. Instead of show htseq-count you can also use featureCounts which comes as a precompiled binary and is notably faster.

1 answer

You also need pysam on the PYTHONPATH. Normally it should have been installed together with HTSeq-count automatically. Maybe more stuff is broken ... If you work on your own computer you could do this with e.g. pip install pysam https://pypi.org/project/pysam/ . You could also start working with conda https://docs.conda.io/en/latest/ . If its on a shared computing thing you have to ask your adminstrator to fix this for you or you do it with e.g. conda

Thanks for the reply. I just install pysam today. But it still does not work. I think I have to as my administrator to find the development library for the python.

I guess you use a different python than HTseq count. Best and easiest is you switch to conda and create your own environment independent of the administrators.

Can you please guide me through how to do that?

Log in to answer this question.