[Bioc-devel] importing packages without a name space

Laurent Gatto L.Gatto at dnavision.be
Mon Apr 16 13:36:51 CEST 2007

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
.First.lib <-  function(lib,pkg,where) { 
    # Find what position in the search path this package is 
    where <- match(paste("package:", pkg, sep=""), search());

When I check the src of my package (or try to load it), I get the
following error:

Error in setIs(Class, class2, classDef = classDef, where = where) :
        Unable to find package environment for class "QCStats" to revise
subclass information	
Error in setClass("YAQCStats", contains = "QCStats",
representation(average.noise = "numeric",  :
        error in contained classes ("QCStats") for class "YAQCStats";
class definition removed from "yaqcaffy"
In addition: Warning message:
Couldn't find superclass "QCStats" to clean up when removing subclass
references to class "YAQCStats" in: .removeSuperclassBackRefs(Class,
classDef, classWhere)
Error : unable to load R code in package 'yaqcaffy'
Error: package/namespace load failed for 'yaqcaffy'
Execution halted

If I add 'importClassesFrom(simpleaffy, QCStats)' in the NAMESPACE file,
I get

Error : package 'simpleaffy' does not have a name space
Error: package/namespace load failed for 'yaqcaffy'
Execution halted

Note that I get the same error message if I ask to import simpleaffy in

Below is my sessionInfo() output after loading simpleaffy and

Thank you very much in advance,


Laurent Gatto

> sessionInfo()
R version 2.5.0 beta (2007-04-11 r41127)


attached base packages:
[1] "splines"   "tools"     "stats"     "graphics"  "grDevices" "utils"
[7] "datasets"  "methods"   "base"

other attached packages:
geneplotter     lattice    annotate  simpleaffy  genefilter    survival
   "1.13.8"    "0.15-3"    "1.13.8"     "2.9.3"   "1.13.14"      "2.31"
       affy      affyio     Biobase
  "1.13.19"     "1.2.0"   "1.13.49"

-----Original Message-----
From: Seth Falcon [mailto:sfalcon at fhcrc.org] 
Sent: Friday, April 13, 2007 7:59 PM
To: Laurent Gatto
Cc: bioc-devel at stat.math.ethz.ch
Subject: Re: [Bioc-devel] importing packages without a name space

Hi Laurent,

"Laurent Gatto" <L.Gatto at dnavision.be> writes:
> I have a problem with my NAMESPACE file. I need to import a package
> does not define a name space, and I always get the same error on
> import(), specifying that the package I try to load 'does not have a
> name space'. 

Actually, it is simply not possible to import from a package that does
not have a name space of its own.

> Note that I also need to import a class from that package with
> importClassFrom() which seems to work.

That is news to me; I would not expect it to work.

I think the best you can do when you are using code from a package
that does not have a NAMESPACE file is to put this package in the
Depends field.  

The next thing to do is send a friendly email to the package's
maintainer and ask that they add a name space to their package :-)

+ seth

Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research

More information about the Bioc-devel mailing list