[Bioc-devel] Importing generic functions from other pkgs and defining methods on them?

Seth Falcon sfalcon at fhcrc.org
Fri Mar 9 00:57:26 CET 2007


Hi Wolfgang,

Wolfgang Huber <huber at ebi.ac.uk> writes:
> Hi,
>
> I post this problem to the list b/c perhaps others have it as well and
> so we only need to solve it once. Something with S4 and Namespaces
> appears to have changed. With the current R-devel, I get from "R CMD
> check tilingArray":
>
>     .... SNIP ...
> * checking package vignettes in 'inst/doc' ... WARNING
> *** Weave Errors ***
> File
> /net/nfs7/vol6/research-huber/users/huber/madman/Rpacks/tilingArray.Rcheck/tilingArray/doc/findsegments.Rnw
> :
> Error :  chunk 8 (label=penLLsim)
> Error in logLik(seg) : no applicable method for "logLik"
>
> When I run Sweave on the vignette interactively, there is no error!
> Also, the package used to pass R CMD check a while ago, and has not
> changed - but of course R has changed. In my NAMESPACE I have:
>
>   importFrom("stats", "confint", "logLik", "residuals")
>
> and in tilingArray/R/methods-segmentation.R
>
> setMethod("logLik", "segmentation",
>   function(object, penalty="none", ...) {
>     ## BLA
>   })
>
> Does anybody have a pointer for where to look at?

I had a quick look and it is strange.  

logLik is an S3 generic defined in stats.  You import it and define an
S4 generic with the same name using the S3 generic as default.

At the command line, you get the S4 generic.  Within your package
code -- e.g. if you debug inside tilingArray:::plotPenLL -- then you
get the one that was imported, that is, the S3 generic.  This causes
the error.

I thought at first it was the lack of a Collate field and that the
plotPenLL was being defined before the generic, but that isn't the
issue.

I have to run right now, but you might want to try calling
tilingArray::logLik inside plotPenLL and see if that helps.  That
would be a temporary fix.

A bit more investigation is needed.  This could be a bug in
R/methods/namespace.

Best,

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org



More information about the Bioc-devel mailing list