| 250 | | |
| | 250 | * However, sometimes Seurat may depend on other R packages to run certain functions, in that case, only loading the older version of Seurat may not work. Instead, we could explicitly load all R packages from the last R library set to keep the packages compatible. |
| | 251 | {{{ |
| | 252 | set_lib_paths <- function(lib_vec) { |
| | 253 | lib_vec <- normalizePath(lib_vec, mustWork = TRUE) |
| | 254 | shim_fun <- .libPaths |
| | 255 | shim_env <- new.env(parent = environment(shim_fun)) |
| | 256 | shim_env$.Library <- character() |
| | 257 | shim_env$.Library.site <- character() |
| | 258 | environment(shim_fun) <- shim_env |
| | 259 | shim_fun(lib_vec) |
| | 260 | } |
| | 261 | |
| | 262 | set_lib_paths(c("/nfs/apps/lib/R/4.2-focal/site-library.2023q1", "/opt/R/4.2.1/lib/R/library")) |
| | 263 | |
| | 264 | library(Seurat) |
| | 265 | # load other required packages, e.g. scPred, for cell type annotation. |
| | 266 | library(scPred) |
| | 267 | }}} |
| | 268 | * By running the codes above, all the required R packages will be loaded from the previous R library set (2023q1). |
| | 269 | |
| | 270 | |