Skip to contents

Sets up the Python environment and lazily loads modules required for running GRNBoost2: arboreto, pandas, and numpy. Automatically installs missing Python packages if requested.

Usage

init_py(
  python_path = "/usr/bin/python3",
  required = TRUE,
  install_missing = FALSE,
  install_method = "auto",
  verbose = TRUE
)

Arguments

python_path

Character string. Path to the Python executable, e.g., "/usr/bin/python3".

required

Logical. If TRUE, errors if Python is not available or path is invalid. Default: TRUE.

install_missing

Logical. If TRUE, automatically installs missing Python packages. Default: FALSE.

install_method

Character string. Installation method when install_missing = TRUE. Options: "auto", "conda", "pip". Default: "auto".

verbose

Logical. If TRUE, shows installation progress. Default: TRUE.

Value

A list with three Python module objects:

  • arboreto: GRNBoost2 algorithm module.

  • pandas: Data handling module.

  • numpy: Numerical operations module.

Details

Uses reticulate to bind R to the specified Python interpreter and lazily import modules needed for GRNBoost2. If install_missing = TRUE, automatically installs the 'arboreto' package using the specified method if not found.

Examples

# Initialize Python environment (adjust python_path as needed)
modules <- init_py()
#> Python modules successfully loaded.

# Initialize with automatic installation of missing packages
modules <- init_py(install_missing = TRUE)
#> Python modules successfully loaded.