[Bioc-devel] Found more than one class "Annotated" in cache

Michael Lawrence lawrence.michael at gene.com
Mon Apr 25 22:49:45 CEST 2016


Yes, that's a better fix for this in principle, since it uses the
information encoded in the extends object, although I think
getClassFromCache() also needs to be fixed, so that getClassDef() sees
only the imported classes when only given "where". That's a more
general fix that works in both load orders.

Maybe the superClass slot of the extends object should store its
package? Would be convenient, if somewhat redundant. Conceptually, it
seems the package really belongs on superClass, not on the extends
object itself (how does a ClassExtends pertain to a package?).

Index: ClassExtensions.R
===================================================================
--- ClassExtensions.R (revision 70547)
+++ ClassExtensions.R (working copy)
@@ -316,6 +316,7 @@
         stop(gettextf("the 'replace' argument to setIs() should be a
function of 2 or 3 arguments, got an object of class %s",
                       dQuote(class(replace))), domain = NA)

+    packageSlot(to) <- package
     new(extClass, subClass = Class, superClass = to, package = package,
  coerce = coerce, test = test, replace = replace, simple = simple,
  by = by, dataPart = dataPart, distance = distance)



On Mon, Apr 25, 2016 at 1:24 PM, Martin Morgan
<martin.morgan at roswellpark.org> wrote:
>
>
> On 04/25/2016 03:53 PM, Michael Lawrence wrote:
>>
>> Yea, this is a bug in R, in my opinion. The class cache circumvents
>> the namespace imports. In my working copy I've fixed it by falling
>> back to the namespace search when there are multiple hits. That at
>> least fixes this case.
>
>
> This also fixes it
>
> Index: src/library/methods/R/SClasses.R
> ===================================================================
> --- src/library/methods/R/SClasses.R    (revision 70547)
> +++ src/library/methods/R/SClasses.R    (working copy)
> @@ -524,7 +524,7 @@
>         superClass <- exti at superClass
>         if(!exti at simple && !is(object, superClass))
>             next ## skip conditional relations that don't hold for this
> object
> -       superDef <- getClassDef(superClass, where = where)
> +       superDef <- getClassDef(superClass, package = packageSlot(exti))
>         if(is.null(superDef)) {
>             errors <- c(errors,
>                         paste0("superclass \"", superClass,
>
>
> There's another problem seen by loading the packages in reverse order
>
>> suppressPackageStartupMessages({ library(RNeXML); library(GenomicRanges)
>> })
> Found more than one class "Annotated" in cache; using the first, from
> namespace 'RNeXML'
> Also defined by 'S4Vectors'
> ...
>
> which is from
>
> [[17]]
> S4Vectors:::setDefaultSlotValue("XRaw", "shared", new("SharedRaw"),
>     where = asNamespace(pkgname))
>
> [[18]]
> resetClass(classname, classdef, where = where)
>
> [[19]]
> completeClassDefinition(Class, classDef, where)
>
> [[20]]
> .completeClassSlots(ClassDef, where)
>
> [[21]]
> isClass(eClass, where = where)
>
> [[22]]
> getClassDef(Class, where)
>
> [[23]]
> .getClassFromCache(Class, where, package = package, resolve.msg =
> resolve.msg)
>
> but I haven't quite got to the bottom of that. Also, I think these are both
> different from but related to
>
>> suppressPackageStartupMessages(library(Statomica))
> Error in .mergeMethodsTable(generic, mtable, tt, attach) :
>   trying to get slot "defined" from an object of a basic class ("list") with
> no slots
> Error: package or namespace load failed for 'Statomica'
>
>
>>
>> You can disable the message in the short term by setting the
>> "getClass.msg" option to FALSE.
>>
>> Michael
>>
>> On Sun, Apr 24, 2016 at 12:50 PM, davide risso <risso.davide at gmail.com>
>> wrote:
>>>
>>> Dear list,
>>>
>>> we are developing a new package that defines a class that builds on
>>> SummarizedExperiment and also imports the CRAN package phylobase.
>>>
>>> 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 causes the following
>>> message to be thrown every time we create a new object.
>>>
>>> Found more than one class "Annotated" in cache; using the first, from
>>> namespace 'S4Vectors'
>>>
>>>
>>> A minimal example is the following.
>>>
>>>> library(SummarizedExperiment)> SummarizedExperiment()class:
>>>> SummarizedExperiment
>>>
>>> dim: 0 0
>>> metadata(0):
>>> assays(0):
>>> rownames: NULL
>>> rowData names(0):
>>> colnames: NULL
>>> colData names(0):> library(phylobase)> 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):
>>>
>>>> sessionInfo()R Under development (unstable) (2016-03-07 r70284)
>>>
>>> Platform: x86_64-pc-linux-gnu (64-bit)
>>> Running under: Debian GNU/Linux stretch/sid
>>>
>>> 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] stats4    parallel  stats     graphics  grDevices utils
>>> datasets  methods
>>> [9] base
>>>
>>> other attached packages:
>>> [1] phylobase_0.8.2             SummarizedExperiment_1.1.21
>>> [3] Biobase_2.31.3              GenomicRanges_1.23.23
>>> [5] GenomeInfoDb_1.7.6          IRanges_2.5.39
>>> [7] S4Vectors_0.9.41            BiocGenerics_0.17.3
>>>
>>> loaded via a namespace (and not attached):
>>>   [1] Rcpp_0.12.3      plyr_1.8.3       XVector_0.11.7   iterators_1.0.8
>>>   [5] tools_3.3.0      zlibbioc_1.17.0  uuid_0.1-2       jsonlite_0.9.19
>>>   [9] nlme_3.1-125     lattice_0.20-33  foreach_1.4.3    DBI_0.3.1
>>> [13] httr_1.1.0       stringr_1.0.0    dplyr_0.4.3      xml2_0.1.2
>>> [17] ade4_1.7-4       grid_3.3.0       rredlist_0.1.0   reshape_0.8.5
>>> [21] data.table_1.9.6 R6_2.1.2         XML_3.98-1.4     RNeXML_2.0.6
>>> [25] reshape2_1.4.1   tidyr_0.4.1      magrittr_1.5     codetools_0.2-14
>>> [29] assertthat_0.1   bold_0.3.5       taxize_0.7.5     ape_3.4
>>> [33] stringi_1.0-1    rncl_0.6.0       lazyeval_0.1.10  rotl_0.5.0
>>> [37] chron_2.3-47
>>>
>>>
>>> Since we need to import both packages, is there a way to explicitly use
>>> the
>>> correct definition of "Annotated" or to not import the class "Annotated"
>>> from RNeXML?
>>>
>>> Or is this something that could be addressed in the SummarizedExperiment
>>> package?
>>>
>>> These are our DESCRIPTION and NAMESPACE file (note that we are importing
>>> only what we need from phylobase):
>>> https://github.com/epurdom/clusterExperiment/blob/develop/DESCRIPTION
>>> https://github.com/epurdom/clusterExperiment/blob/develop/NAMESPACE
>>>
>>> See also Henrik's comment at:
>>> https://github.com/epurdom/clusterExperiment/issues/66
>>>
>>> Thank you in advance for any help!
>>>
>>> Best,
>>> davide
>>>
>>>          [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> Bioc-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>>>
>>
>> _______________________________________________
>> Bioc-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>>
>
>
> This email message may contain legally privileged and/or confidential
> information.  If you are not the intended recipient(s), or the employee or
> agent responsible for the delivery of this message to the intended
> recipient(s), you are hereby notified that any disclosure, copying,
> distribution, or use of this email message is prohibited.  If you have
> received this message in error, please notify the sender immediately by
> e-mail and delete this email message from your computer. Thank you.
>



More information about the Bioc-devel mailing list