Error when trying to build a package that needs to import GO.db, GOstats, ath1121501.db packages
1
0
Entering edit mode
@martin-morgan-1513
Last seen 2 days ago
United States
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
Annotation GO Cancer ath1121501 AnnotationDbi BHC Annotation GO Cancer ath1121501 BHC • 1.4k views
ADD COMMENT
0
Entering edit mode
Rich Savage ▴ 60
@rich-savage-3040
Last seen 8.6 years ago
University of Warwick, UK
Hi Martin, That worked perfectly! Thanks :-) I added the following line to my NAMESPACE file: importMethodsFrom(AnnotationDbi, eapply) Plus, I changed my DESCRIPTION file to include this dependency: Depends: methods, BHC, GO.db, GOstats, ath1121501.db, AnnotationDbi ('BHC' is my own package) My package now runs perfectly happily. Thanks again for your help, 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/ ------------------------------------------------------------------ Martin Morgan wrote: > 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 >
ADD COMMENT
0
Entering edit mode
Rich Savage wrote: > Hi Martin, > > That worked perfectly! Thanks :-) > > > I added the following line to my NAMESPACE file: > > importMethodsFrom(AnnotationDbi, eapply) > > > Plus, I changed my DESCRIPTION file to include this dependency: > > Depends: methods, BHC, GO.db, GOstats, ath1121501.db, AnnotationDbi I think you want AnnotationDbi (and perhaps the others, too) as Imports: This will make the content of the package available to your package (subject to Imports: statements in your name space) but not clutter the user name space with things they don't want/need. It's a little tricky to know whether that's really correct, though. For instance, if your package returns an object that is defined in AnnotationDbi, then probably your user wants to manipulate it and so needs to have AnnotationDbi available to them (and hence on their 'search' path, and in your 'Depends: field). We should probably have stopped at your first line, 'That worked perfectly!'. Martin > ('BHC' is my own package) > > > My package now runs perfectly happily. > > Thanks again for your help, > > Rich >
ADD REPLY

Login before adding your answer.

Traffic: 359 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6