Skip to content

Commit

Permalink
Merge pull request #228 from wwang-chcn/dev
Browse files Browse the repository at this point in the history
Add pip_packages param to allow repository selection when install conda env
  • Loading branch information
jiajic authored Aug 28, 2024
2 parents 8638293 + 01c6605 commit 8c1c4f3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
34 changes: 21 additions & 13 deletions R/python_environment.R
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ checkGiottoEnvironment <- function(
#' @title .install_giotto_environment_specific
#' @description installation of giotto environment
#' @param packages_to_install python packages to install with giotto env
#' @param pip_packages python packages mush installed with pip, only names
#' are needed
#' @param python_version python version to install
#' @param mini_install_path directory to install the environment to.
#' @param create_dir whether to create the directory specified by
Expand All @@ -288,8 +290,9 @@ checkGiottoEnvironment <- function(
.install_giotto_environment_specific <- function(packages_to_install = c(
"pandas", "networkx", "python-igraph",
"leidenalg", "python-louvain", "python.app",
"scikit-learn"
"scikit-learn", "smfishhmrf", "session-info"
),
pip_packages = c("python-louvain", "smfishhmrf", "session-info"),
python_version = "3.10.2",
mini_install_path = NULL,
confirm = TRUE,
Expand Down Expand Up @@ -359,18 +362,15 @@ checkGiottoEnvironment <- function(
)]
}

# python-louvain must be installed with pip, not with conda-forge
# some python packages must be installed with pip, not with conda-forge
# `pip_packages` will be installed with pip
# `forge_packages` will be installed with conda-forge
forge_packages <- packages_to_install
py_lou <-"python-louvain"
pip_packages <- c("smfishhmrf", "session-info")
if (py_lou %in% packages_to_install) {
pip_packages <- c(pip_packages, py_lou)
forge_packages <- forge_packages[
forge_packages != py_lou
]
}
pip_pkg_indices <- grep(paste0(
"^(", paste(pip_packages, collapse = "|"),
")"
), packages_to_install, ignore.case = TRUE)
forge_packages <- packages_to_install[-pip_pkg_indices]
pip_packages <- packages_to_install[pip_pkg_indices]

## create conda env ##
## ---------------- ##
Expand Down Expand Up @@ -419,8 +419,9 @@ checkGiottoEnvironment <- function(
packages_to_install = c(
"pandas", "networkx", "python-igraph",
"leidenalg", "python-louvain", "python.app",
"scikit-learn"
"scikit-learn", "smfishhmrf", "session-info"
),
pip_packages = c("python-louvain", "smfishhmrf", "session-info"),
python_version = "3.10.2",
mini_install_path = NULL,
confirm = TRUE,
Expand Down Expand Up @@ -462,6 +463,7 @@ checkGiottoEnvironment <- function(
# install giotto environment
.install_giotto_environment_specific(
packages_to_install = packages_to_install,
pip_packages = pip_packages,
python_version = python_version,
mini_install_path = mini_install_path,
confirm = confirm,
Expand All @@ -485,6 +487,8 @@ checkGiottoEnvironment <- function(
#' environment with a .yml
#' - Returns `NULL`
#' @param packages_to_install python modules (packages) to install for Giotto.
#' @param pip_packages python packages mush installed with pip, only names
#' are needed
#' @param python_version python version to use within the giotto conda
#' environment. Default is v3.10.2
#' @param mini_install_path (optional) desired miniconda installation location.
Expand Down Expand Up @@ -513,8 +517,11 @@ installGiottoEnvironment <- function(
"leidenalg==0.9.0",
"python-louvain==0.16",
"python.app==1.4",
"scikit-learn==1.1.3"
"scikit-learn==1.1.3",
"smfishhmrf",
"session-info"
),
pip_packages = c("python-louvain", "smfishhmrf", "session-info"),
python_version = "3.10.2",
mini_install_path = NULL,
confirm = TRUE,
Expand Down Expand Up @@ -551,6 +558,7 @@ installGiottoEnvironment <- function(
.install_giotto_environment(
force_environment = force_environment,
packages_to_install = packages_to_install,
pip_packages = pip_packages,
python_version = python_version,
mini_install_path = mini_install_path,
confirm = confirm,
Expand Down
3 changes: 2 additions & 1 deletion man/dot-install_giotto_environment.Rd

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

7 changes: 6 additions & 1 deletion man/giotto_python.Rd

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

0 comments on commit 8c1c4f3

Please sign in to comment.