How can I export featureCounts (Rsubread) results?
1
0
Entering edit mode
7.0 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")

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

 

R Rsubread featureCounts • 11k views
ADD COMMENT
0
Entering edit mode

thanks, Wei Shi! your option worked for me

ADD REPLY
4
Entering edit mode
7.0 years ago

For who had similar or the same problem like me, I found two successfully answers in another forum!


First option by James W. MacDonald

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.


Second option by Wei Shi

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

thanks, Wei Shi! your option worked for me

ADD REPLY

Login before adding your answer.

Traffic: 1944 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