... | ... |
@@ -30,7 +30,7 @@ ad <- NULL |
30 | 30 |
#' @name sctkPythonInstallConda |
31 | 31 |
#' @title Installs Python packages into a Conda environment |
32 | 32 |
#' @description Install all Python packages used in the \code{\link{singleCellTK}} package |
33 |
-#' using \code{\link[reticulate]{conda_install}} from package \code{\link{reticulate}}. This |
|
33 |
+#' using \code{\link{conda_install}} from package \code{\link{reticulate}}. This |
|
34 | 34 |
#' will create a new Conda environment with the name \code{envname} if not already present. |
35 | 35 |
#' Note that Anaconda or Miniconda already need to be installed on the local system. |
36 | 36 |
#' @param envname Character. Name of the conda environment to create. |
... | ... |
@@ -42,15 +42,15 @@ ad <- NULL |
42 | 42 |
#' @param pipIgnoreInstalled Boolean. Ignore installed versions when using pip. This is TRUE by default so that specific package versions can be installed even if they are downgrades. |
43 | 43 |
#' The FALSE option is useful for situations where you don't want a pip install to attempt an overwrite of a conda binary package (e.g. SciPy on Windows which is very difficult |
44 | 44 |
#' to install via pip due to compilation requirements). |
45 |
-#' @param pythonVersion Passed to \code{python_version} variable in \code{\link[reticulate]{conda_install}}. Default NULL. |
|
46 |
-#' @param ... Other parameters to pass to \code{\link[reticulate]{conda_install}}. |
|
45 |
+#' @param pythonVersion Passed to \code{python_version} variable in \code{\link{conda_install}}. Default NULL. |
|
46 |
+#' @param ... Other parameters to pass to \code{\link{conda_install}}. |
|
47 | 47 |
#' @return None. Installation of Conda environment. |
48 | 48 |
#' @examples |
49 | 49 |
#' \dontrun{ |
50 | 50 |
#' sctkPythonInstallConda(envname = "sctk-reticulate") |
51 | 51 |
#' } |
52 |
-#' @seealso See \code{\link[reticulate]{conda_create}} for more information on creating a Conda environment. |
|
53 |
-#' See \code{\link[reticulate]{conda_install}} for more description of the installation parameters. |
|
52 |
+#' @seealso See \code{\link{conda_create}} for more information on creating a Conda environment. |
|
53 |
+#' See \code{\link{conda_install}} for more description of the installation parameters. |
|
54 | 54 |
#' See \url{https://rstudio.github.io/reticulate/} for more information on package \code{\link{reticulate}}. |
55 | 55 |
#' See \code{\link[singleCellTK]{selectSCTKConda}} for reloading the Conda environment if R is restarted without |
56 | 56 |
#' going through the whole installation process again. |
... | ... |
@@ -88,7 +88,7 @@ sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
88 | 88 |
#' @name sctkPythonInstallVirtualEnv |
89 | 89 |
#' @title Installs Python packages into a virtual environment |
90 | 90 |
#' @description Install all Python packages used in the \code{\link{singleCellTK}} package |
91 |
-#' using \code{\link[reticulate]{virtualenv_install}} from package \code{\link{reticulate}}. This |
|
91 |
+#' using \code{\link{virtualenv_install}} from package \code{\link{reticulate}}. This |
|
92 | 92 |
#' will create a new virtual environment with the name \code{envname} if not already present. |
93 | 93 |
#' @param envname Character. Name of the virtual environment to create. |
94 | 94 |
#' @param packages Character Vector. List of packages to install. |
... | ... |
@@ -99,8 +99,8 @@ sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
99 | 99 |
#' \dontrun{ |
100 | 100 |
#' sctkPythonInstallVirtualEnv(envname = "sctk-reticulate") |
101 | 101 |
#' } |
102 |
-#' @seealso See \code{\link[reticulate]{virtualenv_create}} for more information on creating a Conda environment. |
|
103 |
-#' See \code{\link[reticulate]{virtualenv_install}} for more description of the installation parameters. |
|
102 |
+#' @seealso See \code{\link{virtualenv_create}} for more information on creating a Conda environment. |
|
103 |
+#' See \code{\link{virtualenv_install}} for more description of the installation parameters. |
|
104 | 104 |
#' See \url{https://rstudio.github.io/reticulate/} for more information on package \code{\link{reticulate}}. |
105 | 105 |
#' See \code{\link[singleCellTK]{selectSCTKVirtualEnvironment}} for reloading the virtual environment if R is restarted without |
106 | 106 |
#' going through the whole installation process again. |
... | ... |
@@ -59,7 +59,7 @@ ad <- NULL |
59 | 59 |
sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
60 | 60 |
conda = "auto", |
61 | 61 |
packages = c("scipy", "numpy", "astroid", "six"), |
62 |
- pipPackages = c("scrublet", "scanpy", "bbknn", "scanorama", "anndata", "umap-learn"), |
|
62 |
+ pipPackages = c("scrublet", "scanpy", "bbknn", "scanorama", "anndata"), |
|
63 | 63 |
selectConda = TRUE, |
64 | 64 |
forge = FALSE, |
65 | 65 |
pipIgnoreInstalled = TRUE, |
... | ... |
@@ -106,7 +106,7 @@ sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
106 | 106 |
#' going through the whole installation process again. |
107 | 107 |
#' @export |
108 | 108 |
sctkPythonInstallVirtualEnv <- function(envname = "sctk-reticulate", |
109 |
- packages = c("scipy", "numpy", "astroid", "six", "scrublet", "scanpy", "scanorama", "bbknn", "anndata", "umap-learn"), |
|
109 |
+ packages = c("scipy", "numpy", "astroid", "six", "scrublet", "scanpy", "scanorama", "bbknn", "anndata"), |
|
110 | 110 |
selectEnvironment = TRUE, |
111 | 111 |
python = NULL) { |
112 | 112 |
|
... | ... |
@@ -59,7 +59,7 @@ ad <- NULL |
59 | 59 |
sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
60 | 60 |
conda = "auto", |
61 | 61 |
packages = c("scipy", "numpy", "astroid", "six"), |
62 |
- pipPackages = c("scrublet", "scanpy", "bbknn", "scanorama", "anndata"), |
|
62 |
+ pipPackages = c("scrublet", "scanpy", "bbknn", "scanorama", "anndata", "umap-learn"), |
|
63 | 63 |
selectConda = TRUE, |
64 | 64 |
forge = FALSE, |
65 | 65 |
pipIgnoreInstalled = TRUE, |
... | ... |
@@ -106,7 +106,7 @@ sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
106 | 106 |
#' going through the whole installation process again. |
107 | 107 |
#' @export |
108 | 108 |
sctkPythonInstallVirtualEnv <- function(envname = "sctk-reticulate", |
109 |
- packages = c("scipy", "numpy", "astroid", "six", "scrublet", "scanpy", "scanorama", "bbknn", "anndata"), |
|
109 |
+ packages = c("scipy", "numpy", "astroid", "six", "scrublet", "scanpy", "scanorama", "bbknn", "anndata", "umap-learn"), |
|
110 | 110 |
selectEnvironment = TRUE, |
111 | 111 |
python = NULL) { |
112 | 112 |
|
... | ... |
@@ -9,7 +9,6 @@ scipy <- NULL |
9 | 9 |
sparse <- NULL |
10 | 10 |
numpy <- NULL |
11 | 11 |
scnrm <- NULL |
12 |
-scgen <- NULL |
|
13 | 12 |
sc <- NULL |
14 | 13 |
bbknn <- NULL |
15 | 14 |
pkg_resources <- NULL |
... | ... |
@@ -22,7 +21,6 @@ ad <- NULL |
22 | 21 |
sparse <<- reticulate::import("scipy.sparse", delay_load = TRUE) |
23 | 22 |
numpy <<- reticulate::import("numpy", delay_load = TRUE) |
24 | 23 |
scnrm <<- reticulate::import("scanorama", delay_load = TRUE) |
25 |
- scgen <<- reticulate::import("scgen", delay_load = TRUE) |
|
26 | 24 |
sc <<- reticulate::import("scanpy", delay_load = TRUE) |
27 | 25 |
bbknn <<- reticulate::import("bbknn", delay_load = TRUE) |
28 | 26 |
pkg_resources <<- reticulate::import('pkg_resources',delay_load = TRUE) |
... | ... |
@@ -60,7 +58,7 @@ ad <- NULL |
60 | 58 |
sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
61 | 59 |
conda = "auto", |
62 | 60 |
packages = c("scipy", "numpy", "astroid", "six"), |
63 |
- pipPackages = c("scrublet", "scanpy", "bbknn", "scanorama", "scgen","anndata"), |
|
61 |
+ pipPackages = c("scrublet", "scanpy", "bbknn", "scanorama", "anndata"), |
|
64 | 62 |
selectConda = TRUE, |
65 | 63 |
forge = FALSE, |
66 | 64 |
pipIgnoreInstalled = TRUE, |
... | ... |
@@ -106,7 +104,7 @@ sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
106 | 104 |
#' going through the whole installation process again. |
107 | 105 |
#' @export |
108 | 106 |
sctkPythonInstallVirtualEnv <- function(envname = "sctk-reticulate", |
109 |
- packages = c("scipy", "numpy", "astroid", "six", "scrublet", "scanpy", "scanorama", "bbknn", "scgen","anndata"), |
|
107 |
+ packages = c("scipy", "numpy", "astroid", "six", "scrublet", "scanpy", "scanorama", "bbknn", "anndata"), |
|
110 | 108 |
selectEnvironment = TRUE, |
111 | 109 |
python = NULL) { |
112 | 110 |
|
... | ... |
@@ -25,15 +25,10 @@ ad <- NULL |
25 | 25 |
scgen <<- reticulate::import("scgen", delay_load = TRUE) |
26 | 26 |
sc <<- reticulate::import("scanpy", delay_load = TRUE) |
27 | 27 |
bbknn <<- reticulate::import("bbknn", delay_load = TRUE) |
28 |
-<<<<<<< HEAD |
|
29 | 28 |
pkg_resources <<- reticulate::import('pkg_resources',delay_load = TRUE) |
30 | 29 |
ad <<- reticulate::import('anndata',delay_load = TRUE,convert = FALSE) |
31 |
-======= |
|
32 |
- pkg_resources <<- reticulate::import('pkg_resources', delay_load = TRUE) |
|
33 |
->>>>>>> 4127090a0c04ab251d1357d8787f6c0ea2c648d5 |
|
34 | 30 |
} |
35 | 31 |
|
36 |
- |
|
37 | 32 |
#' @name sctkPythonInstallConda |
38 | 33 |
#' @title Installs Python packages into a Conda environment |
39 | 34 |
#' @description Install all Python packages used in the \code{\link{singleCellTK}} package |
... | ... |
@@ -28,7 +28,6 @@ ad <- NULL |
28 | 28 |
bbknn <<- reticulate::import("bbknn", delay_load = TRUE) |
29 | 29 |
pkg_resources <<- reticulate::import('pkg_resources',delay_load = TRUE) |
30 | 30 |
ad <<- reticulate::import('anndata',delay_load = TRUE,convert = FALSE) |
31 |
- blt <<- reticulate::import_builtins() |
|
32 | 31 |
} |
33 | 32 |
|
34 | 33 |
|
... | ... |
@@ -9,7 +9,6 @@ scipy <- NULL |
9 | 9 |
sparse <- NULL |
10 | 10 |
numpy <- NULL |
11 | 11 |
scnrm <- NULL |
12 |
-blt <- NULL |
|
13 | 12 |
scgen <- NULL |
14 | 13 |
sc <- NULL |
15 | 14 |
bbknn <- NULL |
... | ... |
@@ -25,8 +24,7 @@ pkg_resources <- NULL |
25 | 24 |
scgen <<- reticulate::import("scgen", delay_load = TRUE) |
26 | 25 |
sc <<- reticulate::import("scanpy", delay_load = TRUE) |
27 | 26 |
bbknn <<- reticulate::import("bbknn", delay_load = TRUE) |
28 |
- pkg_resources <<- reticulate::import('pkg_resources',delay_load = TRUE) |
|
29 |
- blt <<- reticulate::import_builtins() |
|
27 |
+ pkg_resources <<- reticulate::import('pkg_resources', delay_load = TRUE) |
|
30 | 28 |
} |
31 | 29 |
|
32 | 30 |
|
... | ... |
@@ -3,13 +3,12 @@ |
3 | 3 |
## https://rstudio.github.io/reticulate/articles/package.html |
4 | 4 |
## Meant to delay loading of python environmnet so user can set the python environment |
5 | 5 |
|
6 |
-# python modules to use |
|
6 |
+# python modules to use |
|
7 | 7 |
scrublet <- NULL |
8 | 8 |
scipy <- NULL |
9 | 9 |
sparse <- NULL |
10 | 10 |
numpy <- NULL |
11 | 11 |
scnrm <- NULL |
12 |
-blt <- NULL |
|
13 | 12 |
scgen <- NULL |
14 | 13 |
sc <- NULL |
15 | 14 |
bbknn <- NULL |
... | ... |
@@ -26,7 +25,6 @@ pkg_resources <- NULL |
26 | 25 |
sc <<- reticulate::import("scanpy", delay_load = TRUE) |
27 | 26 |
bbknn <<- reticulate::import("bbknn", delay_load = TRUE) |
28 | 27 |
pkg_resources <<- reticulate::import('pkg_resources',delay_load = TRUE) |
29 |
- blt <<- reticulate::import_builtins() |
|
30 | 28 |
} |
31 | 29 |
|
32 | 30 |
|
... | ... |
@@ -35,30 +33,30 @@ pkg_resources <- NULL |
35 | 33 |
#' @description Install all Python packages used in the \code{\link{singleCellTK}} package |
36 | 34 |
#' using \code{\link[reticulate]{conda_install}} from package \code{\link{reticulate}}. This |
37 | 35 |
#' will create a new Conda environment with the name \code{envname} if not already present. |
38 |
-#' Note that Anaconda or Miniconda already need to be installed on the local system. |
|
36 |
+#' Note that Anaconda or Miniconda already need to be installed on the local system. |
|
39 | 37 |
#' @param envname Character. Name of the conda environment to create. |
40 | 38 |
#' @param conda Character. Path to conda executable. Usue "auto" to find conda using the PATH and other conventional install locations. Default 'auto'. |
41 |
-#' @param packages Character Vector. List of packages to install from Conda. |
|
39 |
+#' @param packages Character Vector. List of packages to install from Conda. |
|
42 | 40 |
#' @param pipPackages Character Vector. List of packages to install into the Conda environment using 'pip'. |
43 | 41 |
#' @param selectConda Boolean. Run \code{\link[singleCellTK]{selectSCTKConda}} after installing all packages to select the Conda environment. Default TRUE. |
44 | 42 |
#' @param forge Boolean. Include the Conda Forge repository. |
45 | 43 |
#' @param pipIgnoreInstalled Boolean. Ignore installed versions when using pip. This is TRUE by default so that specific package versions can be installed even if they are downgrades. |
46 | 44 |
#' The FALSE option is useful for situations where you don't want a pip install to attempt an overwrite of a conda binary package (e.g. SciPy on Windows which is very difficult |
47 | 45 |
#' to install via pip due to compilation requirements). |
48 |
-#' @param pythonVersion Passed to \code{python_version} variable in \code{\link[reticulate]{conda_install}}. Default NULL. |
|
49 |
-#' @param ... Other parameters to pass to \code{\link[reticulate]{conda_install}}. |
|
46 |
+#' @param pythonVersion Passed to \code{python_version} variable in \code{\link[reticulate]{conda_install}}. Default NULL. |
|
47 |
+#' @param ... Other parameters to pass to \code{\link[reticulate]{conda_install}}. |
|
50 | 48 |
#' @examples |
51 | 49 |
#' \dontrun{ |
52 | 50 |
#' sctkPythonInstallConda(envname = "sctk-reticulate") |
53 | 51 |
#' } |
54 |
-#' @seealso See \code{\link[reticulate]{conda_create}} for more information on creating a Conda environment. |
|
52 |
+#' @seealso See \code{\link[reticulate]{conda_create}} for more information on creating a Conda environment. |
|
55 | 53 |
#' See \code{\link[reticulate]{conda_install}} for more description of the installation parameters. |
56 | 54 |
#' See \url{https://rstudio.github.io/reticulate/} for more information on package \code{\link{reticulate}}. |
57 |
-#' See \code{\link[singleCellTK]{selectSCTKConda}} for reloading the Conda environment if R is restarted without |
|
58 |
-#' going through the whole installation process again. |
|
55 |
+#' See \code{\link[singleCellTK]{selectSCTKConda}} for reloading the Conda environment if R is restarted without |
|
56 |
+#' going through the whole installation process again. |
|
59 | 57 |
#' See \url{https://docs.conda.io/en/latest/} for more information on Conda environments. |
60 | 58 |
#' @export |
61 |
-sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
|
59 |
+sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
|
62 | 60 |
conda = "auto", |
63 | 61 |
packages = c("scipy", "numpy", "astroid", "six"), |
64 | 62 |
pipPackages = c("scrublet", "scanpy", "bbknn", "scanorama", "scgen"), |
... | ... |
@@ -67,21 +65,21 @@ sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
67 | 65 |
pipIgnoreInstalled = TRUE, |
68 | 66 |
pythonVersion = NULL, |
69 | 67 |
...) { |
70 |
- |
|
68 |
+ |
|
71 | 69 |
path <- reticulate::conda_create(envname = envname, packages = "python", conda = conda) |
72 |
- |
|
70 |
+ |
|
73 | 71 |
for(i in packages) { |
74 |
- reticulate::conda_install(envname = envname, packages = i, conda = conda, |
|
72 |
+ reticulate::conda_install(envname = envname, packages = i, conda = conda, |
|
75 | 73 |
pip = FALSE, pip_ignore_installed = pipIgnoreInstalled, |
76 | 74 |
python_version = pythonVersion, ...) |
77 | 75 |
} |
78 |
- |
|
76 |
+ |
|
79 | 77 |
reticulate::conda_install(envname = envname, packages = pipPackages, |
80 | 78 |
pip = TRUE, pip_ignore_installed = pipIgnoreInstalled, |
81 | 79 |
python_version = pythonVersion, ...) |
82 |
- |
|
80 |
+ |
|
83 | 81 |
if(isTRUE(selectConda)) selectSCTKConda(envname = envname) |
84 |
- |
|
82 |
+ |
|
85 | 83 |
invisible(path) |
86 | 84 |
} |
87 | 85 |
|
... | ... |
@@ -93,32 +91,32 @@ sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
93 | 91 |
#' using \code{\link[reticulate]{virtualenv_install}} from package \code{\link{reticulate}}. This |
94 | 92 |
#' will create a new virtual environment with the name \code{envname} if not already present. |
95 | 93 |
#' @param envname Character. Name of the virtual environment to create. |
96 |
-#' @param packages Character Vector. List of packages to install. |
|
94 |
+#' @param packages Character Vector. List of packages to install. |
|
97 | 95 |
#' @param selectEnvironment Boolean. Run \code{\link[singleCellTK]{selectSCTKVirtualEnvironment}} after installing all packages to select the virtual environment. Default TRUE. |
98 | 96 |
#' @param python The path to a Python interpreter, to be used with the created virtual environment. When NULL, the Python interpreter associated with the current session will be used. Default NULL. |
99 | 97 |
#' @examples |
100 | 98 |
#' \dontrun{ |
101 | 99 |
#' sctkPythonInstallVirtualEnv(envname = "sctk-reticulate") |
102 | 100 |
#' } |
103 |
-#' @seealso See \code{\link[reticulate]{virtualenv_create}} for more information on creating a Conda environment. |
|
101 |
+#' @seealso See \code{\link[reticulate]{virtualenv_create}} for more information on creating a Conda environment. |
|
104 | 102 |
#' See \code{\link[reticulate]{virtualenv_install}} for more description of the installation parameters. |
105 | 103 |
#' See \url{https://rstudio.github.io/reticulate/} for more information on package \code{\link{reticulate}}. |
106 |
-#' See \code{\link[singleCellTK]{selectSCTKVirtualEnvironment}} for reloading the virtual environment if R is restarted without |
|
107 |
-#' going through the whole installation process again. |
|
104 |
+#' See \code{\link[singleCellTK]{selectSCTKVirtualEnvironment}} for reloading the virtual environment if R is restarted without |
|
105 |
+#' going through the whole installation process again. |
|
108 | 106 |
#' @export |
109 | 107 |
sctkPythonInstallVirtualEnv <- function(envname = "sctk-reticulate", |
110 | 108 |
packages = c("scipy", "numpy", "astroid", "six", "scrublet", "scanpy", "scanorama", "bbknn", "scgen"), |
111 | 109 |
selectEnvironment = TRUE, |
112 | 110 |
python = NULL) { |
113 |
- |
|
111 |
+ |
|
114 | 112 |
path <- reticulate::virtualenv_create(envname = envname, python = python) |
115 |
- |
|
113 |
+ |
|
116 | 114 |
for(i in packages) { |
117 | 115 |
reticulate::virtualenv_install(envname = envname, packages = i, ignore_installed = TRUE) |
118 | 116 |
} |
119 |
- |
|
117 |
+ |
|
120 | 118 |
if(isTRUE(selectEnvironment)) selectSCTKVirtualEnvironment(envname = envname) |
121 |
- |
|
119 |
+ |
|
122 | 120 |
invisible(path) |
123 | 121 |
} |
124 | 122 |
|
... | ... |
@@ -142,7 +140,7 @@ sctkPythonInstallVirtualEnv <- function(envname = "sctk-reticulate", |
142 | 140 |
selectSCTKConda <- function(envname = "sctk-reticulate") { |
143 | 141 |
condaList <- reticulate::conda_list() |
144 | 142 |
ix <- condaList$name == envname |
145 |
- |
|
143 |
+ |
|
146 | 144 |
if(!any(ix)) { |
147 | 145 |
stop(paste0("Environment '", envname, "', not found. Run sctkPythonInstallConda(envname = '", envname, "') to install Python packages into a conda environmanet with this name.")) |
148 | 146 |
} |
... | ... |
@@ -150,7 +148,7 @@ selectSCTKConda <- function(envname = "sctk-reticulate") { |
150 | 148 |
envs <- paste(condaList[ix,"python"], collapse="\n") |
151 | 149 |
warning(paste0("More than one Conda environment detected with the name '", envname, "'. Selecting the first one in the list:\n", envs)) |
152 | 150 |
} |
153 |
- |
|
151 |
+ |
|
154 | 152 |
reticulate::use_condaenv(condaenv = envname, required = TRUE) |
155 | 153 |
} |
156 | 154 |
|
... | ... |
@@ -172,13 +170,13 @@ selectSCTKConda <- function(envname = "sctk-reticulate") { |
172 | 170 |
selectSCTKVirtualEnvironment <- function(envname = "sctk-reticulate") { |
173 | 171 |
res <- reticulate::virtualenv_list() |
174 | 172 |
ix <- res == envname |
175 |
- |
|
173 |
+ |
|
176 | 174 |
if(!any(ix)) { |
177 | 175 |
stop(paste0("Environmnet '", envname, "', not found. Run selectSCTKVirtualEnvironment(envname = '", envname, "') to install Python packages into a virtual environmanet with this name.")) |
178 | 176 |
} |
179 | 177 |
if(sum(ix) > 1) { |
180 | 178 |
warning(paste0("More than one virtual environment detected with the name '", envname, "'. Selecting the first one in the list.")) |
181 | 179 |
} |
182 |
- |
|
180 |
+ |
|
183 | 181 |
reticulate::use_virtualenv(res[which(ix)[1]], required = TRUE) |
184 | 182 |
} |
... | ... |
@@ -14,6 +14,7 @@ scgen <- NULL |
14 | 14 |
sc <- NULL |
15 | 15 |
bbknn <- NULL |
16 | 16 |
pkg_resources <- NULL |
17 |
+ad <- NULL |
|
17 | 18 |
|
18 | 19 |
.onLoad <- function(libname, pkgname) { |
19 | 20 |
# use superassignment to update global reference to scipy |
... | ... |
@@ -26,6 +27,7 @@ pkg_resources <- NULL |
26 | 27 |
sc <<- reticulate::import("scanpy", delay_load = TRUE) |
27 | 28 |
bbknn <<- reticulate::import("bbknn", delay_load = TRUE) |
28 | 29 |
pkg_resources <<- reticulate::import('pkg_resources',delay_load = TRUE) |
30 |
+ ad <<- reticulate::import('anndata',delay_load = TRUE,convert = FALSE) |
|
29 | 31 |
blt <<- reticulate::import_builtins() |
30 | 32 |
} |
31 | 33 |
|
... | ... |
@@ -61,7 +63,7 @@ pkg_resources <- NULL |
61 | 63 |
sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
62 | 64 |
conda = "auto", |
63 | 65 |
packages = c("scipy", "numpy", "astroid", "six"), |
64 |
- pipPackages = c("scrublet", "scanpy", "bbknn", "scanorama", "scgen"), |
|
66 |
+ pipPackages = c("scrublet", "scanpy", "bbknn", "scanorama", "scgen","anndata"), |
|
65 | 67 |
selectConda = TRUE, |
66 | 68 |
forge = FALSE, |
67 | 69 |
pipIgnoreInstalled = TRUE, |
... | ... |
@@ -107,7 +109,7 @@ sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
107 | 109 |
#' going through the whole installation process again. |
108 | 110 |
#' @export |
109 | 111 |
sctkPythonInstallVirtualEnv <- function(envname = "sctk-reticulate", |
110 |
- packages = c("scipy", "numpy", "astroid", "six", "scrublet", "scanpy", "scanorama", "bbknn", "scgen"), |
|
112 |
+ packages = c("scipy", "numpy", "astroid", "six", "scrublet", "scanpy", "scanorama", "bbknn", "scgen","anndata"), |
|
111 | 113 |
selectEnvironment = TRUE, |
112 | 114 |
python = NULL) { |
113 | 115 |
|
... | ... |
@@ -96,7 +96,6 @@ sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
96 | 96 |
#' @param packages Character Vector. List of packages to install. |
97 | 97 |
#' @param selectEnvironment Boolean. Run \code{\link[singleCellTK]{selectSCTKVirtualEnvironment}} after installing all packages to select the virtual environment. Default TRUE. |
98 | 98 |
#' @param python The path to a Python interpreter, to be used with the created virtual environment. When NULL, the Python interpreter associated with the current session will be used. Default NULL. |
99 |
-#' @param ... Other parameters to pass to \code{\link[reticulate]{conda_install}}. |
|
100 | 99 |
#' @examples |
101 | 100 |
#' \dontrun{ |
102 | 101 |
#' sctkPythonInstallVirtualEnv(envname = "sctk-reticulate") |
... | ... |
@@ -13,6 +13,7 @@ blt <- NULL |
13 | 13 |
scgen <- NULL |
14 | 14 |
sc <- NULL |
15 | 15 |
bbknn <- NULL |
16 |
+pkg_resources <- NULL |
|
16 | 17 |
|
17 | 18 |
.onLoad <- function(libname, pkgname) { |
18 | 19 |
# use superassignment to update global reference to scipy |
... | ... |
@@ -24,7 +25,7 @@ bbknn <- NULL |
24 | 25 |
scgen <<- reticulate::import("scgen", delay_load = TRUE) |
25 | 26 |
sc <<- reticulate::import("scanpy", delay_load = TRUE) |
26 | 27 |
bbknn <<- reticulate::import("bbknn", delay_load = TRUE) |
27 |
- pkg_resources <- reticulate::import('pkg_resources',delay_load = TRUE) |
|
28 |
+ pkg_resources <<- reticulate::import('pkg_resources',delay_load = TRUE) |
|
28 | 29 |
blt <<- reticulate::import_builtins() |
29 | 30 |
} |
30 | 31 |
|
... | ... |
@@ -24,6 +24,7 @@ bbknn <- NULL |
24 | 24 |
scgen <<- reticulate::import("scgen", delay_load = TRUE) |
25 | 25 |
sc <<- reticulate::import("scanpy", delay_load = TRUE) |
26 | 26 |
bbknn <<- reticulate::import("bbknn", delay_load = TRUE) |
27 |
+ pkg_resources <- reticulate::import('pkg_resources',delay_load = TRUE) |
|
27 | 28 |
blt <<- reticulate::import_builtins() |
28 | 29 |
} |
29 | 30 |
|
... | ... |
@@ -8,6 +8,11 @@ scrublet <- NULL |
8 | 8 |
scipy <- NULL |
9 | 9 |
sparse <- NULL |
10 | 10 |
numpy <- NULL |
11 |
+scnrm <- NULL |
|
12 |
+blt <- NULL |
|
13 |
+scgen <- NULL |
|
14 |
+sc <- NULL |
|
15 |
+bbknn <- NULL |
|
11 | 16 |
|
12 | 17 |
.onLoad <- function(libname, pkgname) { |
13 | 18 |
# use superassignment to update global reference to scipy |
... | ... |
@@ -15,6 +20,11 @@ numpy <- NULL |
15 | 20 |
scipy <<- reticulate::import("scipy", delay_load = TRUE) |
16 | 21 |
sparse <<- reticulate::import("scipy.sparse", delay_load = TRUE) |
17 | 22 |
numpy <<- reticulate::import("numpy", delay_load = TRUE) |
23 |
+ scnrm <<- reticulate::import("scanorama", delay_load = TRUE) |
|
24 |
+ scgen <<- reticulate::import("scgen", delay_load = TRUE) |
|
25 |
+ sc <<- reticulate::import("scanpy", delay_load = TRUE) |
|
26 |
+ bbknn <<- reticulate::import("bbknn", delay_load = TRUE) |
|
27 |
+ blt <<- reticulate::import_builtins() |
|
18 | 28 |
} |
19 | 29 |
|
20 | 30 |
|
... | ... |
@@ -49,7 +59,7 @@ numpy <- NULL |
49 | 59 |
sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
50 | 60 |
conda = "auto", |
51 | 61 |
packages = c("scipy", "numpy", "astroid", "six"), |
52 |
- pipPackages = c("scrublet"), |
|
62 |
+ pipPackages = c("scrublet", "scanpy", "bbknn", "scanorama", "scgen"), |
|
53 | 63 |
selectConda = TRUE, |
54 | 64 |
forge = FALSE, |
55 | 65 |
pipIgnoreInstalled = TRUE, |
... | ... |
@@ -96,7 +106,7 @@ sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
96 | 106 |
#' going through the whole installation process again. |
97 | 107 |
#' @export |
98 | 108 |
sctkPythonInstallVirtualEnv <- function(envname = "sctk-reticulate", |
99 |
- packages = c("scipy", "numpy", "astroid", "six", "scrublet"), |
|
109 |
+ packages = c("scipy", "numpy", "astroid", "six", "scrublet", "scanpy", "scanorama", "bbknn", "scgen"), |
|
100 | 110 |
selectEnvironment = TRUE, |
101 | 111 |
python = NULL) { |
102 | 112 |
|
... | ... |
@@ -23,7 +23,7 @@ numpy <- NULL |
23 | 23 |
#' @description Install all Python packages used in the \code{\link{singleCellTK}} package |
24 | 24 |
#' using \code{\link[reticulate]{conda_install}} from package \code{\link{reticulate}}. This |
25 | 25 |
#' will create a new Conda environment with the name \code{envname} if not already present. |
26 |
-#' Note that Conda or Miniconda already need to be installed on the local system. |
|
26 |
+#' Note that Anaconda or Miniconda already need to be installed on the local system. |
|
27 | 27 |
#' @param envname Character. Name of the conda environment to create. |
28 | 28 |
#' @param conda Character. Path to conda executable. Usue "auto" to find conda using the PATH and other conventional install locations. Default 'auto'. |
29 | 29 |
#' @param packages Character Vector. List of packages to install from Conda. |
... | ... |
@@ -18,15 +18,156 @@ numpy <- NULL |
18 | 18 |
} |
19 | 19 |
|
20 | 20 |
|
21 |
-#' @name sctk_py_install |
|
22 |
-#' @title Installs Python packages |
|
21 |
+#' @name sctkPythonInstallConda |
|
22 |
+#' @title Installs Python packages into a Conda environment |
|
23 | 23 |
#' @description Install all Python packages used in the \code{\link{singleCellTK}} package |
24 |
-#' using \code{\link[reticulate]{py_install}} from package \code{\link{reticulate}}. |
|
25 |
-#' @param packages List of packages to install |
|
26 |
-#' @param ... Other parameters to pass to \code{\link[reticulate]{py_install}}. Can be useful for |
|
27 |
-#' selecting which environment to install these packages into. If no parameters are supplied, |
|
28 |
-#' then packages will be installed into default Python environment chosen by \code{\link{reticulate}}. |
|
24 |
+#' using \code{\link[reticulate]{conda_install}} from package \code{\link{reticulate}}. This |
|
25 |
+#' will create a new Conda environment with the name \code{envname} if not already present. |
|
26 |
+#' Note that Conda or Miniconda already need to be installed on the local system. |
|
27 |
+#' @param envname Character. Name of the conda environment to create. |
|
28 |
+#' @param conda Character. Path to conda executable. Usue "auto" to find conda using the PATH and other conventional install locations. Default 'auto'. |
|
29 |
+#' @param packages Character Vector. List of packages to install from Conda. |
|
30 |
+#' @param pipPackages Character Vector. List of packages to install into the Conda environment using 'pip'. |
|
31 |
+#' @param selectConda Boolean. Run \code{\link[singleCellTK]{selectSCTKConda}} after installing all packages to select the Conda environment. Default TRUE. |
|
32 |
+#' @param forge Boolean. Include the Conda Forge repository. |
|
33 |
+#' @param pipIgnoreInstalled Boolean. Ignore installed versions when using pip. This is TRUE by default so that specific package versions can be installed even if they are downgrades. |
|
34 |
+#' The FALSE option is useful for situations where you don't want a pip install to attempt an overwrite of a conda binary package (e.g. SciPy on Windows which is very difficult |
|
35 |
+#' to install via pip due to compilation requirements). |
|
36 |
+#' @param pythonVersion Passed to \code{python_version} variable in \code{\link[reticulate]{conda_install}}. Default NULL. |
|
37 |
+#' @param ... Other parameters to pass to \code{\link[reticulate]{conda_install}}. |
|
38 |
+#' @examples |
|
39 |
+#' \dontrun{ |
|
40 |
+#' sctkPythonInstallConda(envname = "sctk-reticulate") |
|
41 |
+#' } |
|
42 |
+#' @seealso See \code{\link[reticulate]{conda_create}} for more information on creating a Conda environment. |
|
43 |
+#' See \code{\link[reticulate]{conda_install}} for more description of the installation parameters. |
|
44 |
+#' See \url{https://rstudio.github.io/reticulate/} for more information on package \code{\link{reticulate}}. |
|
45 |
+#' See \code{\link[singleCellTK]{selectSCTKConda}} for reloading the Conda environment if R is restarted without |
|
46 |
+#' going through the whole installation process again. |
|
47 |
+#' See \url{https://docs.conda.io/en/latest/} for more information on Conda environments. |
|
29 | 48 |
#' @export |
30 |
-sctk_py_install = function(packages = c("scipy", "scrublet"), ...) { |
|
31 |
- reticulate::py_install(packages, ...) |
|
32 |
-} |
|
33 | 49 |
\ No newline at end of file |
50 |
+sctkPythonInstallConda <- function(envname = "sctk-reticulate", |
|
51 |
+ conda = "auto", |
|
52 |
+ packages = c("scipy", "numpy", "astroid", "six"), |
|
53 |
+ pipPackages = c("scrublet"), |
|
54 |
+ selectConda = TRUE, |
|
55 |
+ forge = FALSE, |
|
56 |
+ pipIgnoreInstalled = TRUE, |
|
57 |
+ pythonVersion = NULL, |
|
58 |
+ ...) { |
|
59 |
+ |
|
60 |
+ path <- reticulate::conda_create(envname = envname, packages = "python", conda = conda) |
|
61 |
+ |
|
62 |
+ for(i in packages) { |
|
63 |
+ reticulate::conda_install(envname = envname, packages = i, conda = conda, |
|
64 |
+ pip = FALSE, pip_ignore_installed = pipIgnoreInstalled, |
|
65 |
+ python_version = pythonVersion, ...) |
|
66 |
+ } |
|
67 |
+ |
|
68 |
+ reticulate::conda_install(envname = envname, packages = pipPackages, |
|
69 |
+ pip = TRUE, pip_ignore_installed = pipIgnoreInstalled, |
|
70 |
+ python_version = pythonVersion, ...) |
|
71 |
+ |
|
72 |
+ if(isTRUE(selectConda)) selectSCTKConda(envname = envname) |
|
73 |
+ |
|
74 |
+ invisible(path) |
|
75 |
+} |
|
76 |
+ |
|
77 |
+ |
|
78 |
+ |
|
79 |
+#' @name sctkPythonInstallVirtualEnv |
|
80 |
+#' @title Installs Python packages into a virtual environment |
|
81 |
+#' @description Install all Python packages used in the \code{\link{singleCellTK}} package |
|
82 |
+#' using \code{\link[reticulate]{virtualenv_install}} from package \code{\link{reticulate}}. This |
|
83 |
+#' will create a new virtual environment with the name \code{envname} if not already present. |
|
84 |
+#' @param envname Character. Name of the virtual environment to create. |
|
85 |
+#' @param packages Character Vector. List of packages to install. |
|
86 |
+#' @param selectEnvironment Boolean. Run \code{\link[singleCellTK]{selectSCTKVirtualEnvironment}} after installing all packages to select the virtual environment. Default TRUE. |
|
87 |
+#' @param python The path to a Python interpreter, to be used with the created virtual environment. When NULL, the Python interpreter associated with the current session will be used. Default NULL. |
|
88 |
+#' @param ... Other parameters to pass to \code{\link[reticulate]{conda_install}}. |
|
89 |
+#' @examples |
|
90 |
+#' \dontrun{ |
|
91 |
+#' sctkPythonInstallVirtualEnv(envname = "sctk-reticulate") |
|
92 |
+#' } |
|
93 |
+#' @seealso See \code{\link[reticulate]{virtualenv_create}} for more information on creating a Conda environment. |
|
94 |
+#' See \code{\link[reticulate]{virtualenv_install}} for more description of the installation parameters. |
|
95 |
+#' See \url{https://rstudio.github.io/reticulate/} for more information on package \code{\link{reticulate}}. |
|
96 |
+#' See \code{\link[singleCellTK]{selectSCTKVirtualEnvironment}} for reloading the virtual environment if R is restarted without |
|
97 |
+#' going through the whole installation process again. |
|
98 |
+#' @export |
|
99 |
+sctkPythonInstallVirtualEnv <- function(envname = "sctk-reticulate", |
|
100 |
+ packages = c("scipy", "numpy", "astroid", "six", "scrublet"), |
|
101 |
+ selectEnvironment = TRUE, |
|
102 |
+ python = NULL) { |
|
103 |
+ |
|
104 |
+ path <- reticulate::virtualenv_create(envname = envname, python = python) |
|
105 |
+ |
|
106 |
+ for(i in packages) { |
|
107 |
+ reticulate::virtualenv_install(envname = envname, packages = i, ignore_installed = TRUE) |
|
108 |
+ } |
|
109 |
+ |
|
110 |
+ if(isTRUE(selectEnvironment)) selectSCTKVirtualEnvironment(envname = envname) |
|
111 |
+ |
|
112 |
+ invisible(path) |
|
113 |
+} |
|
114 |
+ |
|
115 |
+ |
|
116 |
+#' @name selectSCTKConda |
|
117 |
+#' @title Selects a Conda environment |
|
118 |
+#' @description Selects a Conda environment with Python packages used in \code{\link{singleCellTK}}. |
|
119 |
+#' @param envname Character. Name of the conda environment to activate. |
|
120 |
+#' @examples |
|
121 |
+#' \dontrun{ |
|
122 |
+#' sctkPythonInstallConda(envname = "sctk-reticulate", selectConda = FALSE) |
|
123 |
+#' selectSCTKConda(envname = "sctk-reticulate") |
|
124 |
+#' } |
|
125 |
+#' @seealso \code{\link[reticulate]{conda-tools}} for more information on using Conda environments with package \code{\link{reticulate}}. |
|
126 |
+#' See \url{https://rstudio.github.io/reticulate/} for more information on package \code{\link{reticulate}}. |
|
127 |
+#' @export |
|
128 |
+#' @seealso See \code{\link[singleCellTK]{sctkPythonInstallConda}} for installation of Python modules into a Conda environment. |
|
129 |
+#' See\code{\link[reticulate]{conda-tools}} for more information on using Conda environments with package \code{\link{reticulate}}. |
|
130 |
+#' See \url{https://rstudio.github.io/reticulate/} for more information on package \code{\link{reticulate}}. |
|
131 |
+#' See \url{https://docs.conda.io/en/latest/} for more information on Conda environments. |
|
132 |
+selectSCTKConda <- function(envname = "sctk-reticulate") { |
|
133 |
+ condaList <- reticulate::conda_list() |
|
134 |
+ ix <- condaList$name == envname |
|
135 |
+ |
|
136 |
+ if(!any(ix)) { |
|
137 |
+ stop(paste0("Environment '", envname, "', not found. Run sctkPythonInstallConda(envname = '", envname, "') to install Python packages into a conda environmanet with this name.")) |
|
138 |
+ } |
|
139 |
+ if(sum(ix) > 1) { |
|
140 |
+ envs <- paste(condaList[ix,"python"], collapse="\n") |
|
141 |
+ warning(paste0("More than one Conda environment detected with the name '", envname, "'. Selecting the first one in the list:\n", envs)) |
|
142 |
+ } |
|
143 |
+ |
|
144 |
+ reticulate::use_condaenv(condaenv = envname, required = TRUE) |
|
145 |
+} |
|
146 |
+ |
|
147 |
+ |
|
148 |
+ |
|
149 |
+#' @name selectSCTKVirtualEnvironment |
|
150 |
+#' @title Selects a virtual environment |
|
151 |
+#' @description Selects a virtual environment with Python packages used in \code{\link{singleCellTK}} |
|
152 |
+#' @param envname Character. Name of the virtual environment to activate. |
|
153 |
+#' @examples |
|
154 |
+#' \dontrun{ |
|
155 |
+#' sctkPythonInstallVirtualEnv(envname = "sctk-reticulate", selectEnvironment = FALSE) |
|
156 |
+#' selectSCTKVirtualEnvironment(envname = "sctk-reticulate") |
|
157 |
+#' } |
|
158 |
+#' @seealso See \code{\link[singleCellTK]{sctkPythonInstallVirtualEnv}} for installation of Python modules into a virtual environment. |
|
159 |
+#' See\code{\link[reticulate]{virtualenv-tools}} for more information on using virtual environments with package \code{\link{reticulate}}. |
|
160 |
+#' See \url{https://rstudio.github.io/reticulate/} for more information on package \code{\link{reticulate}}. |
|
161 |
+#' @export |
|
162 |
+selectSCTKVirtualEnvironment <- function(envname = "sctk-reticulate") { |
|
163 |
+ res <- reticulate::virtualenv_list() |
|
164 |
+ ix <- res == envname |
|
165 |
+ |
|
166 |
+ if(!any(ix)) { |
|
167 |
+ stop(paste0("Environmnet '", envname, "', not found. Run selectSCTKVirtualEnvironment(envname = '", envname, "') to install Python packages into a virtual environmanet with this name.")) |
|
168 |
+ } |
|
169 |
+ if(sum(ix) > 1) { |
|
170 |
+ warning(paste0("More than one virtual environment detected with the name '", envname, "'. Selecting the first one in the list.")) |
|
171 |
+ } |
|
172 |
+ |
|
173 |
+ reticulate::use_virtualenv(res[which(ix)[1]], required = TRUE) |
|
174 |
+} |
... | ... |
@@ -6,11 +6,15 @@ |
6 | 6 |
# python modules to use |
7 | 7 |
scrublet <- NULL |
8 | 8 |
scipy <- NULL |
9 |
+sparse <- NULL |
|
10 |
+numpy <- NULL |
|
9 | 11 |
|
10 | 12 |
.onLoad <- function(libname, pkgname) { |
11 | 13 |
# use superassignment to update global reference to scipy |
12 |
-# scrublet <<- reticulate::import("scrublet", delay_load = TRUE) |
|
13 |
-# scipy <<- reticulate::import("scipy", delay_load = TRUE) |
|
14 |
+ scrublet <<- reticulate::import("scrublet", delay_load = TRUE) |
|
15 |
+ scipy <<- reticulate::import("scipy", delay_load = TRUE) |
|
16 |
+ sparse <<- reticulate::import("scipy.sparse", delay_load = TRUE) |
|
17 |
+ numpy <<- reticulate::import("numpy", delay_load = TRUE) |
|
14 | 18 |
} |
15 | 19 |
|
16 | 20 |
|
... | ... |
@@ -9,8 +9,8 @@ scipy <- NULL |
9 | 9 |
|
10 | 10 |
.onLoad <- function(libname, pkgname) { |
11 | 11 |
# use superassignment to update global reference to scipy |
12 |
- scrublet <<- reticulate::import("scrublet", delay_load = TRUE) |
|
13 |
- scipy <<- reticulate::import("scipy", delay_load = TRUE) |
|
12 |
+# scrublet <<- reticulate::import("scrublet", delay_load = TRUE) |
|
13 |
+# scipy <<- reticulate::import("scipy", delay_load = TRUE) |
|
14 | 14 |
} |
15 | 15 |
|
16 | 16 |
|
... | ... |
@@ -8,7 +8,21 @@ scrublet <- NULL |
8 | 8 |
scipy <- NULL |
9 | 9 |
|
10 | 10 |
.onLoad <- function(libname, pkgname) { |
11 |
- # delay load foo module (will only be loaded when accessed via $) |
|
12 |
- scrublet <<- import("scrublet", delay_load = TRUE) |
|
13 |
- scipy <<- import("scipy", delay_load = TRUE) |
|
11 |
+ # use superassignment to update global reference to scipy |
|
12 |
+ scrublet <<- reticulate::import("scrublet", delay_load = TRUE) |
|
13 |
+ scipy <<- reticulate::import("scipy", delay_load = TRUE) |
|
14 |
+} |
|
15 |
+ |
|
16 |
+ |
|
17 |
+#' @name sctk_py_install |
|
18 |
+#' @title Installs Python packages |
|
19 |
+#' @description Install all Python packages used in the \code{\link{singleCellTK}} package |
|
20 |
+#' using \code{\link[reticulate]{py_install}} from package \code{\link{reticulate}}. |
|
21 |
+#' @param packages List of packages to install |
|
22 |
+#' @param ... Other parameters to pass to \code{\link[reticulate]{py_install}}. Can be useful for |
|
23 |
+#' selecting which environment to install these packages into. If no parameters are supplied, |
|
24 |
+#' then packages will be installed into default Python environment chosen by \code{\link{reticulate}}. |
|
25 |
+#' @export |
|
26 |
+sctk_py_install = function(packages = c("scipy", "scrublet"), ...) { |
|
27 |
+ reticulate::py_install(packages, ...) |
|
14 | 28 |
} |
15 | 29 |
\ No newline at end of file |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,14 @@ |
1 |
+ |
|
2 |
+## Code taken from: |
|
3 |
+## https://rstudio.github.io/reticulate/articles/package.html |
|
4 |
+## Meant to delay loading of python environmnet so user can set the python environment |
|
5 |
+ |
|
6 |
+# python modules to use |
|
7 |
+scrublet <- NULL |
|
8 |
+scipy <- NULL |
|
9 |
+ |
|
10 |
+.onLoad <- function(libname, pkgname) { |
|
11 |
+ # delay load foo module (will only be loaded when accessed via $) |
|
12 |
+ scrublet <<- import("scrublet", delay_load = TRUE) |
|
13 |
+ scipy <<- import("scipy", delay_load = TRUE) |
|
14 |
+} |
|
0 | 15 |
\ No newline at end of file |