This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Help with Error: Required version of NumPy not available: installation of Numpy >= 1.6 not found

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

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?

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.

1 answer

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")

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.

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.

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

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.

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")

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

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()

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

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.

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.

Log in to answer this question.