Can anyone help me understand why requireNamespace("org.Hs.eg.db") not only loads the needed name spaces, but also loads DBI and RSQLite into the search space? It isn't usual practice in R that loading a name space will have a side-effect like this. For example requireNamespace("AnnotationDbi") doesn't add anything to the search path, even though AnnotationDbi uses both DBI and RSQLite.
Is loading into the search path somehow required because org.Hs.eg.db objects are stored as SQL databases?
Or is it perhaps not even intended?
For the sake of specificity, I've asked about org.Hs.eg.db, but the same question applies to GO.db and to all the organism packages.
Here's some example code. In a new R session, we have just the usual R core packages and name spaces loaded.
> loadedNamespaces() [1] "graphics" "utils" "grDevices" "stats" "datasets" "methods" "base" > search() [1] ".GlobalEnv" "package:stats" "package:graphics" "package:grDevices" [5] "package:utils" "package:datasets" "package:methods" "Autoloads" [9] "package:base"
After loading the org.Hs.eg.db name space, a number of additional name spaces appear:
> requireNamespace("org.Hs.eg.db") Loading required namespace: org.Hs.eg.db Loading required package: DBI > loadedNamespaces() [1] "org.Hs.eg.db" "IRanges" "graphics" "parallel" "DBI" "utils" [7] "grDevices" "stats" "Biobase" "AnnotationDbi" "datasets" "RSQLite" [13] "S4Vectors" "methods" "BiocGenerics" "stats4" "base"
which was not unexpected, but DBI and RSQLite get added to the search path:
> search() [1] ".GlobalEnv" "package:RSQLite" "package:DBI" "package:stats" "package:graphics" [6] "package:grDevices" "package:utils" "package:datasets" "package:methods" "Autoloads" [11] "package:base"
which I didn't expect.
A secondary question: why there a message telling me that DBI has been loaded but no similar message for RSQLite?
> sessionInfo() R Under development (unstable) (2016-03-14 r70331) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 locale: [1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 [3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C [5] LC_TIME=English_Australia.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] RSQLite_1.0.0 DBI_0.3.1 loaded via a namespace (and not attached): [1] org.Hs.eg.db_3.3.0 IRanges_2.5.42 parallel_3.3.0 Biobase_2.31.3 [5] AnnotationDbi_1.33.7 S4Vectors_0.9.46 BiocGenerics_0.17.4 stats4_3.3.0
Thanks Martin. My naive reading of the code is that RSQLite is already imported, so that SQLite() can be replaced by RSQLite::SQLite() and library(RSQLite) is unnecessary.