[BioC] IRanges: as.matrix.RangesMatching not found with NAMESPACE
Patrick Aboyoun
paboyoun at fhcrc.org
Thu Mar 25 17:32:21 CET 2010
Michael,
The answer is in the Writing R Extensions manual:
http://cran.r-project.org/doc/manuals/R-exts.html#Package-name-spaces
"Note that adding a name space to a package changes the search strategy.
The package name space comes first in the search, then the imports, then
the base name space and then the normal search path."
Since the (S3) generic for as.matrix is in the base package it is
retrieved instead of the implicit S4 generic that is defined in IRanges.
The solution to this problem is to make IRanges and Imports in the
DESCRIPTION file and add import(IRanges) to the NAMESPACE file.
Patrick
On 3/25/10 7:03 AM, Michael Dondrup wrote:
> Hi,
>
> I made a package depending on IRanges. When I try to use as.matrix on a RangesMatching object,
> there is an error message, if I don't have a NAMESPACE or I just source the file it works. Am I doing something wrong?
> I made a reproducible example, used package skeleton to build the package for this.
> The whole test -package is available at:
>
> http://www.bccs.uni.no/~mdo041/anRpackage/
>
>
> #require (IRanges)
>
> doit<- function() {
> query<- IRanges(c(1, 4, 9), c(5, 7, 10))
> subject<- IRanges(c(2, 2, 10), c(2, 3, 12))
> tree<- IntervalTree(subject)
>
> ## check if it works?
> ol = findOverlaps(query, tree, multiple = TRUE) # c(2, NA, 3)
> print (ol)
> print (typeof(ol))
> as.matrix(ol)
> }
>
> NAMESPACE:
> exportPattern("^[[:alpha:]]+")
>
>
>
> Here is the output:
>
>
>
>> library(anRpackage)
>>
> Loading required package: IRanges
>
> Attaching package: 'IRanges'
>
>
> The following object(s) are masked from package:base :
>
> Map,
> cbind,
> mapply,
> order,
> pmax,
> pmax.int,
> pmin,
> pmin.int,
> rbind,
> rep.int,
> table
>
>
>> doit()
>>
> An object of class "RangesMatching"
> Slot "matchMatrix":
> query subject
> [1,] 1 2
> [2,] 1 1
> [3,] 3 3
>
> Slot "DIM":
> [1] 3 3
>
> [1] "S4"
> Error in as.vector(data) :
> no method for coercing this S4 class to a vector
>
>
> And that is the output when there is no NAMESPACE
>
>
>> library(anRpackage)
>>
> Loading required package: IRanges
>
> Attaching package: 'IRanges'
>
>
> The following object(s) are masked from package:base :
>
> Map,
> cbind,
> mapply,
> order,
> pmax,
> pmax.int,
> pmin,
> pmin.int,
> rbind,
> rep.int,
> table
>
>
>> doit()
>>
> An object of class "RangesMatching"
> Slot "matchMatrix":
> query subject
> [1,] 1 2
> [2,] 1 1
> [3,] 3 3
>
> Slot "DIM":
> [1] 3 3
>
> [1] "S4"
> query subject
> [1,] 1 2
> [2,] 1 1
> [3,] 3 3
>
>>
>
>
>> sessionInfo()
>>
> R version 2.10.1 (2009-12-14)
> x86_64-apple-darwin9.8.0
>
> locale:
> [1] C
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] anRpackage_1.0 IRanges_1.4.16
>
> loaded via a namespace (and not attached):
> [1] tools_2.10.1
>
>>
>
> Best
>
>
>
> Michael Dondrup
> Post-doctoral researcher
> Uni BCCS
> Thormøhlensgate 55, N-5008 Bergen, Norway
>
> _______________________________________________
> 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
>
More information about the Bioconductor
mailing list