epurdom / clusterExperiment

R package of techniques for comparing clusterings of single-cell sequencing data
36 stars 13 forks source link

Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors' #66

Open drisso opened 8 years ago

drisso commented 8 years ago

This message has been annoying us for a long time.

I'm opening an issue because I found where it comes from. The problem is that the class "Annotated" is defined both in the S4Vectors package (a dependency of SummarizedExperiment) and in the RNeXML package (a dependency of phylobase). Note that we want the former.

This is a minimal example that illustrates the behavior:

library(SummarizedExperiment)
SummarizedExperiment()
# class: SummarizedExperiment 
# dim: 0 0 
# metadata(0):
# assays(0):
# rownames: NULL
# rowData names(0):
# colnames: NULL
# colData names(0):
library(RNeXML)
SummarizedExperiment()
# Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
# class: SummarizedExperiment 
# dim: 0 0 
# metadata(0):
# assays(0):
# rownames: NULL
# rowData names(0):
# colnames: NULL
# colData names(0):

Since we need to import both packages, I don't see any obvious way to make this disappear. Emailing the Bioc devel mailing list might be a good idea. It may be something that needs to be fixed in SummarizedExperiment, since we are not directly using the Annotated class.

drisso commented 8 years ago

new("SummarizedExperiment") does not throw the message. Is this of any use?

drisso commented 8 years ago

@HenrikBengtsson any idea how to solve this?

HenrikBengtsson commented 8 years ago

Sorry, no idea. I agree that the Bioc devel list is probably your best place to ask about this.

FYI, this is not a warning, so options(warn=2) + traceback() doesn't help when troubleshooting this, but a message (so can be silences by suppressMessages() if that's an option), which can be tracked down as:

> withCallingHandlers({ SummarizedExperiment() }, message = function(c) { calls <<- sys.calls(); stop(c) })
Error in message(gettextf("Found more than one class \"%s\" in cache; using the first, from namespace '%s'",  :
  Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
> str(calls)
Dotted pair list of 19
 $ : language withCallingHandlers({     SummarizedExperiment() ...
 $ :length 1 SummarizedExperiment()
  ..- attr(*, "srcref")=Class 'srcref'  atomic [1:8] 1 23 1 44 23 44 1 1
  .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0xccec7e8>
 $ : language SummarizedExperiment()
 $ : language SummarizedExperiment(SimpleList(), ...)
 $ : language SummarizedExperiment(SimpleList(), ...)
 $ : language .local(assays, ...)
 $ : language new_SummarizedExperiment0(assays, ans_rownames, NULL, colData, metadata)
 $ : language new("SummarizedExperiment0", NAMES = names, elementMetadata = rowData,      colData = colData, assays = assays, metadata = as.list(metadata))
 $ : language initialize(value, ...)
 $ : language initialize(value, ...)
 $ : language validObject(.Object)
 $ : language getClassDef(superClass, where = where)
 $ : language .getClassFromCache(Class, where, package = package, resolve.msg = resolve.msg)
 $ : language message(gettextf("Found more than one class \"%s\" in cache; using the first, from namespace '%s'",      name, pkgs[1]), domain = NA)
 $ : language withRestarts({     signalCondition(cond) ...
 $ : language withOneRestart(expr, restarts[[1L]])
 $ : language doWithOneRestart(return(expr), restart)
 $ : language signalCondition(cond)
 $ : language (function (c)  { ...

Maybe there's an easier way, but that's the one I know of.

lawremi commented 8 years ago

Will fix this in R.

drisso commented 8 years ago

Copying from the Bioc-devel answer, setting

options(getClass.msg=FALSE)

can be used for now to get rid of the annoying message

drisso commented 8 years ago

Did you close this because it was fixed in R? Or just because it's not a problem with the package?

epurdom commented 8 years ago

@drisso Just because not a problem with package. I assumed it was fixed in R, but I don't know. You want me to keep it open.

drisso commented 8 years ago

Up to you. I was just curious whether you did it because you noticed that it was fixed in R.

epurdom commented 7 years ago

@drisso This minimal example seems to be fixed in R 3.4. But I still get the message when I use R CMD INSTALL (It doesn't show up every time we make a summarized experiment like before, which was driving us crazy, so I don't guess it matters, but I thought I should at record that it is not completely gone):

ElizabedomsPro2:SingleCell epurdom$ R CMD INSTALL clusterExperiment
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library’
* installing *source* package ‘clusterExperiment’ ...
** R
** data
*** moving datasets to lazyload DB
** preparing package for lazy loading
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (clusterExperiment)
epurdom commented 4 years ago

This warning message about the conflict between S4Vectors Annotated class and RNeXML appears to be back in the development version of bioconductor. We haven't changed the package, so I expect something has changed in S4 @lawremi . It has started causing our unit tests to fail on the development version (expect_silent tests throughout).

> source("setup_create_objects.R") #in our test directory in the package
##### Not showing all the warnings, but they show up here. 
> multi_se <- SummarizedExperiment(assays = list(counts = simCount,
                                               logcounts = log1p(simCount)))
> cl1 <- clusterSingle(multi_se, 
+       whichAssay = "counts",
+       mainClusterArgs=list(clusterArgs=list(k=3),
+           clusterFunction="pam"), 
+       subsample=FALSE, sequential=FALSE)
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
Found more than one class "Annotated" in cache; using the first, from namespace 'S4Vectors'
Also defined by ‘RNeXML’
> sessionInfo()
R Under development (unstable) (2020-03-15 r77975)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.3

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] testthat_2.3.2              clusterExperiment_2.7.0     SingleCellExperiment_1.9.2  SummarizedExperiment_1.17.3
 [5] DelayedArray_0.13.7         BiocParallel_1.21.2         matrixStats_0.56.0          Biobase_2.47.2             
 [9] GenomicRanges_1.39.2        GenomeInfoDb_1.23.13        IRanges_2.21.3              S4Vectors_0.25.13          
[13] BiocGenerics_0.33.0        

loaded via a namespace (and not attached):
 [1] nlme_3.1-145           bitops_1.0-6           bit64_0.9-7            doParallel_1.0.15      RColorBrewer_1.1-2    
 [6] progress_1.2.2         httr_1.4.1             zinbwave_1.9.2         tools_4.0.0            R6_2.4.1              
[11] HDF5Array_1.15.13      DBI_1.1.0              lazyeval_0.2.2         colorspace_1.4-1       ade4_1.7-15           
[16] withr_2.1.2            tidyselect_1.0.0       prettyunits_1.1.1      bit_1.1-15.2           compiler_4.0.0        
[21] cli_2.0.2              xml2_1.2.5             pkgmaker_0.31          scales_1.1.0           genefilter_1.69.0     
[26] NMF_0.22.0             stringr_1.4.0          digest_0.6.25          XVector_0.27.1         pkgconfig_2.0.3       
[31] bibtex_0.4.2.2         limma_3.43.5           rlang_0.4.5            RSQLite_2.2.0          howmany_0.3-1         
[36] dplyr_0.8.5            RCurl_1.98-1.1         magrittr_1.5           GenomeInfoDbData_1.2.2 Matrix_1.2-18         
[41] fansi_0.4.1            Rhdf5lib_1.9.2         Rcpp_1.0.3             munsell_0.5.0          ape_5.3               
[46] lifecycle_0.2.0        stringi_1.4.6          edgeR_3.29.1           MASS_7.3-51.5          zlibbioc_1.33.1       
[51] rhdf5_2.31.6           plyr_1.8.6             grid_4.0.0             blob_1.2.1             crayon_1.3.4          
[56] rncl_0.8.4             lattice_0.20-40        splines_4.0.0          annotate_1.65.1        hms_0.5.3             
[61] locfit_1.5-9.1         pillar_1.4.3           uuid_0.1-4             rngtools_1.5           softImpute_1.4        
[66] reshape2_1.4.3         codetools_0.2-16       XML_3.99-0.3           glue_1.3.2             RNeXML_2.4.3          
[71] vctrs_0.2.4            foreach_1.4.8          locfdr_1.1-8           gtable_0.3.0           purrr_0.3.3           
[76] tidyr_1.0.2            kernlab_0.9-29         assertthat_0.2.1       ggplot2_3.3.0          gridBase_0.4-7        
[81] phylobase_0.8.10       xtable_1.8-4           RSpectra_0.16-0        survival_3.1-11        tibble_2.1.3          
[86] iterators_1.0.12       AnnotationDbi_1.49.1   registry_0.5-1         memoise_1.1.0          cluster_2.1.0         
[91] ellipsis_0.3.0        
lawremi commented 4 years ago

Should go away with a clean installation. Packages need to be reinstalled to recreate the extension objects with the proper package references.

epurdom commented 4 years ago

Thanks @lawremi . I'm unclear about this--has there been a change or a suggestion for how to fix problem?

I got this after I had just downloaded R devel and installed bioconductor and I thought all the packages fresh on my computer. However, I will repeat it and this time completely uninstall any existing R and packages before reinstalling the devel version.

lawremi commented 4 years ago

I'm guessing there were some old packages around. R 4.0 should be much better at disambiguating class names, but it did require some internal changes that break until packages are reinstalled. I probably should have added some hacks to make that unnecessary.

epurdom commented 3 years ago

Hi @lawremi, this same message is back on our package in the devel version of Bioconductor and it's again causing our tests to fail. On my computer, I am getting this message with the devel version of R (2021-02-19 r80028) and Bioconductor. I deleted existing R and R libraries before installing. I believe this is also what is causing the package to fail on Bioconductor builds (it's the same basic error message in the same spot). Should we just hang tight and this will sort itself out? Or is there something we should fix? (I will get angry emails about depricating our package if we continue to fail on the devel branch, unless I can tell them something constructive!).

lawremi commented 3 years ago

No idea what could be causing this. I can look into it, but it might be awhile.

epurdom commented 3 years ago

Understand! It was passing in January so I thought perhaps some quite recent change might have occurred which would ring a bell. I will look into it more--it's only happening for specific commands now unlike before when it was ubiquitous. I'll post example code in case you do have time for it.