Please, could someone help me to export featureCounts (Rsubread) results?
3
0
Entering edit mode
@gustavoborin01-6892
Last seen 10.1 years ago

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 ]

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

$stat
                      Status
1                   Assigned
2       Unassigned_Ambiguity
3    Unassigned_MultiMapping
4      Unassigned_NoFeatures
5        Unassigned_Unmapped
6  Unassigned_MappingQuality
7 Unassigned_FragementLength
8         Unassigned_Chimera
  T_reesei_F24.2_GTGGCC_L008_R1_001.cleanreads.fastq.gz_tophat2.F24h.2_accepted_hits.bam
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

rnaseq rsubread featurecounts r • 5.0k views
ADD COMMENT
2
Entering edit mode
@james-w-macdonald-5106
Last seen 3 days ago
United States

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:

Value:

     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 COMMENT
2
Entering edit mode
Wei Shi ★ 3.6k
@wei-shi-2183
Last seen 3 months ago
Australia/Melbourne/Olivia Newton-John …

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")

write.table(x=data.frame(fc$annotation[,c("GeneID","Length")],fc$counts,stringsAsFactors=FALSE),file="counts.txt",quote=FALSE,sep="\t",row.names=FALSE)

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.

Wei

 

 

ADD COMMENT
0
Entering edit mode
@gustavoborin01-6892
Last seen 10.1 years ago

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

ADD COMMENT

Login before adding your answer.

Traffic: 572 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6