[BioC] Error when trying to build a package that needs to import GO.db, GOstats, ath1121501.db packages

Martin Morgan mtmorgan at fhcrc.org
Wed Oct 29 15:17:02 CET 2008


Hi Rich --

Rich Savage <r.s.savage at warwick.ac.uk> writes:

> Hi all,
>
> I am trying to build a small package that contains some specific
> functions to perform GO annotation and have encountered an error when
> running 'R CMD check' on the package I (try to) build.  Specifically:
>
> [1] "S4"
>             Length             Class              Mode
>              25369 GOTermsAnnDbBimap                S4
> TERM map for GO (object of class "GOTermsAnnDbBimap")
> Error in eapply(GOTERM, function(x) { : argument must be an environment
> Calls: WriteGoAnnotationToCsv -> AnnotateClusters -> unlist -> eapply
> Execution halted

eapply is a generic defined in base, but the method for bimaps (which
the GO object extends) is defined in AnnotationDbi.  So...

> The relevant code in my package (that generates the above) is:
>
>    print(mode(GOTERM))
>    print(summary(GOTERM))
>    print(GOTERM)
>    print(is.environment(GOTERM))
>
>    goTermMaster  <- unlist(eapply(GOTERM, function(x) {x at Term}));
>
>
> These functions work fine when I just 'source' them and run them via a
> script. The example in my package that 'check' is testing also runs

Likely your global environment has AnnotationDbi on its search() path
(you loaded AnnotationDbi, or one of the packages you've loaded has
AnnotationDbi in the Depends: field of their name space). In contrast,
inside your package, AnnotationDbi is likely NOT imported, and hence
not on the search path used by the name space. So...

> fine when I cut-and-paste it into R (having sourced the relevant
> functions).  Then problem only occurs with the package version.
>
> My concern is that I might not be importing something properly into my
> package.   My NAMESPACE file looks like this:
>
> export(WriteGoAnnotationToCsv)
> export(WriteGoAnnotationToLatex)
> import(GO.db)
> import(GOstats)
> import(ath1121501.db)

Your name space has access to 'base' by default, but not AnnotationDbi
& it's methods. When import the *db packages above you import the
maps, but not the methods that operate on them.

So what you need, I think, is

importMethodsFrom(AnnotationDbi, eapply)

with perahps other functions listed after eapply.

> (both the exports are my own functions)
>
>
> Finally, I've also noticed that when I use the above print statements
> in R on GOTERM, I get different info.  Compare:

These differences are likely because verrsions of 'mode', 'summary',
etc `work' on AnnotationDbi objects, but of course give the
information the base version is supposed to give. The in-R versions
are finding the AnnotationDbi-defined methods. This is a variant of
your original problem.

Hope that helps, and is not too misleading.

Martin

> CODE
> ----
> print(mode(GOTERM))
> print(summary(GOTERM))
> print(GOTERM)
>
>
> PACKAGE-BUILDING
> ----------------
> [1] "S4"
>             Length             Class              Mode
>              25369 GOTermsAnnDbBimap                S4
> TERM map for GO (object of class "GOTermsAnnDbBimap")
>
>
> IN R ITSELF
> -----------
>  >   print(mode(GOTERM))
> [1] "S4"
>  >   print(summary(GOTERM))
> TERM map for GO (object of class "GOTermsAnnDbBimap")
> |
> | Lkeyname: go_id (Ltablename: go_term)
> |    Lkeys: "GO:0000001", "GO:0000002", ... (total=25369/mapped=25369)
> |
> | Rkeyname: go_id (Rtablename: go_term)
> |    Rkeys: "GO:0000001", "GO:0000002", ... (total=25369/mapped=25369)
> |
> | direction: L --> R
> NULL
>  >   print(GOTERM)
> TERM map for GO (object of class "GOTermsAnnDbBimap")
>
>
>
>
>
> SESSION INFO
> R version 2.8.0 (2008-10-20)
> i386-apple-darwin8.11.1
>
> locale:
> en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8
>
> attached base packages:
> [1] splines   tools     stats     graphics  grDevices utils
> datasets methods   base
>
> other attached packages:
>   [1] BHC.GoAnnotation_1.2 ath1121501.db_2.2.7  GOstats_2.8.0
> Category_2.8.0
>   [5] genefilter_1.22.0    survival_2.34-1      RBGL_1.18.0
> annotate_1.20.0
>   [9] xtable_1.5-4         graph_1.20.0         GO.db_2.2.5
> RSQLite_0.7-0
> [13] DBI_0.2-4            AnnotationDbi_1.4.0  Biobase_2.2.0
> BHC_1.2.0 
>
>
> loaded via a namespace (and not attached):
> [1] GSEABase_1.4.0  XML_1.98-1      cluster_1.11.11
>
>
>
> Thanks very much for any help you can offer!
>
> Rich
>
>
> -- 
> ------------------------------------------------------------------
>    Dr. Richard Savage			Tel: +44 (0)24 765 50243
>    Systems Biology Centre		
>    University of Warwick
>    Coventry
>    CV4 7AL
>    United Kingdom
>
>    Web:  http://www.programming4scientists.com/
>    	http://wsbc.warwick.ac.uk/~richsavage/
>
> _______________________________________________
> 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

-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M2 B169
Phone: (206) 667-2793



More information about the Bioconductor mailing list