Help with Error: Required version of NumPy not available: installation of Numpy >= 1.6 not found
1
0
Entering edit mode
8 months ago
Chris ▴ 260

Hi all,

    seurat_combined <- FindClusters(seurat_combined, resolution = 0.1, algorithm = 4)
    library(reticulate)
    py_install("leidenalg")
    leidenalg<- import("leidenalg")
    py_install("numpy")
    py_install("pandas")

I don't know how to install Numpy 1.6 in R. Would you please have a suggestion for this error? If I put:

py_install("numpy==1.6")

Error: one or more Python packages failed to install [error code 1].
I can run leiden using scanpy but trying in with seurat. Thank you so much!

seurat leiden • 1.5k views
ADD COMMENT
0
Entering edit mode

Why are you installing python packages using R? Would it not be possible to install the required python packages and just run what you need (the python code) from R?

ADD REPLY
0
Entering edit mode

I know it is quite weird. I am working in R but to choose algorithm = 4, that is the error message I got. You can see the argument/algorithm here which mention about python: https://satijalab.org/seurat/reference/findclusters. I install numpy and pandas because I got error message that I don't have numpy and pandas. Numpy 1.6 is the next error after installing numpy.

ADD REPLY
2
Entering edit mode
8 months ago
bk11 ★ 2.4k

There is no latest version of NumPy 1.6.0 because NumPy 1.6.0 was released on May 14, 2011. The latest version of NumPy is 1.25.2, which was released on July 31, 2023. If OP wants to install the latest version using R, do some thing like this-

#Create an environment, install packages within it, then use the environment from R as follows-
library(reticulate)

# create a new environment 
conda_create("r-reticulate")

# install numpy
conda_install("r-reticulate", "numpy")

# import numpy (it will be automatically discovered in "r-reticulate")
np <- import("numpy")
ADD COMMENT
1
Entering edit mode

I'd think that the better approach would be to conda create the env outside of everything with the required R and python packages and use that env to run everything.

ADD REPLY
0
Entering edit mode

Thank you for your help. Unfortunately, I ran these code in R without erorr but the error about numpy 1.6 persist.

conda_create("r-reticulate")
conda_install("r-reticulate", "numpy")
np <- import("numpy")

enter image description here

I found some posts also get errors when trying leiden.

ADD REPLY
1
Entering edit mode

Try usecondaenv("r-reticulate") before the import and FindClusters calls.

ADD REPLY
0
Entering edit mode

This is the order of my code in RStudio:

use_condaenv("r-reticulate")
np <- import("numpy")
FindClusters()

It looks like FindClusters() still doesn't run in environment that have numpy >=1.6. Unfortunately, the error persist.

ADD REPLY
1
Entering edit mode

Did you also install leiden in R? If not do this-

install.packages("leiden")

or

if (!requireNamespace("devtools"))
    install.packages("devtools")
devtools::install_github("TomKellyGenetics/leiden", ref = "master")
ADD REPLY
0
Entering edit mode

I tried to install leiden with your suggestion and after load the library, the error still shows. Thank you so much!

ADD REPLY
1
Entering edit mode

It runs fine in my setting.

foo <- FindClusters(foo, resolution = 0.2, cluster.name = "harmony_clusters", algorithm = 4)
There were 50 or more warnings (use warnings() to see the first 50)

You can also check the Details section of Help page after you run ?FindClusters()

ADD REPLY
0
Entering edit mode

Reproducible crisis. I try to run again everything. Would you please share your code so that I can compare?

ADD REPLY
1
Entering edit mode

There could have been conflicts in the packages that's why though you installed leiden or others but not recognized in your R. I would suggest to get rid of all the dependencies and reinstall using conda.

ADD REPLY
0
Entering edit mode

I tried another dataset and don't have error except a lot of this one print out:

Warning in paste(condition$message, collapse = "\n") :
  NAs introduced by coercion to integer range
Warning in paste(prefix, message) :
  NAs introduced by coercion to integer range
Warning: NAs introduced by coercion to integer rangeWarning in paste(condition$message, collapse = "\n") :

The first dataset, no error meassge but RStudio crashed.

ADD REPLY

Login before adding your answer.

Traffic: 1758 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6