rbioinformaticsreticulate

netEmbedding() Function in CellChat - UMAP not recognized


I’m encountering an issue with the netEmbedding() function in CellChat and could use some advice.

When I run the following code:

cellchat <- netEmbedding(cellchat, type = "functional")

I get this error:

Manifold learning of the signaling networks for datasets 1 2  
Error in runUMAP(Similarity, min_dist = min_dist, n_neighbors = n_neighbors, :  
Cannot find UMAP, please install through pip (e.g. pip install umap-learn or reticulate::py_install(packages = 'umap-learn')).

I’ve followed the tutorials I could find on this error (uninstalled and installed everything again, used virtual environment, etc) and installed the necessary packages, but the issue persists.

When I run

reticulate::py_config()

umap appears there, but when i run

> reticulate::py_module_available("umap") 

I always get

[1] FALSE

Solution

  • I fixed this issue by changing the reticulate environment to a conda env (base) with Python version 3.12.4 already installed.

    library(reticulate)

    use_condaenv("base", conda = "/opt/anaconda3/bin/conda", required = TRUE) py_config()

    reticulate::py_install(packages = 'umap-learn', envname = "base", pip = TRUE)

    py_module_available("umap")

    [TRUE]