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"
. For optimal GRNBoost2 compatibility, Python 3.8.x is strongly recommended.- 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()
#> Using Python version: 3.8
#> Could not check Python version
#> Python modules successfully loaded.
# Initialize with automatic installation of missing packages
modules <- init_py(install_missing = TRUE)
#> Using Python version: 3.8
#> Could not check Python version
#> Python modules successfully loaded.
# Use specific Python 3.8 installation for optimal GRNBoost2 compatibility
modules <- init_py(python_path = "/usr/bin/python3.8",
install_missing = TRUE)
#> Warning: Previous request to `use_python("/usr/bin/python3", required = TRUE)` will be ignored. It is superseded by request to `use_python("/usr/bin/python3.8")
#> Using Python version: 3.8
#> Could not check Python version
#> Python modules successfully loaded.