I have a lot of BAM files and I tried counting them using featureCounts. All the files works great, but these few files throwing these error. I'm using the same annotation file all the time so I guess that's not the problem, I also tried to decrease the number of threads- didn't change anything. Can someone help me who had the same problem?
My command is:
featureCounts -a Homo_sapiens.GRCh37.75.gtf -o count.out -T 8 bams/*.bam
Your code is fine and since only few of the .bam files give you this error it clearly shows your pipeline is not the issue. The files that gives you error are corrupt. You can either go back and redo QC/preprocessing/alignment for those sample OR if you want to find out the problematic lines in the current bam files you can use samtools debuging as already described here by Devon Ryan
Run
samtools quickcheck -qvvv your.bam
on the problematic bams. Maybe some got corrupted during mapping.