Hi, I'm excited to use the new integration with UMAP but I can't get it to work. Below is the R code and verification that it is installed.
> scRNAseq.integrated <- RunUMAP(object = scRNAseq.integrated, reduction = "pca", dims = 1:30)
Error in RunUMAP.default(object = data.use, assay = assay, n.neighbors = n.neighbors, :
Cannot find UMAP, please install through pip (e.g. pip install umap-learn).
```
DN0a22b768:~ cstill$ pip show umap-learn
Name: umap-learn
Version: 0.3.7
Summary: Uniform Manifold Approximation and Projection
Home-page: http://github.com/lmcinnes/umap
Author: None
Author-email: None
License: BSD
Location: /Users/cstill/anaconda3/lib/python3.7/site-packages
Requires: scikit-learn, numba, scipy, numpy
Required-by:
DN0a22b768:~ cstill$
```python
>>> sam.run_umap()
array([[16.360878 , 6.602775 ],
[15.218763 , 6.808421 ],
[19.056177 , 8.954225 ],
...,
[22.249752 , 2.8561206],
[18.007689 , 25.26965 ],
[19.846735 , 18.987228 ]], dtype=float32)
I had the same issue. But you can save.image(); q(); y. Then do pip install umap-learn. Restart the R session, and it works.
Hi @cstill1992,
What happens if you install UMAP using the Pip/Python installation that came with your Mac? We've noticed that reticulate doesn't see Anaconda-installed Python modules, so we recommend not using Anaconda.
Closing this issue as both suggested solutions (not using anaconda, and restarting R) should be sufficient for reticulate to detect UMAP
@satijalab @mojaveazure
Just wanted to send fyi. Still new to all of this but after some playing around it appears that reticulate can function with Anaconda but it seems to have trouble if you create environments and install packages directly through Anaconda. However, if you install packages through reticulate in R then it creates environment and works with no issues for me (at least on Mac OS X).
Following auto creates Anaconda environment "r-reticulate" and installs umap and dependencies.
library(reticulate)
py_install("umap-learn")
So if there is a need to use Anaconda or that is what users have installed appears that this works to solve the issue.
Thanks for all you do with Seurat!
Hi, I have the same issue and I tried all the above solution and doesn't work.
I am using Seurat v3 on Centos 7.
I am using Domino system and both solution did not work for me. Still have the "could not find UMAP" error.
try #1
pip install umap-learn
try #2
library(reticulate)
py_install("umap-learn")
I cannot restart the R session -- every time I shut down the session it will start a new EC2.
Any suggestion?
Thanks,
Shuoguo
Hi guys, sorry for getting away from this for a bit. So neither of the above solutions really worked for me and I eventually just did conda install -c conda-forge umap-learn (as shown here: https://umap-learn.readthedocs.io/en/latest/) and everything started working. Not sure why this worked though. Might be worth giving a try if you still haven't gotten it working.
Hi, I found the solution, so umap-learn should be installed using python v3 and pip v3
so before installing umap you should upgrade the pipe to v3.
Best.
in my case pip3 install umap-learn did the trick. thanks @Abghaith !!
just figured out in a new EC2 instance that after install i also need to restart r session to get it work:.rs.restartR()
I had to add the location of my python 3 in the R session.
library(reticulate)
use_python("/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/")
Hello. Can someone give me the final codes that you used on both anaconda and r for umap installation? Please give the order also.
Another fix which worked in my case and which I haven't seen in previous comments.
In my case the problem was that reticulate wasn't able to find my python install, so nothing worked, but the error was that the umap package was missing (which wasn't the issue).
The check for this is:
library(reticulate)
py_config()
You'll either get something which says which version of python has been found, or in my case it produced:
> py_config()
Error in initialize_python(required_module, use_environment) :
Installation of Python not found, Python bindings not loaded.
If I then specified the location of python by running use_python then it started working.
> use_python("C:/Program Files/Python37/python.exe")
> py_config()
python: C:/Program Files/Python37/python.exe
libpython: C:/Program Files/Python37/python37.dll
pythonhome: C:\PROGRA~1\Python37
version: 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]
Architecture: 64bit
numpy: C:\Users\Training9\AppData\Roaming\Python\Python37\site-packages\numpy
numpy_version: 1.16.4
After the python was discovered then RunUMAP also started to work.
Hi,
The umap-learn package is installed ...
> py_config()
python: /apps/RH7U2/gnu/anaconda/5.2.0/python/3.6/bin/python
libpython: /apps/RH7U2/gnu/anaconda/5.2.0/python/3.6/lib/libpython3.6m.so
pythonhome: /apps/RH7U2/gnu/anaconda/5.2.0/python/3.6:/apps/RH7U2/gnu/anaconda/5.2.0/python/3.6
version: 3.6.8 |Anaconda custom (64-bit)| (default, Dec 30 2018, 01:22:34) [GCC 7.3.0]
numpy: [NOT FOUND]
umap: /home/labs/shalev/hassanm/.local/lib/python3.6/site-packages/umap
but still, I can't run the UMAP Seurat command!
human.combined <- RunUMAP(human.combined, reduction = "pca", dims = 1:30)
Error in RunUMAP.default(object = data.use, assay = assay, n.neighbors = n.neighbors, :
Cannot find UMAP, please install through pip (e.g. pip install umap-learn).
Any suggestions...
Thanks, HM
HM, it looks like your umap install is in in a local path instead of installed with conda. If you have multiple python installs, try use_python("/home/labs/shalev/hassanm/.local/lib/python3.6/") to allow R to recognize where it should be looking for packages as outlined prior in this thread.
@s-andrews's answer helped but not worked in my case.
I am working in Rstudio server. Using use_python cannot change the Python used by R. See the discussions here.
> library(reticulate)
> py_config()
python: /usr/bin/python
libpython: /usr/lib64/libpython2.7.so.1.0
pythonhome: /usr:/usr
version: 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
numpy: /T02Data/niuyw/.local/lib/python2.7/site-packages/numpy
numpy_version: 1.16.4
> use_python('/T02Data/niuyw/software/anaconda3/bin/python')
> py_config()
python: /usr/bin/python
libpython: /usr/lib64/libpython2.7.so.1.0
pythonhome: /usr:/usr
version: 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
numpy: /T02Data/niuyw/.local/lib/python2.7/site-packages/numpy
numpy_version: 1.16.4
And the method below worked for me.
Install umap under the Python used by R.
# install pip
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ /usr/bin/python get-pip.py --user
# install umap
$ .local/bin/pip install umap-learn --user
I also tried to change RETICULATE_PYTHON in .Renviron to the Python I want to use. This way changed the Python used by reticulate indeed but I still got the error 'Cannot find UMAP', though I had installed it through pip.
$ cat .Renviron
RETICULATE_PYTHON=~/software/anaconda3/bin/python
Hope this would be helpful for situations like me.
just figured out in a new EC2 instance that after install i also need to restart r session to get it work:
.rs.restartR()
Thanks. This worked
Hi I'm new to seurat and I've tried the above options but still having trouble. This is my code:
install.packages("reticulate")
library(reticulate)
reticulate::py_install(packages ='umap-learn')
GIST <- RunUMAP(GIST, dims = 1:11)
Error in RunUMAP(GIST, dims = 1:11) : could not find function "RunUMAP"
I've got the latest version of anaconda. I'm on windows 64-bit.
Any suggestions would be very much appreciated :)
All the above also helped me to untangle the problems I was having.
I did the local install, and ensured R could see my python (which it was not before). I was still having problems, then I realized that if I started a python3 shell, even then doing "import umap" did not work. The final error was that python3 was looking for a newer version of scipy that was not installed. Upgrade scipy and try again.
python3 -m pip install scipy --user --upgrade
I realize that Seurat now using "uwot", but that won't solve the umap issue if you are doing:
RunUMAP(obj, umap.method='umap-learn')
Hi there,
I keep getting this issue when trying to use umap on my Seurat object in R
Error: Cannot find 'umap' in this Seurat object
I have tried renaming and reinstalling umap-learn with reticulate::py_install(packages = 'umap-learn')
however this isn't working, I am using python version 3.8, could that be the problem?
would be very grateful if anyone could help me with this issue!
Rachel
I have meet the same problem。 I use "pip3 install umap-learn" in the terminal of Rstudio, then I restart the Rstudio, It worked
Most helpful comment
@satijalab @mojaveazure
Just wanted to send fyi. Still new to all of this but after some playing around it appears that reticulate can function with Anaconda but it seems to have trouble if you create environments and install packages directly through Anaconda. However, if you install packages through reticulate in R then it creates environment and works with no issues for me (at least on Mac OS X).
Following auto creates Anaconda environment "r-reticulate" and installs umap and dependencies.
library(reticulate)py_install("umap-learn")So if there is a need to use Anaconda or that is what users have installed appears that this works to solve the issue.
Thanks for all you do with Seurat!