DESEq2 error - 'DESeqDataSet' object superclass 'RectangularData' not defined in the environment of the object's class
2
0
Entering edit mode
3.9 years ago

Hi all,

I've used DESeq2 many times before, but for some reason, running into the below issue

Error in validObject(.Object) :    invalid class “DESeqDataSet”
object: superclass "RectangularData" not defined in the environment of
the object's class

My code is as follows:

BiocManager::install("DESeq2") 

library(DESeq2)

kegg_mg <- read.delim(here("kegg",

"aaron_metaG_KEGG_counts_merged.txt"), 
                      header=TRUE) %>% as.matrix()
y_mg <- data.frame(row.names=c("GM1a", "GM1b", "GM1c", "GM4a", "GM4b",
 "GM4c"), 
                 condition=as.factor(c(rep("GM1",3), rep("GM4",3))))

 ddsMat_mg <-DESeqDataSetFromMatrix(countData = kegg_mg, colData =
 y_mg, design = ~ condition)

I've restarted Rstudio. Purged all the existing packages and did a clean re-install, and still the problem persists. My input file is a table with 6 columns and count values. Thank you for your help!

DESeq2 R DESeq • 2.3k views
ADD COMMENT
1
Entering edit mode
3.8 years ago
Michael Love ★ 2.6k

Class-related issues often result from invalid installations of Bioconductor, e.g. packages crossing from different Bioc releases. As the packages are built off of a common framework defining classes, conflicting versions often leads to errors like the above.

Can you run:

BiocManager::valid()

And see if you can spot any issues there?

ADD COMMENT
0
Entering edit mode
3.9 years ago

The problem can likely be solved by following these simple tips:

  • kegg_mg should be a data-frame of integer values representing raw counts
  • y_mg should be a data-frame of metadata, with character vectors encoded as factors (i.e. encoded categorically) - continuous vectors are also permitted
  • This should be TRUE: nrow(y_mg) == ncol(kegg_mg)
  • This should be TRUE: rownames(y_mg) == colnames(kegg_mg)

If you need further help, please show the output of:

str(kegg_mg)
str(y_mg)

Kevin

ADD COMMENT
0
Entering edit mode

Hi Keven, I had the same problem. I checked my countData with" is.integer(countData) " and the output is True. I think my data meets all the requirements you listed above. Could you help me with this? Thank you!

str(countData)
 num [1:23669, 1:42] 0 60 74 227 285 ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:23669] "ADH6" "SLC6A13" "FGD1" "MDM4" ...
  ..$ : chr [1:42] "R8202" "R9159" "R9160" "R9163" ...

the output of str(metadata)

str(meta)
 chr [1:42, 1:3] "-9/-9" "-9/-9" "-9/-9" "-9/-9" "wt" "wt" "wt" "w/-9" "-9/-9" "w/-9" ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:42] "R8202" "R9159" "R9160" "R9163" ...
  ..$ : chr [1:3] "Genot" "gender" "time"
ADD REPLY
0
Entering edit mode

Hello, how about running class() and typeof() on these objects?

Can you also show the sequence of commands that you are running?

ADD REPLY
0
Entering edit mode

Hi Keven,

I tried to read my data from the CSV files again. Here are my code and the outs. code:

# ge contains 6 sets of my data.
ge <- read.csv("/home/x/00-data/Rabbit/Raw.Normalized_Counts_All.Genes.All.Samples.csv")
names <- make.unique(ge$GeneName)
rownames(ge) <- names
ge <- ge[,-1]

# brush is my target data.
brush <- ge[ , grepl( ".3_Raw" , names( ge ) )]
colnames(brush) <- substr(colnames(brush ), 1, 5 )
tmp2 <- rowSums(brush)>1
brush <- brush[tmp2,]
brush <- brush[,-1]


## adjust the order of rownames
id <- c(colnames(brush))
id <- data.frame(id=id)

meta <- read.csv("/home/x/00-data/Rabbit/meta_rabbits.csv", header= T)
meta <- left_join(id, meta,by = "id")
rownames(meta) <- meta[,1]
meta <- meta[,-1]


library(DESeq2)
library(gplots)
dds <- DESeqDataSetFromMatrix(countData = brush, colData = meta, design= ~ Genot.)

Then I got the error message again.

str(brush)
'data.frame':   18384 obs. of  42 variables:
 $ R8202: int  0 60 74 227 285 225 2 3392 2748 2393 ...
 $ R9159: int  0 108 145 254 258 70 0 3616 2601 2301 ...
 $ R9160: int  0 197 136 239 140 121 0 3486 2709 2222 ...
 $ R9163: int  0 83 129 242 127 250 0 2648 2486 1684 ...
 $ R9166: int  0 289 153 213 178 424 1 4455 2817 2084 ...

....

str(meta)
'data.frame':   42 obs. of  5 variables:
 $ time  : chr  "Year old" "Wks_4" "Wks_4" "Wks_4" ...
 $ DOB   : chr  "7/6/2017" "5/22/2018" "5/22/2018" "5/22/2018" ...
 $ DOE   : chr  "8/30/2018" "6/18/2018" "6/18/2018" "6/18/2018" ...
 $ Genot.: chr  "-9/-9" "-9/-9" "-9/-9" "-9/-9" ...
 $ gender: chr  "M" "F" "M" "M" ...

class(brush)
[1] "data.frame"
 typeof(brush)
[1] "list"

class(meta)
[1] "data.frame"
typeof(meta)
[1] "list"

Do you have any suggestions? Thank you!

Li

ADD REPLY
0
Entering edit mode

Please see the suggestion by Michael below

ADD REPLY

Login before adding your answer.

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