Question: Please, could someone help me to export featureCounts (Rsubread) results?
gravatar for gustavoborin01
3.7 years ago by
gustavoborin010 wrote:

Hi everyone,

I'm trying to export the featureCounts output results of Rsubread to a .xls format (excel), but I'm not having success. I have got the counts of the reads from my RNASeq experiment, but I can't export the result. I used the command below, but it did not work. It appears that warning message.

I know the reportReads argument saves my output, but the generated files are so big and I know that exists a different and simpler way to do that. So, really appreciate if someone could help me.

Used function

>featureCounts(file="T_reesei_F24-2_GTGGCC_L008_R1_001.cleanreads.fastq.gz_tophat2/F24h-2_accepted_hits.bam",annot.ext = "TrireRUTC30_1_GeneCatalog_genes_20110526.fix2.gtf",isGTFAnnotationFile = TRUE,GTF.featureType = "CDS",GTF.attrType = "transcript_id")

GTF file

TrireRUTC30_1_scaffold_23 JGI exon 45921 45986 . - . transcript_id "e_gw1.23.89.1"; gene_id "e_gw1.23.89.1"
TrireRUTC30_1_scaffold_23 JGI CDS 44782 45549 . - 0 transcript_id "e_gw1.23.89.1"; gene_id "e_gw1.23.89.1"
TrireRUTC30_1_scaffold_23 JGI CDS 45634 45819 . - 0 transcript_id "e_gw1.23.89.1"; gene_id "e_gw1.23.89.1"

Output results

1664                                         +;+;+   3186
1665                                           +;+    234
1666                                             +   1362
 [ reached getOption("max.print") -- omitted 8186 rows ]

[1] "T_reesei_F24.2_GTGGCC_L008_R1_001.cleanreads.fastq.gz_tophat2.F24h.2_accepted_hits.bam"

1                   Assigned
2       Unassigned_Ambiguity
3    Unassigned_MultiMapping
4      Unassigned_NoFeatures
5        Unassigned_Unmapped
6  Unassigned_MappingQuality
7 Unassigned_FragementLength
8         Unassigned_Chimera
1                                                                               34914980
2                                                                                   8021
3                                                                                  88386
4                                                                               11354142
5                                                                                      0
6                                                                                      0
7                                                                                      0
8                                                                                      0

Used command to export

> res <- write.table(res$table, file = "F24.xls")

Warning message

Error in res$counts : object of type 'closure' is not subsettable


Thanks Gustavo Borin

ADD COMMENTlink modified 3.7 years ago • written 3.7 years ago by gustavoborin010
gravatar for James W. MacDonald
3.7 years ago by
United States
James W. MacDonald46k wrote:

You have to capture the output of featureCounts(), by assigning it to an object.

counts <- featureCounts(<arguments go here>)

Then if you look at the help for featureCounts, you will see this:


     A list with the following components:

  counts: a data matrix containing read counts for each feature or
          meta-feature for each library.

And you can write that out to a file.

ADD COMMENTlink written 3.7 years ago by James W. MacDonald46k
gravatar for Wei Shi
3.7 years ago by
Wei Shi2.8k
Wei Shi2.8k wrote:

Dear Gustavo Borin,

The 'reportReads' argument enables the detailed read assignment results to be saved into a file. The file includes overlapping features and other data for each read (each row corresponds a read). But I don't think that is what you want.

To save read counts generated from featureCounts, try the following command:

fc <- featureCounts(file="T_reesei_F24-2_GTGGCC_L008_R1_001.cleanreads.fastq.gz_tophat2/F24h-2_accepted_hits.bam",annot.ext="TrireRUTC30_1_GeneCatalog_genes_20110526.fix2.gtf",isGTFAnnotationFile = TRUE,GTF.featureType = "CDS",GTF.attrType = "transcript_id")


The generated 'counts.txt' file is a tab-delimited file which includes gene identifier, gene length and counts for each gene in each library.

Hope this helps.




ADD COMMENTlink written 3.7 years ago by Wei Shi2.8k
gravatar for gustavoborin01
3.7 years ago by
gustavoborin010 wrote:

Thank you so much James and Wei Shi. It was so simple to solve it! It worked successully!

ADD COMMENTlink written 3.7 years ago by gustavoborin010
Please log in to add an answer.


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