[Bioc-devel] Identical methods in two packages

Vincent Carey stvjc at channing.harvard.edu
Tue Sep 12 22:58:21 CEST 2017


For this particular problem, it may be worth noting that

http://geneontology.org/page/ontology-structure

describes CC, MF, BP as "sub-ontologies" of GO.  AnnotationDbi might replace
its Ontology() with subontology() to acquire those tokens.

On Tue, Sep 12, 2017 at 4:28 PM, Michael Lawrence <lawrence.michael at gene.com
> wrote:

> I think I'm going to vote for the policy that methods with identical
> signatures are currently unsupported by the methods package. It's
> tough to imagine how they might work in any reliable and natural way,
> and they totally break the methods package currently.
>
> In the grand scheme of things, generics should have constrained
> semantics. If you guys can't reconcile the semantics, then you'll need
> two different generics with the same name. But please think about the
> users.
>
> Michael
>
>
> On Tue, Sep 12, 2017 at 1:06 PM, Laurent Gatto <lg390 at cam.ac.uk> wrote:
> >
> > Hi Herve,
> >
> > I understand that there is a clash between the two identical methods.
> > Both packages seem to have good reasons to implement their own
> > `Ontology,character`. Such clashes are relatively frequent.
> >
> > My issue really is that when unloading AnnotationDbi's namespace,
> > `Ontology,character` is removed from the methods' dispatch table, and
> > thus becomes unavailable to rols users. What really should happen is
> > that when AnnotationDbi's namespace is unloaded, the method in rols
> > works again, similar to what happens for function.
> >
> > Is this something that is worth raising on R-devel?
> >
> > Best wishes,
> >
> > Laurent
> >
> > On 12 September 2017 16:35, Hervé Pagès wrote:
> >
> >> Hi Laurent,
> >>
> >> The 2 Ontology,character methods defined in AnnotationDbi and
> >> rols do very different things. The 1st one expects a vector of
> >> GO IDs and returns the GO sub-ontologies that they belong to:
> >>
> >>  > Ontology(c("GO:0000009", "GO:0000012", "GO:0000006"))
> >> GO:0000009 GO:0000012 GO:0000006
> >>        "MF"       "BP"       "MF"
> >>
> >> The 2nd one takes the name of an ontology and returns a
> >> summary/description of it:
> >>
> >>  > Ontology("efo")
> >> Ontology: Experimental Factor Ontology (efo)
> >>    The Experimental Factor Ontology (EFO) provides a systematic
> >>    description of many experimental variables available in EBI
> databases,
> >>    and for external projects such as the NHGRI GWAS catalogue. It
> combines
> >>    parts of several biological ontologies, such as anatomy, disease and
> >>    chemical compounds. The scope of EFO is to support the annotation,
> >>    analysis and visualization of data handled by many groups at the EBI
> >>    and as the core ontology for OpenTargets.org
> >>     Loaded: 2017-08-16 Updated: 2017-09-12 Version: 2.87
> >>     20063 terms  297 properties  0 individuals
> >>
> >> So the problem here is that even though now we have a single Ontology
> >> generic in BiocGenerics for the 2 methods, we haven't really talked
> >> about semantics i.e. what Ontology() is actually supposed to do. Having
> >> a generic without some sort of contract that methods are supposed to
> >> honor is like having a generic called doSomething() and have people
> >> start writing a bunch of methods for it ;-)
> >>
> >> The right thing to do here would be to use 2 different generics with
> >> 2 different names e.g. Ontology() in AnnotationDbi and ontologySummary()
> >> in rols. Or GOontology() in AnnotationDbi and Ontology() in rols.
> >>
> >> If we want to keep the current situation and make it work properly, we
> >> could implement the following hack: have rols depend on AnnotationDbi
> >> and make the method in rols work on GO ids. The code would just need
> >> to detect whether the strings in the supplied character vector start
> >> with the "GO:" prefix and delegate to the code in AnnotationDbi (this
> >> means that rols would need to be able to call that code so the body
> >> of the AnnotationDbi method would need to be moved to an helper
> >> function). An ugly hack though!
> >>
> >> What do you want to do?
> >>
> >> H.
> >>
> >> On 09/03/2017 07:59 AM, Laurent Gatto wrote:
> >>>
> >>> Dear all,
> >>>
> >>> This is a follow up to a previous email regarding the Ontology generic
> >>> function, that is now in the BiocGenerics package. It seems that my
> >>> problem was not only that both rols and AnnotationDbi defined the same
> >>> generic, but they also both defined Ontology,character.
> >>>
> >>>> library("rols")
> >>>
> >>> This is 'rols' version 2.5.2
> >>>
> >>>> Ontology("go")
> >>> Ontology: Gene Ontology (go)
> >>>    An ontology for describing the function of genes and gene products
> >>>     Loaded: 2017-08-31 Updated: 2017-09-01 Version: 2017-08-30
> >>>     49075 terms  67 properties  0 individuals
> >>>> Ontology
> >>> standardGeneric for "Ontology" defined from package "BiocGenerics"
> >>>
> >>> function (object)
> >>> standardGeneric("Ontology")
> >>> <environment:0x2da7cf0>
> >>> Methods may be defined for arguments: object
> >>> Use  showMethods("Ontology")  for currently available ones.
> >>>> showMethods("Ontology")
> >>> Function: Ontology (package BiocGenerics)
> >>> object="character"
> >>> object="Ontology"
> >>>
> >>>> getMethod("Ontology", "character")
> >>> Method Definition:
> >>>
> >>> function (object)
> >>> {
> >>>      url <- ontologyUrl(object)
> >>>      x <- GET(url)
> >>>      stop_for_status(x)
> >>>      cx <- content(x)
> >>>      makeOntology(cx)
> >>> }
> >>> <environment:namespace:rols>
> >>>
> >>> Signatures:
> >>>          object
> >>> target  "character"
> >>> defined "character"
> >>>
> >>> Until now, everything works as expected. The trouble begins when
> loading
> >>> AnnotationDbi.
> >>>
> >>>> suppressPackageStartupMessages(library("AnnotationDbi"))
> >>>> showMethods("Ontology")
> >>> Function: Ontology (package BiocGenerics)
> >>> object="character"
> >>> object="GOTerms"
> >>> object="GOTermsAnnDbBimap"
> >>> object="Ontology"
> >>>
> >>>> getMethod("Ontology", "character")
> >>> Method Definition:
> >>>
> >>> function (object)
> >>> .GOid2go_termField(object, "ontology")
> >>> <environment:namespace:AnnotationDbi>
> >>>
> >>> Signatures:
> >>>          object
> >>> target  "character"
> >>> defined "character"
> >>>> Ontology("go")
> >>> Loading required package: GO.db
> >>>
> >>> <NA>
> >>>    NA
> >>>
> >>> Ok, fair enough, these things happen. The issue is to recover
> >>> Ontology,character from rols. If I unload AnnotationDbi's namespace (I
> >>> also neet to unload GO.db, that got loaded automatically), there is no
> >>> Ontology,character anymore.
> >>>
> >>>> unloadNamespace("GO.db")
> >>>> unloadNamespace("AnnotationDbi")
> >>>> showMethods("Ontology")
> >>> Function: Ontology (package BiocGenerics)
> >>> object="Ontology"
> >>>
> >>>> Ontology("go")
> >>> Error in (function (classes, fdef, mtable)  :
> >>>    unable to find an inherited method for function ‘Ontology’ for
> signature ‘"character"’
> >>>> rols::Ontology("go")
> >>> Error in (function (classes, fdef, mtable)  :
> >>>    unable to find an inherited method for function ‘Ontology’ for
> signature ‘"character"’
> >>>
> >>>> getMethod("Ontology", "character")
> >>> Error in getMethod("Ontology", "character") :
> >>>    no method found for function 'Ontology' and signature character
> >>>> getMethod("Ontology", "character", where = "package:rols")
> >>> Method Definition:
> >>>
> >>> function (object)
> >>> {
> >>>      url <- ontologyUrl(object)
> >>>      x <- GET(url)
> >>>      stop_for_status(x)
> >>>      cx <- content(x)
> >>>      makeOntology(cx)
> >>> }
> >>> <environment:namespace:rols>
> >>>
> >>> Signatures:
> >>>          object
> >>> target  "character"
> >>> defined "character"
> >>>
> >>>
> >>> It is really the expected behaviour? How could I recover rols'
> >>> Ontology,character?
> >>>
> >>> Thank you in advance.
> >>>
> >>> Best wishes,
> >>>
> >>> Laurent
> >>>
> >
> >
> > --
> > Laurent Gatto | @lgatt0
> > http://cpu.sysbiol.cam.ac.uk/
> > http://lgatto.github.io/
> >
> > _______________________________________________
> > 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
>

	[[alternative HTML version deleted]]



More information about the Bioc-devel mailing list