Search
Question: featureCounts (sourceforge) not returning any counts in count table, even though summary indicates reads were assigned?
0
gravatar for Darya Vanichkina
2.5 years ago by
Australia/Centenary Institute University of Sydney
Darya Vanichkina100 wrote:

I'm having a very strange error when running featureCounts on a tiny test file: it says it's generating counts in the summary.txt file, but the 7th column of the counttable file is empty:

cat TestYA.multicounts.txt| awk '{print $7}' | sort | uniq

"--fraction"
/home/me/test/TestYAAligned.sortedByCoord.out.bam
cat TestYA.multicounts.txt.summary

Status    /home/me/test/TestYAAligned.sortedByCoord.out.bam
Assigned    18
Unassigned_Ambiguity    297
Unassigned_MultiMapping    0
Unassigned_NoFeatures    517
Unassigned_Unmapped    0
Unassigned_MappingQuality    0
Unassigned_FragmentLength    0
Unassigned_Chimera    0
Unassigned_Secondary    0
Unassigned_Nonjunction    0
Unassigned_Duplicate    0

 

Where did the 18 reads go?

 

head testYA.multicounts.txt
# Program:featureCounts v1.5.0; Command:"/home/me/bin/subread-1.5.0-Linux-x86_64/bin/featureCounts" "-p" "-M" "--fraction" "−−minOverlap" "5" "-s" "n" "-T" "-C" "-R" "-t" "exon" "-g" "gene_id" "-a" "/home/me/mouse/GRCm38_mm10/gencode.vM8.primary_assembly.annotation.gtf" "-o" "TestYA.multicounts.txt" "/home/me/test/TestYAAligned.sortedByCoord.out.bam"
Geneid    Chr    Start    End    Strand    Length    /home/me/test/TestYAAligned.sortedByCoord.out.bam
ENSMUSG00000102693.1    chr1    3073253    3074322    +    1070
ENSMUSG00000064842.1    chr1    3102016    3102125    +    110
ENSMUSG00000051951.5    chr1;chr1;chr1;chr1    3205901;3213439;3421702;3670552    3207317;3216968;3421901;3671498    -;-;-;-    6094
ENSMUSG00000102851.1    chr1    3252757    3253236    +    480

 

 

 

 

 
ADD COMMENTlink modified 2.5 years ago • written 2.5 years ago by Darya Vanichkina100

You're working in bash, not R right?

From your first cat | awk | etc. you get: "--fraction"

So my guess there is something wrong with that? Maybe this argument is not correctly given? Are the dashes ok?

ADD REPLYlink written 2.5 years ago by b.nota300

Yes, I'm in bash, but, unfortunately, that's not the case. If you look at the results of my head command, I'm getting exactly what I would expect:

"--fraction" from line 1:

# Program:featureCounts v1.5.0; Command:"/home/me/bin/subread-1.5.0-Linux-x86_64/bin/featureCounts" "-p" "-M" "--fraction" "−−minOverlap" "5" "-s" "n" "-T" "-C" "-R" "-t" "exon" "-g" "gene_id" "-a" "/home/me/mouse/GRCm38_mm10/gencode.vM8.primary_assembly.annotation.gtf" "-o" "TestYA.multicounts.txt" "/home/me/test/TestYAAligned.sortedByCoord.out.bam"

 

/home/me/test/TestYAAligned.sortedByCoord.out.bam from line2:

Geneid    Chr    Start    End    Strand    Length   /home/me/test/TestYAAligned.sortedByCoord.out.bam

 

And all of the rest of the lines of the file (wc -l identifies 47071 lines in the file, with each line looking like line 3) have nothing (not even a zero!) in the 7th field. I would think that if all was well, featureCounts would at least write all zeros ... But I can't see a message in the error file that would explain to me why it's all failing!

/Figured out below/

 

ADD REPLYlink written 2.5 years ago by Darya Vanichkina100
1
gravatar for Darya Vanichkina
2.5 years ago by
Australia/Centenary Institute University of Sydney
Darya Vanichkina100 wrote:

OK, so I figured it out, and it was not very intuitive to debug! The problem I had was that when I copied the --minOverlap flag from the user manual pdf, it must have had some non-unicode characters which made featureCounts to think that --minOverlap and 5 (the value I set) were files, not a flag and it's value. 

Running the code below is bad:

/home/me/bin/subread-1.5.0-Linux-x86_64/bin/featureCounts -p -M −−minOverlap 1 --fraction -s 0 -T 1 -C -R -t exon -g gene_id -a /home/me/project/me/Reference/mouse/GRCm38_mm10/gencode.vM8.primary_assembly.annotation.gtf -o TestYA.multicounts.txt /home/me/test/star/TestYAAligned.sortedByCoord.out.bam

Looking at the pre-run log you can see:

 

        ==========     _____ _    _ ____  _____  ______          _____
        =====         / ____| |  | |  _ \|  __ \|  ____|   /\   |  __ \
          =====      | (___ | |  | | |_) | |__) | |__     /  \  | |  | |
            ====      \___ \| |  | |  _ <|  _  /|  __|   / /\ \ | |  | |
              ====    ____) | |__| | |_) | | \ \| |____ / ____ \| |__| |
        ==========   |_____/ \____/|____/|_|  \_\______/_/    \_\_____/
      v1.5.0

//========================== featureCounts setting ===========================\\
||                                                                            ||
||             Input files : 1 BAM file  2 unknown files                      ||
||                           ? −−minOverlap                               || <- LOOK HERE
||                           ? 1                                              || <- HERE
||                           P /home/me/test/TestYAAligned. ... ||
||                                                                            ||
||             Output file : TestYA.multicounts.txt                           ||
||             Annotations : /home/me/project/me/Reference/m ... ||
||      Assignment details : <input_file>.featureCounts                       ||
||                                                                            ||
||                 Threads : 1                                                ||
||                   Level : meta-feature level                               ||
||              Paired-end : yes                                              ||
||         Strand specific : no                                               ||
||      Multimapping reads : counted (as fractions)                           ||
|| Multi-overlapping reads : not counted                                      ||
||       Read orientations : fr                                               ||
||                                                                            ||
||          Chimeric reads : not counted                                      ||
||        Both ends mapped : not required                                     ||
||                                                                            ||
\\===================== http://subread.sourceforge.net/ ======================//

//================================= Running ==================================\\
||                                                                            ||
|| Load annotation file /home/me/project/me/Reference/mouse/ ... ||
||    Features : 701120                                                       ||
||    Meta-features : 47069                                                   ||
||    Chromosomes/contigs : 45                                                ||
||                                                                            ||
|| Process Unknown file −−minOverlap...                                   ||
||    Single-end reads are included.                                          ||
|| Failed to open file −−minOverlap                                       ||
|| No counts were generated for this file.                                    ||
||                                                                            ||
|| Process Unknown file 1...                                                  ||
||    Single-end reads are included.                                          ||
|| Failed to open file 1                                                      ||
|| No counts were generated for this file.                                    ||
||                                                                            ||
|| Process BAM file /home/me/test/star/TestYAAligned.sortedByCoo ... ||
||    Paired-end reads are included.                                          ||
||    Assign fragments (read pairs) to features...                            ||
||    Total fragments : 832                                                   ||
||    Successfully assigned fragments : 18 (2.2%)                             ||
||    Running time : 0.00 minutes                                             ||
||                                                                            ||
||                         Read assignment finished.                          ||
||                                                                            ||
\\===================== http://subread.sourceforge.net/ ======================//

When the code is run this way, no reads are reported in the output file (although in theory they should, if you look at the log!/

If, however, I paste the flag from the command line (i.e. by pasting from running featureCounts without arguments) all is well and I get

/home/me/bin/subread-1.5.0-Linux-x86_64/bin/featureCounts --minOverlap 1 -p -M --fraction -s 0 -T 1 -C -R -t exon -g gene_id -a /home/me/project/me/Reference/mouse/GRCm38_mm10/gencode.vM8.primary_assembly.annotation.gtf -o TestYA.multicounts.txt /home/me/test/star/TestYAAligned.sortedByCoord.out.bam

 

This works! 

The relevant bit of the log file looks like this:

//========================== featureCounts setting ===========================\\
||                                                                            ||
||             Input files : 1 BAM file                                       ||
||                           P /home/me/test/TestYAAligned. ... ||
||                                                                            ||
||             Output file : TestYA.multicounts.txt                           ||
||             Annotations : /home/me/project/me/Reference/m ... ||
||      Assignment details : <input_file>.featureCounts                       ||

 

And the output of my about head/awk pipe is:

cat TestYA.multicounts.txt| awk '{print $7}' | sort | uniq
0
1
2.50
/home/me/test/TestYAAligned.sortedByCoord.out.bam
"-p"

As I would expect. 

 

Another thing I found out in the process is that if you include an incorrect flag for stranding:

/home/me/bin/subread-1.5.0-Linux-x86_64/bin/featureCounts --minOverlap 5 -p -M --fraction -s LALA -T 1 -C -R -t exon -g gene_id -a /home/me/project/me/Reference/mouse/GRCm38_mm10/gencode.vM8.primary_assembly.annotation.gtf -o TestYA.multicounts.txt /home/me/test/TestYAAligned.sortedByCoord.out.bam

Instead of flipping, featureCounts will just count the data as unstranded. An important GOTCHA ... Not sure which other variables are not tested for integrity...

ADD COMMENTlink modified 2.5 years ago • written 2.5 years ago by Darya Vanichkina100

Yeah you use bash, I was asking this because this website is for R bioconductor questions ;-)

If you copy dashes from pdf files you get problems in bash, that's what I wanted to tell you. I suspected "--fraction" to cause it but it was "--minOverlap". Why some dashes are copied right and others not? I dont know!

ADD REPLYlink written 2.5 years ago by b.nota300
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 144 users visited in the last hour