[Bioc-devel] NAMESPACE question

Martin Morgan mtmorgan at fhcrc.org
Mon Oct 6 19:24:23 CEST 2014

On 10/05/2014 01:39 PM, Robert Castelo wrote:
> hi,
> i have the following warning message when installing the devel version
> (0.99.5) of my package 'qpgraph':
> ** testing if installed package can be loaded
> Warning: replacing previous import by 'IRanges::as.vector' when loading
> 'qpgraph'
> * DONE (qpgraph)
> after investigating the issue i think it has to do with the fact that in
> the NAMESPACE of 'qpgraph' i'm importing the whole Matrix package and
> later the 'as.vector()' method defined in IRanges. The NAMESPACE file
> looks like this:
> useDynLib(qpgraph)
> import(methods)
> import(graph)
> import(Matrix)
> ... (few lines later) ...
> importMethodsFrom(IRanges,
>                                   as.vector)
> ... (rest of the file) ...
> from what i have learned while reading documentation and googling about
> this issue, it seems that the solution would be to import every
> function/method i use from Matrix before i do the import from IRanges,
> but i use the dspMatrix-class all over the package and i don't know how
> would i find out what set of functions/methods i have to explicitly
> import. i can import a few of the methods from Matrix i know from the
> top of my head that the package is using but i'm afraid i'll be missing
> other methods that will break the package when using it in situations
> outside current examples and unit tests.
> i'd appreciate if you have a suggestion about what to do in this situation.

There are two 'as.vector' generics, one defined in Matrix and one in 
BiocGenerics (and made available via IRanges). These generics have different methods

 > showMethods(Matrix::as.vector)
Function: as.vector (package base)
x="abIndex", mode="ANY"
x="abIndex", mode="character"
x="ANY", mode="ANY"
x="dgCMatrix", mode="missing"
x="dgeMatrix", mode="missing"
x="diagonalMatrix", mode="missing"
x="dsCMatrix", mode="missing"
x="ldenseMatrix", mode="missing"
x="Matrix", mode="missing"
x="ndenseMatrix", mode="missing"
x="sparseVector", mode="character"
x="sparseVector", mode="missing"

 > showMethods(BiocGenerics::as.vector)
Function: as.vector (package BiocGenerics)

so it's important that your code clearly distinguish between generics. One 
possibility is to remove importMethodsFrom(IRanges, as.vector) from the 
NAMESPACE, and explicitly use IRanges::as.vector(...) in your code.

codetoolsBioC::writeNamespaceImports("qpgraph") might provide you with some 
guidance (it's not 100% reliable; available via svn at 
https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/codetoolsBioC) about 
what functionality is being imported.


> thanks!
> robert.
> 	[[alternative HTML version deleted]]
> _______________________________________________
> Bioc-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel

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 Bioc-devel mailing list