DESeq2 cannot create DESeqDataSetFromMatrix
1
0
Entering edit mode
10.0 years ago
Mina • 0

Hi,

I wanted to create the dataset for the DESeqDataSetFromMatrix. However, there is an error:

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function 'counts' for signature '"DESeqDataSet"'

This is the code I used:

library(DESeq2)
library(pasilla)
setwd("C:\\Users\\Desktop")

countdata<-read.table("RSEM.txt",sep="\t",header=TRUE,row.names=1)
dim(countdata)

rs<-rowSums(countdata)
use<-(rs>180)
countTableFilt<-countdata[use,]

dim(countTableFilt)
countTableFilt$Fast<-as.integer(countTableFilt$Treat)
countTableFilt$Fast.1<-as.integer(countTableFilt$Treat.1)
countTableFilt$Fast.2<-as.integer(countTableFilt$Treat.2)
countTableFilt$Slow<-as.integer(countTableFilt$Control)
countTableFilt$Slow.1<-as.integer(countTableFilt$Control.1)
countTableFilt$Slow.2<-as.integer(countTableFilt$Control.2)

(conds<-factor(c("Treat","Treat","Treat","Control","Control","Control")))

(coldata <- data.frame(row.names=colnames(countTableFilt), conds))

dds<-DESeqDataSetFromMatrix(countData=countTableFilt,colData=coldata,design=~conds)

I cannot seem to figure out what is wrong. Could someone explain the error? Thanks!

DESeq2 • 9.7k views
ADD COMMENT
1
Entering edit mode

Please check your object properties and also the package versions you are using. I would suggest to post session info and few header lines from your data?

I simulated a small data set using the information provided above. It worked fine on my machine. Script I ran:

library(DESeq2)
df=data.frame("treat"=sample(c(80:100),6, replace=FALSE),
"treat1"=sample(c(90:103),6, replace=FALSE),
"treat2"=sample(c(80:100),6, replace=FALSE),
"ctrl"=sample(c(60:90),6, replace=FALSE),
"ctrl1"=sample(c(60:90),6, replace=FALSE),
"ctrl2"=sample(c(60:90),6, replace=FALSE))
conds<-as.factor(c("Treat","Treat","Treat","Control","Control","Control"))
coldata <- data.frame(row.names=colnames(df), conds)
dds=DESeqDataSetFromMatrix(countData=df,colData=coldata,design=~conds)

My session info:

R version 3.2.2 (2015-08-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu Wily Werewolf (development branch)

locale:
 [1] LC_CTYPE=en_IN       LC_NUMERIC=C         LC_TIME=en_IN
 [4] LC_COLLATE=en_IN     LC_MONETARY=en_IN    LC_MESSAGES=en_IN
 [7] LC_PAPER=en_IN       LC_NAME=C            LC_ADDRESS=C
[10] LC_TELEPHONE=C       LC_MEASUREMENT=en_IN LC_IDENTIFICATION=C

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets
[8] methods   base

other attached packages:
[1] DESeq2_1.8.1              RcppArmadillo_0.5.400.2.0
[3] Rcpp_0.12.0               GenomicRanges_1.20.6
[5] GenomeInfoDb_1.4.2        IRanges_2.2.7
[7] S4Vectors_0.6.5           BiocGenerics_0.14.0

loaded via a namespace (and not attached):
 [1] RColorBrewer_1.1-2   futile.logger_1.4.1  plyr_1.8.3
 [4] XVector_0.8.0        futile.options_1.0.0 tools_3.2.2
 [7] rpart_4.1-10         digest_0.6.8         RSQLite_1.0.0
[10] annotate_1.46.1      gtable_0.1.2         lattice_0.20-33
[13] DBI_0.3.1            proto_0.3-10         gridExtra_2.0.0
[16] genefilter_1.50.0    stringr_1.0.0        cluster_2.0.3
[19] locfit_1.5-9.1       nnet_7.3-11          grid_3.2.2
[22] Biobase_2.28.0       AnnotationDbi_1.30.1 XML_3.98-1.3
[25] survival_2.38-3      BiocParallel_1.2.21  foreign_0.8-66
[28] latticeExtra_0.6-26  Formula_1.2-1        geneplotter_1.46.0
[31] ggplot2_1.0.1        reshape2_1.4.1       lambda.r_1.1.7
[34] magrittr_1.5         scales_0.3.0         Hmisc_3.16-0
[37] MASS_7.3-44          splines_3.2.2        xtable_1.8-0
[40] colorspace_1.2-6     stringi_0.5-5        acepack_1.3-3.3
[43] munsell_0.4.2
ADD REPLY
0
Entering edit mode

Hi cpad0112,

I am sorry about that. Here is my session info:

sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_Philippines.1252  LC_CTYPE=English_Philippines.1252
[3] LC_MONETARY=English_Philippines.1252 LC_NUMERIC=C
[5] LC_TIME=English_Philippines.1252

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods
[8] base

other attached packages:
[1] DESeq2_1.0.19             RcppArmadillo_0.5.600.2.0
[3] Rcpp_0.12.1               lattice_0.20-23
[5] Biobase_2.22.0            GenomicRanges_1.14.4
[7] XVector_0.2.0             IRanges_1.20.7
[9] BiocGenerics_0.8.0

loaded via a namespace (and not attached):
 [1] annotate_1.40.0      AnnotationDbi_1.24.0 DBI_0.2-7
 [4] genefilter_1.44.0    grid_3.0.2           locfit_1.5-9.1
 [7] RColorBrewer_1.0-5   RSQLite_0.11.4       splines_3.0.2
[10] stats4_3.0.2         survival_2.37-4      tools_3.0.2
[13] XML_3.98-1.1         xtable_1.7-1

And here are the first lines of my data:

                    Treat  Treat.1  Treat.2  Control  Control.1  Control2
comp0_c0_seq1       4      0        1        0        1          0
comp0_c1_seq1       1      0        3        1        2          1
comp100000_c0_seq1  0      0        1        1        2          2
comp100001_c0_seq1  1      0        0        4        3          4
comp100002_c0_seq1  5      1        4        0        1          4
comp100003_c0_seq1  3      0        1        1        1          1

Thank you very much.

Mina

ADD REPLY
0
Entering edit mode

Version 1.0.19 is from 2013 (or 2012?), you might want to upgrade your version of R and the packages.

ADD REPLY
0
Entering edit mode
10.0 years ago
  • Last column name doesn't match between your code and the data you pasted here (Control2 Vs Control.2)
  • Following part of your code is creating 6 empty columns and is this what you want? This would create 6 additional columns in countTableFilt table (with column names Fast, Fast.1, Fast.2, Slow, Slow.1 and Slow.2)

    countTableFilt$Fast<-as.integer(countTableFilt$Treat)
    countTableFilt$Fast.1<-as.integer(countTableFilt$Treat.1)
    countTableFilt$Fast.2<-as.integer(countTableFilt$Treat.2)
    countTableFilt$Slow<-as.integer(countTableFilt$Control)
    countTableFilt$Slow.1<-as.integer(countTableFilt$Control.1)
    countTableFilt$Slow.2<-as.integer(countTableFilt$Control.2)
    
  • Following command in your code should throw an error. This is because there are 6 conditions and your column numbers are now 12 after running above command. I am not sure why it didn't

    (coldata <- data.frame(row.names=colnames(countTableFilt), conds))
    

To reproduce the issue, I did following things to cross check if your code works and it seems code has no problems:

1) I created a tsv with the values you furnished with name "rsem.txt":

    Treat    Treat.1    Treat.2    Control    Control.1    Control.2
comp0_c0_seq1    4    0    1    0    1    0
comp0_c1_seq1    1    0    3    1      2      1
comp100000_c0_seq1    0      0      1    1      2      2
comp100001_c0_seq1    1      0      0    4      3      4
comp100002_c0_seq1    5      1      4    0      1      4
comp100003_c0_seq1    3      0      1    1      1      1

2) I copy/pasted your code and ran the code. It didn't give me any error. Please note that I modified rs value (from 180 to 1) so that values are not filtered out and modified code not to create any new columns. In my opinion, "as.integer" code is not necessary (for all the 6 cols). I ran the code with and without "as.integer" arguments, code works in either case.

library(DESeq2)
countdata<-read.table("rsem.txt",sep="\t",header=TRUE,row.names=1)
rs<-rowSums(countdata)
rs
use<-(rs>1)
use
countTableFilt<-countdata[use,]
countTableFilt
colnames(countTableFilt)
dim(countTableFilt)
colnames(countTableFilt)
countTableFilt$Treat<-as.integer(countTableFilt$Treat)
countTableFilt$Treat.1<-as.integer(countTableFilt$Treat.1)
countTableFilt$Treat.2<-as.integer(countTableFilt$Treat.2)
countTableFilt$Control<-as.integer(countTableFilt$Control)
countTableFilt$Control.1<-as.integer(countTableFilt$Control.1)
countTableFilt$Control.2<-as.integer(countTableFilt$Control.2)
conds<-factor(c("Treat","Treat","Treat","Control","Control","Control"))
data.frame(conds)
colnames(countTableFilt)
coldata <- data.frame(row.names=colnames(countTableFilt), conds)
countTableFilt
dds<-DESeqDataSetFromMatrix(countData=countTableFilt,colData=coldata,design=~conds)
ADD COMMENT

Login before adding your answer.

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