# Count files using htseq-count?

I am doing RNA-Seq data analysis using data available on SRA (SRR6047326). Samples are from the pig and they are paired. So, I did alignment using HISAT2.I used pig reference genome available on ENSEMBL. Then, I sorted .sam output files obtained from HISAT2. Now I am trying to get the count file using sorted sam file and it is not working. I am using annotated GTF file for pig which I downloaded from Ensembl.

I get count files using following commands, but all the counts are 0.

htseq-counts -i no myfile.sam genes.gtf>output.count


What is wrong here ? Are there any alternatives to htseq-count?

• Help us to help you. What does "not working" mean? Please post relevant error messages, if any. Apr 22 '18 at 8:57
• I runs well and gives me the count file. But there are zero counts for all the genes. At the end of count files it scores most of the genes are on --alignment_not_unique. Apr 22 '18 at 15:31
• I tried kallisto and it seems to work fine with kallisto.I can see counts for the multiple genes in tsv file generated by kallisto. Apr 22 '18 at 15:32
• Is that the actual command you ran? Because the "no" in -i no myfile.sam is odd, and since kallisto is returning some reasonable counts we can assume the issue with the htseq command and not the alignments (which was my 1st thought). Apr 22 '18 at 18:07
• Speaking of kallisto, it is also fine to use those results for your analysis, unless that there a specific reason to use htseq-count. Apr 22 '18 at 18:08

I m not sure about htseq-counts but I would suggest go for featureCounts, I will update my answer and share the script/command. Give it a try

the command i use

featureCounts -T 50 -C -p -t exon -g gene_id -a /run/media/data2/gencode.v21.annotation.gtf  -o PRIMARY_CELL.txt \$(ls *.bam | sort )

• Thanks. I haven't use featureCounts. I found that it could run on R. Hopefully it works. Apr 22 '18 at 5:28
• yes you can but it takes lot of memory
– kcm
Apr 22 '18 at 5:52
• I am running on cluster. But, I have a question here. I have .sam files obtained from HISAT2 which were generated from the paired fastq files. Can I use that .sam files directly for feature counts ? Do I need to sort the sam file and then use feature counts ? Apr 22 '18 at 15:36
• I used the following commands fcounts <- featureCounts(files=“reads.sam”,genome="genes.gtf"). And my results were: Unassigned_NoFeatures = 5305153, and Unassigned_Unmapped=49253221. So, none of the genes were mapped. Any idea what could have gone wrong here ? Apr 22 '18 at 15:46
• Yes, I found a lot of papers using STAR aligner. I will give it a try. Thanks. Apr 23 '18 at 23:33