[BioC] IRanges::unlist in package

James W. MacDonald jmacdon at uw.edu
Wed Aug 7 23:09:34 CEST 2013


Hi Marco,

On 8/7/2013 4:51 PM, Blanchette, Marco wrote:
> Dear all,
>
> First, sorry for the double posting on the r-help and bioC, my mistake… Never meant to send it to the r-help list as it is a bioC question. So here it is…
>
> I am writing a package with some of my favorite custom functions so that I can share them with others. I do not have a lot of experience building these packages and I apologize if this is a trivial question.
>
> The issue I am having is with the generic function unlist used to unlist GRangesList object (unlist(GRL) from the IRanges package)
>
> I have a function A in myPkg calling function B (myPkg::A{myPkg::B; …}), which is in the same package and call the unlist function of a GRangesList object (myPkg::B{ unlist(GRL); … }). For some reason, if I have the two function on the top level namespace, everything works, but when loaded from a package (library(myPkg); A(GRL)) it breaks at the unlist() step. However, if I fully qualify the unlist function in myPkgB (myPkg::B{IRanges::unlist(GRL); …} ), then calling A(GRL) after loading the myPkg library works.
>
> So, are we expected to always fully qualify the unlist() function? (i.e. Calling it with it's package name myPkg::B{ IRanges::unlist(GRL) } ). I have been trying all strategy of Depends: and Imports: in my DESCRIPTION file and nothing works unless I fully qualify this function.

I don't think you want to depend on IRanges if you only use this one 
function. Instead, you should be adding IRanges to the Imports list in 
your DEPENDS file, and using a NAMESPACE file that includes

importMethodsFrom(IRanges, unlist)

See

http://cran.r-project.org/doc/manuals/r-release/R-exts.html#Namespaces-with-S4-classes-and-methods

for more information.

Best,

Jim


>
> What is the best practice? I tried using only Imports: as suggested by Chambers but it breaks. Using Depends does not help.
> Am I having clashing namespace? Here is my Depends: (or Imports:) line: Depends: Rsamtools, GenomicFeatures, parallel, rtracklayer, edgeR
>
> Am I simply missing something?
>
> Thanks
>
> --  Marco Blanchette, Ph.D.
> Stowers Institute for Medical Research
> 1000 East 50th Street
> Kansas City MO 64110
> www.stowers.org
>
>
> 	[[alternative HTML version deleted]]
>
>
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor

-- 
James W. MacDonald, M.S.
Biostatistician
University of Washington
Environmental and Occupational Health Sciences
4225 Roosevelt Way NE, # 100
Seattle WA 98105-6099



More information about the Bioconductor mailing list