[BioC] Category R CMD check and not reloading required packages

Robert M. Flight rflight79 at gmail.com
Thu Mar 3 15:47:50 CET 2011


Hi Martin,

Thanks for that. I knew it would be hard to spot what was going on
without having a reproducible example that did not depend on the
functions in the package I'm developing. I spent a day hunting down
the bug and figuring out a way to reproduce my problem. Originally it
was extremely confusing because the example was running a wrapper
function that uses the one that was failing, making it a pain in the
butt to figure out just what it was that was going wrong. And running
the examples independently worked too. It was only running them
sequentially following cleanEx() that things start to go haywire.

-Robert

On Thu, Mar 3, 2011 at 09:33, Martin Morgan <mtmorgan at fhcrc.org> wrote:
> On 03/03/2011 06:21 AM, Sean Davis wrote:
>> On Thu, Mar 3, 2011 at 8:47 AM, Robert M. Flight <rflight79 at gmail.com>wrote:
>>
>>> Hi All,
>>>
>>> I am developing a package that depends on Category. As part of my
>>> package development, I decided that I should use R CMD check and
>>> documentation examples to verify that my functions are working
>>> properly. Unfortunately, it appears that after the "cleanEx()"
>>> function removes certain packages that are used to access annotation
>>> packages (DBI and RSQLITE), they don't get reloaded again for the next
>>> example, even though it consists of very similar code. I have a toy
>>> example below that fails in exactly the same way that my actual
>>> examples do.
>>>
>>> >From what I can tell using search(), the important package that is not
>>> getting reloaded is "DBI". Should I simply include that in the
>>> "library" call in my examples, or is this something that should be
>>> fixed somewhere else?
>>>
>>>
>> The examples are meant to be independent of each other, so loading a package
>> in one example does not mean it is loaded in another example.
>>
>> There are a few ways to deal with this:
>>
>> 1)  Use library() in every example.  You may want to fail gracefully by
>> using require() and an if statement.  You will want to consider adding the
>> required packages to "suggests" in DESCRIPTION.
>> 2)  Label the examples as doNotRun.  The downside is that you don't get
>> example checking, obviously.
>> 3)  Add the required Imports to the NAMESPACE and DESCRIPTION files.
>>
>> These types of questions are probably best asked on the bioc-devel list, so
>> if you have further questions, you could start a new thread there.
>
> Actually, I think there's a NAMESPACE problem with annotate; it should
> Import: DBI and importMethodsFrom(DBI, dbGetQuery). In Robert's example
> (thanks for providing that) ID2EntrezID fails to find dbGetQuery the
> second time round, but it shouldn't be relying on DBI being on the user
> search path (compare sessionInfo() after each cleanEx(), and you'll see
> that DBI is still in the list of attached packages). Fix should be
> available shortly.
>
> Robert -- please consider using R-devel during package development;
> this'll be the version in which your users will first see your package.
>
> Martin
>
>>
>> Sean
>>
>>
>>
>>> Thanks,
>>>
>>> -Robert
>>>
>>>
>>> ### Run using "R --vanilla" to be similar to R CMD check, but still
>>> fails in a normal R session as well
>>> source(file.path(R.home("share"), "R", "examples-header.R"))
>>> options(warn = 1)
>>> options(pager = "console")
>>>
>>> library('Category')
>>>
>>> assign(".oldSearch", search(), pos = 'CheckExEnv')
>>>
>>> cleanEx()
>>>
>>> nameEx("Ex1")
>>> flush(stderr()); flush(stdout())
>>>
>>> library('org.Hs.eg.db')
>>> datPkg <- DatPkgFactory('org.Hs.eg.db')
>>> t1 <- mget('7083', ID2EntrezID(datPkg))
>>> t1
>>> search()
>>>
>>> cleanEx()
>>>
>>>
>>> nameEx("Ex2")
>>> flush(stderr()); flush(stdout())
>>>
>>> library('org.Hs.eg.db')
>>> datPkg <- DatPkgFactory('org.Hs.eg.db')
>>> search()             #### No DBI on the search list
>>> t1 <- unlist(mget('7083', ID2EntrezID(datPkg)))   ## and this does not work
>>> t1
>>>
>>>
>>> sessionInfo()
>>> R version 2.12.1 (2010-12-16)
>>> Platform: i386-pc-mingw32/i386 (32-bit)
>>>
>>> locale:
>>> [1] LC_COLLATE=English_United States.1252
>>> [2] LC_CTYPE=English_United States.1252
>>> [3] LC_MONETARY=English_United States.1252
>>> [4] LC_NUMERIC=C
>>> [5] LC_TIME=English_United States.1252
>>>
>>> attached base packages:
>>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>>
>>> other attached packages:
>>> [1] org.Hs.eg.db_2.4.6   Category_2.16.0      AnnotationDbi_1.12.0
>>> [4] Biobase_2.10.0
>>>
>>> loaded via a namespace (and not attached):
>>>  [1] annotate_1.28.0   DBI_0.2-5         genefilter_1.32.0 graph_1.28.0
>>>  [5] GSEABase_1.12.2   RBGL_1.26.0       RSQLite_0.9-4     splines_2.12.1
>>>  [9] survival_2.36-1   tools_2.12.1      XML_3.2-0.2       xtable_1.5-6
>>>
>>> Robert M. Flight, Ph.D.
>>> University of Louisville Bioinformatics Laboratory
>>> University of Louisville
>>> Louisville, KY
>>>
>>> PH 502-852-1809 (HSC)
>>> PH 502-852-0467 (Belknap)
>>> EM robert.flight at louisville.edu
>>> EM rflight79 at gmail.com
>>>
>>> Williams and Holland's Law:
>>>        If enough data is collected, anything may be proven by
>>> statistical methods.
>>>
>>> _______________________________________________
>>> 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
>>>
>>
>>       [[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
>
>
> --
> Computational Biology
> Fred Hutchinson Cancer Research Center
> 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109
>
> Location: M1-B861
> Telephone: 206 667-2793
>



More information about the Bioconductor mailing list