[Bioc-devel] Identical methods in two packages

Hervé Pagès hpages at fredhutch.org
Wed Sep 13 00:52:08 CEST 2017


On 09/12/2017 01:58 PM, Vincent Carey wrote:
> For this particular problem, it may be worth noting that
>
> https://urldefense.proofpoint.com/v2/url?u=http-3A__geneontology.org_page_ontology-2Dstructure&d=DwIGaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=ECJZN8XlNzgWTqEBbZjafknjX8AFaP25P-pVVk1_FnI&s=JGP585F0L1FCGBWgo2vmg1Tl4ieNB_z2HRGv0oEUVvk&e=
>
> describes CC, MF, BP as "sub-ontologies" of GO.  AnnotationDbi might replace
> its Ontology() with subontology() to acquire those tokens.

Thanks Vince for the suggestion. I like subontology() as a replacement
for Ontology() in AnnotationDbi.

We'll make that change.

H.

>
> 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
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__cpu.sysbiol.cam.ac.uk_&d=DwIGaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=ECJZN8XlNzgWTqEBbZjafknjX8AFaP25P-pVVk1_FnI&s=8m_hDI6K7TnMToJXMG5Ud2QFHJfsppSA93X-dX5rne0&e=
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lgatto.github.io_&d=DwIGaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=ECJZN8XlNzgWTqEBbZjafknjX8AFaP25P-pVVk1_FnI&s=n_IeMmaEdWX1VL_8OXRo8V20H4tUGDol4ESVrf8eUVg&e=
>>>
>>> _______________________________________________
>>> Bioc-devel at r-project.org mailing list
>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_bioc-2Ddevel&d=DwIGaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=ECJZN8XlNzgWTqEBbZjafknjX8AFaP25P-pVVk1_FnI&s=hZlM1vvmu1PhUWy5mGpZ8c-eK0c8aILEnqQG4Wc12y0&e=
>>
>> _______________________________________________
>> Bioc-devel at r-project.org mailing list
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_bioc-2Ddevel&d=DwIGaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=ECJZN8XlNzgWTqEBbZjafknjX8AFaP25P-pVVk1_FnI&s=hZlM1vvmu1PhUWy5mGpZ8c-eK0c8aILEnqQG4Wc12y0&e=
>>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> Bioc-devel at r-project.org mailing list
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_bioc-2Ddevel&d=DwIGaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=ECJZN8XlNzgWTqEBbZjafknjX8AFaP25P-pVVk1_FnI&s=hZlM1vvmu1PhUWy5mGpZ8c-eK0c8aILEnqQG4Wc12y0&e=
>

-- 
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



More information about the Bioc-devel mailing list