This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Fail to install umap-learn in R

Dear fellows,

I am having a bit issue with umap-learn for my cellchat analysis. Here is the story!

I run the following cellchat function and got error and I followed the instruction to install umap-learn

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

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 used the following script

reticulate::install_python(version = '3.12.2')
reticulate::py_install(packages = "umap-learn")

Using virtual environment "~/.virtualenvs/r-reticulate" ...
+ "C:/Users/skeam/OneDrive - Inside/Documents/.virtualenvs/r-reticulate/Scripts/python.exe" -m pip install --upgrade --no-user umap-learn
Requirement already satisfied: umap-learn in c:\users\skeam\onedri~1\docume~1\virtua~1\r-reti~1\lib\site-packages (0.5.5)
Requirement already satisfied: numpy>=1.17 in c:\users\skeam\onedri~1\docume~1\virtua~1\r-reti~1\lib\site-packages (from umap-learn) (1.26.4)
Requirement already satisfied: scipy>=1.3.1 in c:\users\skeam\onedri~1\docume~1\virtua~1\r-reti~1\lib\site-packages (from umap-learn) (1.12.0)
Requirement already satisfied: scikit-learn>=0.22 in c:\users\skeam\onedri~1\docume~1\virtua~1\r-reti~1\lib\site-packages (from umap-learn) (1.4.1.post1)
Requirement already satisfied: numba>=0.51.2 in c:\users\skeam\onedri~1\docume~1\virtua~1\r-reti~1\lib\site-packages (from umap-learn) (0.59.0)
Requirement already satisfied: pynndescent>=0.5 in c:\users\skeam\onedri~1\docume~1\virtua~1\r-reti~1\lib\site-packages (from umap-learn) (0.5.11)
Requirement already satisfied: tqdm in c:\users\skeam\onedri~1\docume~1\virtua~1\r-reti~1\lib\site-packages (from umap-learn) (4.66.2)
Requirement already satisfied: llvmlite<0.43,>=0.42.0dev0 in c:\users\skeam\onedri~1\docume~1\virtua~1\r-reti~1\lib\site-packages (from numba>=0.51.2->umap-learn) (0.42.0)
Requirement already satisfied: joblib>=0.11 in c:\users\skeam\onedri~1\docume~1\virtua~1\r-reti~1\lib\site-packages (from pynndescent>=0.5->umap-learn) (1.3.2)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\skeam\onedri~1\docume~1\virtua~1\r-reti~1\lib\site-packages (from scikit-learn>=0.22->umap-learn) (3.3.0)
Requirement already satisfied: colorama in c:\users\skeam\onedri~1\docume~1\virtua~1\r-reti~1\lib\site-packages (from tqdm->umap-learn) (0.4.6)

The output says everything is satisfied, but once I run the following code!

reticulate::py_module_available("umap")
[1] FALSE

I rerun the cellchat function again and got same error.

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

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')).

Not sure why... I search the CellChat page in github and other sources, but could not fix it for the whole morning. Hope you could suggest sth.

Kind Regards,
Synat

cellchat r

2 answers

Yes I was able to solve this by adding something like this into the part of my code where I load in the libraries

for example:

#load in your libraries, then
reticulate::use_python("foo/miniconda3/bin/python", required=T)

Then clear environment and restart R

Thanks, if fixed. By chance, umap-learn was not installed in python path and I have to manually move it under python path.

Log in to answer this question.