Skip to content

Commit

Permalink
Fix namespace issue with objects created onLoad. (#39)
Browse files Browse the repository at this point in the history
* Export `cell_type_map` from namespace.

* Use assignInNamespace

* Restore Makefile

* Fix roxygen object names

* Add missing title in roxygen output
  • Loading branch information
grst authored Apr 16, 2020
1 parent 663f9e4 commit d12d11c
Show file tree
Hide file tree
Showing 22 changed files with 162 additions and 45 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Imports:
sva,
GSEABase,
xCell,
MCPcounter
MCPcounter,
utils
Suggests:
testthat,
knitr,
Expand All @@ -47,4 +48,4 @@ Roxygen: list(markdown = TRUE)
LazyData: true
URL: https://icbi-lab.github.io/immunedeconv, https://github.com/icbi-lab/immunedeconv
BugReports: https://github.com/icbi-lab/immunedeconv/issues
RoxygenNote: 6.1.1
RoxygenNote: 7.1.0
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Generated by roxygen2: do not edit by hand

export(available_datasets)
export(cell_type_map)
export(cell_type_tree)
export(deconvolute)
export(deconvolute_cibersort)
export(deconvolute_epic)
Expand Down Expand Up @@ -35,3 +38,4 @@ importFrom(stats,na.omit)
importFrom(testit,assert)
importFrom(tibble,as_tibble)
importFrom(tibble,rowid_to_column)
importFrom(utils,assignInMyNamespace)
22 changes: 14 additions & 8 deletions R/cell_type_mapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
#' @importFrom dplyr select
#' @importFrom stats na.omit
#' @import magrittr
#'
#'
#' @name cell_type_mapping
NULL


#' Table mapping the cell types from methods/datasets to a single, controlled vocabulary.
#'
#' Columns: `method_dataset`, `method_cell_type`, `cell_type`.
#'
#' See `inst/extdata/cell_type_mapping.xlsx` for more details.
#'
#' @name cell_type_map
NULL
#' @export
cell_type_map = NULL
# gets attached on .onLoad, see zzz.R
.get_cell_type_map = function() {
readxl::read_xlsx(system.file("extdata", "cell_type_mapping.xlsx",
Expand All @@ -34,14 +33,16 @@ NULL
#' A list of all methods (e.g. `cibersort`) and datasets (e.g. `schelker_ovarian`) for
#' that the cell types are mapped to the controlled vocabulary.
#'
#' @name available_datasets
NULL
#' @export
available_datasets = NULL
# gets attached on .onLoad, see zzz.R
.get_available_datasets = function() {
cell_type_map %>% pull(method_dataset) %>% unique()
}


#' List with controlled cell-type vocabulary
cell_type_list = NULL
.get_cell_type_list = function() {
tmp_list = readxl::read_excel(system.file("extdata", "cell_type_mapping.xlsx",
package="immunedeconv", mustWork=TRUE),
Expand All @@ -57,14 +58,19 @@ NULL
#'
#' @details a `data.tree` object
#' @name cell_type_tree
NULL
#' @export
cell_type_tree = NULL
# gets attached on .onLoad, see zzz.R
.get_cell_type_tree = function() {
cell_type_list %>% as.data.frame() %>% data.tree::FromDataFrameNetwork()
}


# Access nodes by name in O(1). Node names are unique in our tree.
#' Lookup dictionary for cell-type nodes
#'
#' Access nodes by name in O(1). Node names are unique in our tree.
#' gets attached on .onLoad, see zzz.R
node_by_name=NULL
# gets attached on .onLoad, see zzz.R
.get_node_by_name = function() {
cell_type_tree$Get(function(node){node})
Expand Down
4 changes: 3 additions & 1 deletion R/immune_deconvolution_methods.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#' Collection of immune cell deconvolution methods.
#'
#'
#' @description Immunedeconv is an an R package for unified access to computational methods for
#' estimating immune cell fractions from bulk RNA sequencing data.
#' @docType package
#' @name immunedeconv
#' @import methods
Expand Down
25 changes: 14 additions & 11 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# assign the following global variables
# .onLoad because of 'staged-install'
#
# See https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html
# for more details.
#
#' assign the following global variables
#' .onLoad because of 'staged-install'
#'
#' See https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html
#' for more details.
#'
#' @name fix_namespace
#' @importFrom utils assignInMyNamespace
NULL

.onLoad = function(libname, pkgname) {
assign('cell_type_map', .get_cell_type_map(), envir=.GlobalEnv)
assign('available_datasets', .get_available_datasets(), envir=.GlobalEnv)
assign('cell_type_list', .get_cell_type_list(), envir=.GlobalEnv)
assign('cell_type_tree', .get_cell_type_tree(), envir=.GlobalEnv)
assign('node_by_name', .get_node_by_name(), envir=.GlobalEnv)
assignInMyNamespace('cell_type_map', .get_cell_type_map())
assignInMyNamespace('available_datasets', .get_available_datasets())
assignInMyNamespace('cell_type_list', .get_cell_type_list())
assignInMyNamespace('cell_type_tree', .get_cell_type_tree())
assignInMyNamespace('node_by_name', .get_node_by_name())
}
8 changes: 8 additions & 0 deletions man/available_datasets.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions man/cell_type_list.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions man/cell_type_map.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions man/cell_type_tree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/dataset_racle.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions man/deconvolute.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions man/deconvolute_cibersort.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions man/deconvolute_mcp_counter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/deconvolute_quantiseq.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions man/deconvolute_quantiseq.default.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions man/deconvolute_xcell.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/deconvolution_methods.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions man/fix_namespace.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/immunedeconv.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions man/node_by_name.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/timer_available_cancers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/xCell.data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d12d11c

Please sign in to comment.