[Bioc-devel] Nasty function collision

James W. MacDonald jmacdon at med.umich.edu
Tue Oct 31 20:08:05 CET 2006

Thanks for the input. However, I am not sure if any of these suggestions 
are applicable. I don't ever call getURL() directly; it gets called as a 
result of calling saveHTML() in annaffy, which outputs an HTML table, or 
it gets called by useMart() in biomaRt when trying to connect to a 
Biomart using the RCurl package.

It seems to me that Laurent has the best suggestion - getURL() in 
annaffy has a method:

setMethod("getURL", "ANY", function(object) {


Which to an S4 maven may be useful, but pretty much torches the getURL() 
in RCurl. It seems to me that this method isn't particularly useful (is 
it?), so maybe the best course of action is to convince Colin Smith to 
remove this particular method.

The other possibility is to get Steffen Durinck to change biomaRt to use 

Or am I still missing something?



Robert Gentleman wrote:
> That is IMHO pretty much it - not a problem, and why namespaces exist.
> I really think that you want to use iii) in preference to either i) or 
> ii), and if you only want that getURL then I would import it with that name.
> Seth Falcon wrote:
>>"James MacDonald" <jmacdon at med.umich.edu> writes:
>>>I am having a nasty function collision in my affycoretools package
>>>that is causing things to error out.  I have tracked the problem
>>>down to the getURL() functions that are defined in RCurl and
>>>annaffy. If I load RCurl first and then annaffy, getURL() is
>>>silently masked, probably because it is an S4 function in annaffy
>>>and a regular function in RCurl.
>>Since annaffy has a NAMESPACE, this is easy to resolve.  You can:
>>i) Make calls to annaffy::getURL where appropriate
>>ii) "Rename" annaffy's getURL function in your package code:
>>        annaffy_getURL <- annaffy::getURL
>>iii) Rename annaffy's getURL at import time:
>>       importFrom("annaffy", foo=getURL)
>>IMO, this sort of conflict is really not nasty at all.  What would be
>>nasty is to expect package developers to keep in mind the global name
>>space consisting of the union of all existing packages and to name
>>their functions accordingly.  
>>>If I do the opposite, R is nice enough to mention that I have just
>>>masked a function from annaffy. 
>>Seems odd that you only sometimes get a warning since both packages
>>have a name space.  But perhaps it depends on details of
>>import/require/depend, etc.
>>>In the past I got around this problem by importing annaffy rather than
>>>listing it in the Depends line in the DESCRIPTION file, and load()ing it
>>>when needed. This worked out OK because one is likely to be using either
>>>annaffy to create output, or biomaRt, but not usually both, so the
>>>masking problem was a moot point. Having annaffy in Imports ensured that
>>>things like biocLite() would automatically install it as a
>>Listing it in Imports in DESCRIPTION implies you really import it in
>>the NAMESPACE file -- and that means it gets loaded (but not attached
>>to the search path).
>>>Unfortunately now R CMD check complains about "'library' or 'require'
>>>calls not declared from: annaffy" and points me to Creating R Packages
>>>and the DESCRIPTION file entry, which doesn't really enlighten.
>>Separate issue which might have a reasonable workaround, but I think
>>you want i, ii, or iii above. :-)
>>+ seth
>>Bioc-devel at stat.math.ethz.ch mailing list

James W. MacDonald, M.S.
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109

Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues.

More information about the Bioc-devel mailing list