<p>You can't cbind a bunch of obscure object types.</p>

<p>If you want merged count tables you should do this:</p>

<pre><code>mdat &lt;- do.call(cbind,lapply(dat,assay))
</code></pre>

<p>Where <strong>row.names</strong> are <em>Ensembl gene IDs</em> and <strong>col.names</strong> are the <em>SRR accessions</em>.</p>

<p>Then run your table writing command.</p>

<p>-</p>

<p>If you want the coordinates of your genes then do this to make a bed with the genomic locations:</p>

<pre><code>library(rtracklayer)
export.bed(rowRanges(dat[[1]]),'gene_coords.bed')
</code></pre>

CC BY-SA 4.0
2019-02-12T17:10:02.887Z
2019-02-12T17:10:02.887Z
story
<p>I tried to run the following code in R studio. Everything worked fine, except at the last step [write.table(mdat, "recount_mdat.csv")] when I tried to export the 'mdat', I got the following error:</p>

<pre><code>Error in as.vector(x) : no method for coercing this S4 class to a vector
</code></pre>

<p>My code:</p>

<pre><code> library('dplyr')
 library('recount')
 library('magrittr')
 library('ffpe')
 library('RSkittleBrewer')
 library('SummarizedExperiment')
 library('devtools')
 trop &lt;- RSkittleBrewer::RSkittleBrewer('tropical')
 colon_proj &lt;- c('SRP025982', 'SRP42161')
 if(any(!file.exists(file.path(colon_proj, 'rse_gene.Rdata')))) {
 sapply(colon_proj, download_study)
 }

 blood_proj &lt;- c('SRP066834', 'SRP041736', 'SRP060416')
 if(any(!file.exists(file.path(blood_proj, 'rse_gene.Rdata')))) {
 sapply(blood_proj, download_study)
 }
 proj &lt;- c(colon_proj,blood_proj)

 dat &lt;- lapply(proj, function(x) {
 load(file.path(x, 'rse_gene.Rdata'))
 return(rse_gene)
 })
 proj

 sapply(dat, dim)

 metadata &lt;- all_metadata('sra')

 write.table(metadata, "recount_metadata.csv")

 mdat &lt;- do.call(cbind, dat)

 write.table(mdat, "recount_mdat.csv")

is(mdat)
## "RangedSummarizedExperiment" "SummarizedExperiment" "Vector" "Annotated"
</code></pre>

CC BY-SA 4.0
2019-02-12T16:14:41.393Z
What is the class of mdat? Did you try `is(mdat)`? What did you get?
llrs
CC BY-SA 4.0
2019-02-12T16:15:27.257Z
@IIrs Hi I got this after this step

               [1] "RangedSummarizedExperiment" "SummarizedExperiment"       
               "Vector"                    
       [4] "Annotated"
Priya
CC BY-SA 4.0
2019-02-13T09:31:56.470Z
Great, see how fast you got your answer when you provided enough details, remember to include all the relevant details next time! Glad you found how to solve the problem
llrs
<rna-seq><bioconductor><rstudio>
Error in as.vector(x) : no method for coercing this S4 class to a vector
# Error in as.vector(x) : no method for coercing this S4 class to a vector

(Asked by: username_0 on 2019-02-12)

I tried to run the following code in R studio. Everything worked fine, except at the last step [write.table(mdat, "recount_mdat.csv")] when I tried to export the 'mdat', I got the following error:
Error in as.vector(x) : no method for coercing this S4 class to a vector

My code:
 library('dplyr')
 library('recount')
 library('magrittr')
 library('ffpe')
 library('RSkittleBrewer')
 library('SummarizedExperiment')
 library('devtools')
 trop <- RSkittleBrewer::RSkittleBrewer('tropical')
 colon_proj <- c('SRP025982', 'SRP42161')
 if(any(!file.exists(file.path(colon_proj, 'rse_gene.Rdata')))) {
 sapply(colon_proj, download_study)
 }

 blood_proj <- c('SRP066834', 'SRP041736', 'SRP060416')
 if(any(!file.exists(file.path(blood_proj, 'rse_gene.Rdata')))) {
 sapply(blood_proj, download_study)
 }
 proj <- c(colon_proj,blood_proj)

 dat <- lapply(proj, function(x) {
 load(file.path(x, 'rse_gene.Rdata'))
 return(rse_gene)
 })
 proj

 sapply(dat, dim)

 metadata <- all_metadata('sra')

 write.table(metadata, "recount_metadata.csv")

 mdat <- do.call(cbind, dat)

 write.table(mdat, "recount_mdat.csv")

is(mdat)
## "RangedSummarizedExperiment" "SummarizedExperiment" "Vector" "Annotated"

**Tags:** rna-seq, bioconductor, rstudio
> **Comments:**
> **username_1**: What is the class of mdat? Did you try `is(mdat)`? What did you get?  
> **username_0**: @IIrs Hi I got this after this step                 [1] "RangedSummarizedExperiment" "SummarizedExperiment"                       "Vector"                            [4] "Annotated"  
> **username_1**: Great, see how fast you got your answer when you provided enough details, remember to include all the relevant details next time! Glad you found how to solve the problem  

---

## 1 answers

### Answer by username_2 on 2019-02-12. Score: 6 | Accepted answer

You can't cbind a bunch of obscure object types.
If you want merged count tables you should do this:
mdat <- do.call(cbind,lapply(dat,assay))

Where row.names are Ensembl gene IDs and col.names are the SRR accessions.
Then run your table writing command.
-
If you want the coordinates of your genes then do this to make a bed with the genomic locations:
library(rtracklayer)
export.bed(rowRanges(dat[[1]]),'gene_coords.bed')


---

