DESeq2 error when attempting to normalize counts
1
0
Entering edit mode
snamjoshi87 ▴ 40
@snamjoshi87-11184
Last seen 7.8 years ago

I am running code that I have run many times over the last two months and suddenly it stopped working. I checked my older backup copies to ensure I hadn't accidentally deleted something. Everything is exactly as it has been but it now throws an error.

Import my raw count data/processing:

countData <- read.csv(file = "countData.csv", header = T)
rownames(countData) <- countData[ ,1]
countData[ ,1] <- NULL

rownames(metaTable) <- metaTable[ ,1]   # Set first column to row names
metaTable[ ,1] <- NULL

Create DESeq object (note: my metaTable is not shown in this post):

dd <- DESeqDataSetFromMatrix(countData = countData, colData = metaTable, design = ~ condition)

This produces (sample names altered):

class: DESeqDataSet
dim: 47729 42
metadata(1): version
assays(1): counts
rownames(47729): ENSMUSG00000102693 ENSMUSG00000064842 ...
  ENSMUSG00000096730 ENSMUSG00000095742
rowData names(0):
colnames(42): SAMPLE1 SAMPLE1 ... SAMPLE41 SAMPLE42
colData names(5): LibraryLayout fastq condition technical Counts

Collapse technical replicates:

dd$technical <- gsub("_T1|_T2", "", row.names(metaTable))
ddRep <- collapseReplicates(dd, groupby = dd$technical)

This produces (sample names altered):

class: DESeqDataSet
dim: 47729 21
metadata(1): version
assays(1): counts
rownames(47729): ENSMUSG00000102693 ENSMUSG00000064842 ...
  ENSMUSG00000096730 ENSMUSG00000095742
rowData names(0):
colnames(21): SAMPLE1 SAMPLE2 ... SAMPLE20 SAMPLE21
colData names(6): LibraryLayout fastq ... Counts sizeFactor

Normalize:

ddRep <- estimateSizeFactors(ddRep)
normCounts <- as.data.frame(counts(ddRep, normalize = T))

Then I get this error:

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

Session info:

R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.1 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8      
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8  
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C             
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C      

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

other attached packages:
 [1] BiocInstaller_1.22.3       RDAVIDWebService_1.10.0    GOstats_2.38.1           
 [4] Category_2.38.0            Matrix_1.2-7.1             graph_1.50.0             
 [7] RColorBrewer_1.1-2         pheatmap_1.0.8             reshape2_1.4.1           
[10] ggplot2_2.1.0              org.Mm.eg.db_3.3.0         AnnotationDbi_1.34.4     
[13] DESeq2_1.12.4              SummarizedExperiment_1.2.3 Biobase_2.32.0           
[16] GenomicRanges_1.24.3       GenomeInfoDb_1.8.7         IRanges_2.6.1            
[19] S4Vectors_0.10.3           BiocGenerics_0.18.0      

loaded via a namespace (and not attached):
 [1] genefilter_1.54.2      locfit_1.5-9.1         splines_3.3.1        
 [4] rJava_0.9-8            lattice_0.20-34        colorspace_1.2-6     
 [7] chron_2.3-47           survival_2.39-5        RBGL_1.48.1          
[10] XML_3.98-1.4           foreign_0.8-67         DBI_0.5-1            
[13] BiocParallel_1.6.6     plyr_1.8.4             stringr_1.1.0        
[16] zlibbioc_1.18.0        munsell_0.4.3          gtable_0.2.0         
[19] latticeExtra_0.6-28    geneplotter_1.50.0     GSEABase_1.34.1      
[22] Rcpp_0.12.7            acepack_1.3-3.3        xtable_1.8-2         
[25] scales_0.4.0           Hmisc_3.17-4           annotate_1.50.1      
[28] XVector_0.12.1         gridExtra_2.2.1        stringi_1.1.2        
[31] grid_3.3.1             tools_3.3.1            bitops_1.0-6         
[34] magrittr_1.5           RCurl_1.95-4.8         RSQLite_1.0.0        
[37] Formula_1.2-1          cluster_2.0.5          GO.db_3.3.0          
[40] data.table_1.9.6       AnnotationForge_1.14.2 rpart_4.1-10         
[43] nnet_7.3-12          

 

deseq2 RDAVIDWebService • 2.6k views
ADD COMMENT
2
Entering edit mode
@mikelove
Last seen 1 day ago
United States

What about this:

library(DESeq2)
dds <- makeExampleDESeqDataSet()
head(​counts(dds))

 

ADD COMMENT
0
Entering edit mode

Running the code above produces the same error.

ADD REPLY
0
Entering edit mode

And I assume you are all up to date on Bioc packages?

What do you get with:

library(BiocInstaller)
​biocValid()
ADD REPLY
0
Entering edit mode

Running biocValid() I see the only out of date packages are evaluate (0.9), rggobi (2.1.20), rgl (0.95.1441), RGtk2 (2.20.31), and rJava (0.9-8). I had tried to update these earlier but I got non-zero exit status, probably because of some missing core libraries and I guess I never ended up updating after that. That was quite a while ago and everything has worked fine since then.

However, I just discovered that I am able to replicate the error by loading the Bioconductor package RDAVIDWebService. If this package is not loaded, both my original code and the sample code you posted work. When I add the package, I can no longer run the code!

ADD REPLY
0
Entering edit mode

And, I noticed that when you load the RDAVIDWebService, the messages printed during package loading include: "The following object is masked from 'package:DESeq2' : counts".

So it would appear that is the issue, but why is this happening?

ADD REPLY
0
Entering edit mode

Sorry, for all the posting but I think I figured it out. Both DESeq2 and RDAVIDWebService have a function called counts(). Since RDAVIDWebService is loaded after DESeq2 in my code, it take precedence for the counts() function and DESeq2 cannot access it unless I use the double colon operator (i.e. DESeq2::counts() ). I'm new to all this so if someone could confirm that this is the proper way to handle this situation if I want both packages loaded, I would appreciate it.

ADD REPLY
1
Entering edit mode

Yes that is correct. You can get around it with ::

This message that was printed: "The following object is masked from 'package:DESeq2' : counts"

...tells you that whatever package you just loaded took over the counts() function in a way that you won't be able to use DESeq2's count function. 

The way we usually handle this in Bioconductor is to define methods for different classes of objects, so that lots of packages can all have functions with the same name. RDAVIDWebService should not set a generic for 'counts' because this is already in BiocGenerics:

https://github.com/Bioconductor-mirror/RDAVIDWebService/blob/dcf73870d68e6fd7306f7cdc04cd45ebe104a527/R/DAVIDGODag-methods.R#L259

https://github.com/Bioconductor-mirror/BiocGenerics/blob/master/R/dge.R#L3

 

ADD REPLY

Login before adding your answer.

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