[BioC] FW: SetMethod for Combine

Martin Morgan mtmorgan at fhcrc.org
Sun May 23 00:36:43 CEST 2010


On 05/20/2010 10:22 AM, Mercier Eloi wrote:
> 
> Dear mailing list,
> 
> I'm developping a bioconductor package. I 'm using a method called "combine". This method is already defined in Biobase
> Thus, to avoid an overwriting of my method, I import the "combine" method from Biobase.
> 
> However, I get some difficulties to add new parameters to this method.
> 
>> library(Biobase)
> 
> setMethod("combine",
> signature(x="numeric", y="numeric"),
> function(x, y, test=TRUE,...)
> {
>     return(sum(x,y))
> })
> 
>> combine(1,2)
> [1] 3 #OK
>> combine(1,2, test=TRUE)
> Error in do.call(callGeneric, list(y, ...)) :
>   element 1 is empty;
>    the part of the args list of 'list' being evaluated was:
>    (y, ...)
> Error in combine(x, do.call(callGeneric, list(y, ...))) :
>   error in evaluating the argument 'y' in selecting a method for function 'combine'
> Error in combine(x, do.call(callGeneric, list(y, ...))) :
>   error in evaluating the argument 'y' in selecting a method for function 'combine'
> 
> 
> This is due to the definition of the method by Biobase :
> 
>> library(Biobase)
>> combine
> nonstandardGenericFunction for "combine" defined from package "Biobase"
> 
> function (x, y, ...)
> {
>     if (length(list(...)) > 0) {  #HERE IS MY PROBLEM
>         callGeneric(x, do.call(callGeneric, list(y, ...)))
>     }
>     else {
>         standardGeneric("combine")
>     }
> }
> <environment: 0x102ddea00>
> Methods may be defined for arguments: x, y
> Use  showMethods("combine")  for currently available ones.
> 
> The function's looking for futher arguments and calls different functions depending of that.
> I'm not able to enter inside the "else" if I add any arguments.
> 
> Is there any way to avoid that ?

Hi -- I don't know that there is a way to avoid this, short of revising
the 'combine' function, and since 'combine' is not elegant I'm open to
doing that. I was wondering whether your method is in the spirit of the
'combine' generic, which is to say, from  ?combine, 'given an arbitrary
number of arguments of the same class... combine them into a single
instance in a a sensible way',

Martin
> 
> Thanks.
> 
> ------------------------------------------
> Eloi Mercier
> Computational Biology, IRCM
> 110 av. Des Pins O.
> Montreal
> Canada, QC
> 
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor


-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793



More information about the Bioconductor mailing list