forked from zhanghao-njmu/SCP
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzzz.R
25 lines (25 loc) · 1.32 KB
/
zzz.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
.onAttach <- function(libname, pkgname) {
options(future.globals.maxSize = Inf)
options(expressions = 5e5)
env_exist <- isTRUE(tryCatch("SCP" %in% reticulate::conda_list()$name[grep(reticulate:::conda_info()$conda_prefix, reticulate::conda_list()$python)], error = identity))
if (env_exist && (is.null(getOption("SCP_env_init")) || getOption("SCP_env_init") != FALSE)) {
try({
python_path <- reticulate::conda_python("SCP")
reticulate::use_python(python_path, required = TRUE)
pyinfo <- utils::capture.output(reticulate::py_config())
pyinfo_mesg <- c(
"======================== SCP python config ========================",
pyinfo,
"==================================================================="
)
invisible(lapply(pyinfo_mesg, packageStartupMessage))
invisible(run_Python(command = "import matplotlib", envir = .GlobalEnv))
if (!interactive()) {
invisible(run_Python(command = "matplotlib.use('pdf')", envir = .GlobalEnv))
}
invisible(run_Python(command = "import matplotlib.pyplot as plt", envir = .GlobalEnv))
invisible(run_Python(command = "import scanpy", envir = .GlobalEnv))
packageStartupMessage("SCP python environment can be disabled with the command 'options(SCP_env_init = FALSE)' before loading the package")
})
}
}