activate_python: Activate Python Environment for SeuratExtend

View source: R/Python.R

activate_pythonR Documentation

Activate Python Environment for SeuratExtend

Description

This function activates a Python environment (default: "seuratextend") and imports specified packages. It's particularly important for macOS users to call this function at the beginning of their workflow to prevent R session crashes when running Python-dependent functions later.

Usage

activate_python(conda_env = "seuratextend", verbose = TRUE, packages = c("os"))

Arguments

conda_env

Character string specifying the conda environment name. Default is "seuratextend".

verbose

Logical indicating whether to print status messages. Default is TRUE.

packages

Character vector of Python packages to import.

Details

This function serves two main purposes:

1. It activates the specified conda environment and imports the specified Python packages.

2. **For macOS users (especially on Apple Silicon M1/M2/M3/M4)**: Running this function at the start of your R session, before loading any R objects, prevents memory management issues between R and Python that can otherwise cause R to crash when running operations like PCA on AnnData objects.

This is a crucial first step for macOS users working with 'scVelo' functions.

Value

Invisible TRUE if successful

Examples

## Not run: 
# For macOS users, run this at the beginning of your session
activate_python()

# Then load your Seurat objects and continue with your analysis
seu <- readRDS("my_seurat_object.rds")

# Custom environment with verbose output
activate_python(conda_env = "my_custom_env", verbose = TRUE)

## End(Not run)

huayc09/SeuratExtend documentation built on July 5, 2025, 1:41 a.m.