[Bioc-devel] Making non-bioconductor packages play nice with bioc (and vice versa)

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Sep 5 20:29:49 CEST 2011


I guess this could go here or r-devel, so apologies in advance if
you'd rather I send the question there.

I'm helping to develop a package which is outside the bioc universe
(data.table[1]) which I'm trying to get to play nice with the
bioc-verse (particularly IRanges), but running into some problems.

data.table was (and still is) written in using S3, and I've been
adding some functionality for it to respond to some S4-isms.

In order to sneak around some limitation of S3's dispatch on
cbind/rbind, I'm currently experimenting with redefining its cbind and
rbind functions to use S4 dispatch, but I can't seem to find a way to
define and export these functions in a way that won't trample IRange's
cbind/rbind's definitions (or vice versa).

I've tried to "guard" against an already defined cbind generic (say,
from IRanges), like:

if (!isGeneric("cbind")) {
  setGeneric("cbind", function(..., deparse.level=1)
standardGeneric("cbind"), signature="...")

but exporting cbind from data.table's NAMESPACE will trample the cbind
methods from IRanges (if IRanges is loaded first). Loading IRanges
after data.table will hose the cbind/rbind defined in data.table.

I guess one way to do it is to importFrom(IRanges, cbind, rbind) in
data.table's NAMESPACE, but it wouldn't really be appropriate to
introduce an IRanges dependency to data.table.

>From reading through the R-exts doc, I get the feeling that what I'm
trying to do is not possible, but maybe there's a way for me to do
this that I'm overlooking?

Will two different packages that declare and implement S4 functions by
the same name always trample over one another unless one of them
imports these functions from the other?

And a random (somehow related), stylistic question. Out of curiosity:
why doesn't IRanges "export" rbind,cbind through the exportMethods()
directive, since its an S4/generic (instead of just export())?



[1] data.table: http://cran.r-project.org/web/packages/data.table/index.html

Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

More information about the Bioc-devel mailing list