[Bioc-devel] How to extend nonstandardGenericFunction

Elizabeth Purdom epurdom @ending from @t@t@berkeley@edu
Fri Oct 19 18:07:50 CEST 2018


Hello,

In my package (`clusterExperiment`) I want to extend a S4 method from a package `phylobase` for my class. However, in the phylobase package, all of the `setGeneric` calls are in the form of 

setMethod("nTips", signature(x="phylo"),
 function(x) {
     Ntip(x)
})

Namely, they use braces in their function definitions, which I have just learned creates a `nonstandardGenericFunction` rather than a `standardGeneric`. Because of this I can’t just do `importMethodFrom` and then just extend the method. And if I try to create my own `standardGeneric` (e.g. https://stat.ethz.ch/R-manual/R-devel/library/methods/html/Methods_for_Nongenerics.html <https://stat.ethz.ch/R-manual/R-devel/library/methods/html/Methods_for_Nongenerics.html>) I can no longer call  the function in the original `phylobase` package, i.e. for the original class for which it is applied.

My only solution appears to be if I put `phylobase` in the `Depends` section, at which point I can then extend their generics. But this gives my package the significant warning:

" Warning: replacing previous import ‘phylobase::plot’ by ‘graphics::plot’ when loading ‘clusterExperiment’”

My question is whether there is anything I can do on my end to either 1) extend phylobase generics without a depends statement or 2) to get rid of the warning about the imports (I have made sure to use `graphics::plot` in all of my functions’ calls to plot to make sure there is no problem with the import conflict)? 

Or is my only hope to have the developers of the package fix their calls?   Personally, I was going to strip my setGeneric calls of braces after this experience, since I also have braces in my call but not for any good reason. Is there a good reason that setGenerics might have the braces in their calls? (Hadley’s Advanced R seems to say no, perhaps for this reason https://adv-r.hadley.nz/s4.html#generics-and-methods <https://adv-r.hadley.nz/s4.html#generics-and-methods>). Does using braces keep you from colliding with future developers or other packages? 

Thanks,
Elizabeth





	[[alternative HTML version deleted]]



More information about the Bioc-devel mailing list