[Bioc-devel] importing packages without a name space

Seth Falcon sfalcon at fhcrc.org
Mon Apr 16 16:25:13 CEST 2007

"Laurent Gatto" <L.Gatto at dnavision.be> writes:
> Hello again,
> Thanks to Seth and Holger for their answers, but I still can not get it
> working. I will provide more details.
> I have to load two packages, geneplotter and simpleaffy and my package
> (yaqcaffy) defines YAQCStats, a subclass of simpleaffy's QCStats class.
> As geneplotter provides a name space, I load the required function with
> 'importFrom(geneplotter,smoothScatter)' in NAMESPACE. I also added 
> .onLoad <-  function(lib,pkg) require(methods) 
> in R/zzz.R and geneplotter on the 'Imports' line in DESCRIPTION.
> For simpleaffy, I do not import it in NAMESPACE, but add it as a
> dependency in DESCRIPTION. Here is the .Fist.lib function as defined in
> R/zzz.R:
> .First.lib <-  function(lib,pkg,where) { 
>     require(simpleaffy,quietly=TRUE);
>     # Find what position in the search path this package is 
>     where <- match(paste("package:", pkg, sep=""), search());
>     .initClassesAndMethods(where);
>     cacheMetaData(as.environment(where));
>     .createYAQCEnvironment()
> }

If your package has a NAMESPACE file then the package initialization
function that will be run is .onLoad and .First.lib will be ignored.
So I'm pretty sure all of the code in .First.lib is not getting run.

But are you sure you need all of that code anyhow?  It looks to me
like you have copy/pasted from another package (I'd like to know which
one because perhaps it is not needed there either).  There was a time
long ago when S4 using packages needed such an arrangement, but in
general they no longer do (there are a few cases, but I doubt your
package is among them).

So I'm guessing that .initClassesAndMethods() contains all of your
setClass and setMethod calls.  Can you try just putting those at the
package level in your R code?  

What does .createYAQCEnvironment do?

Have you exported all classes and methods in your NAMESPACE file?

Perhaps you want to post your DESCRIPTION file as well, R is fairly
picky about the syntax and I'd like to rule that out.

+ seth

Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center

More information about the Bioc-devel mailing list