cellgeni / sceasy

A package to help convert different single-cell data formats to each other
GNU General Public License v3.0
382 stars 57 forks source link

Unable to convert Seurat object to H5AD #44

Open dfermin opened 2 years ago

dfermin commented 2 years ago

Hello. I've successfully created a condo environment and installed anndata==0.6.19 scipy==1.2.1 :

conda create -n h5ad anndata==0.6.19 scipy==1.2.1 loompy -c bioconda --yes

Within this new anaconda environment I've started up R and installed reticulate and r-sceasy (with all dependencies).

I can read in my Seurat RDS object but the conversion to H5AD fails. Here is the R code I'm using:

library(sceasy)
library(reticulate)
use_condaenv("/home/dfermin/anaconda3/envs/h5ad")

seurat_obj <- readRDS("../data/suerat_10K.RDS")
sceasy::convertFormat(seurat_obj, from="seurat", to="anndata", outFile="../data/seurat_10K.h5ad")

The error message I get is:

Error in py_module_import(module, convert = convert) :
ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/dfermin/anaconda3/envs/h5ad/lib/python3.7/site-packages/pandas/_libs/window/aggregations.cpython-37m-x86_64-linux-gnu.so)

Detailed traceback:
File "/opt/R-4.1.1/lib64/R/library/reticulate/python/rpytools/loader.py", line 44, in _import_hook 
level=level
File "/home/dfermin/anaconda3/envs/h5ad/lib/python3.7/site-packages/anndata/__init__.py", line 1, in <module>
from .base import AnnData
File "/opt/R-4.1.1/lib64/R/library/reticulate/python/rpytools/loader.py", line 44, in _import_hook
level=level
File "/home/dfermin/anaconda3/envs/h5ad/lib/python3.7/site-packages/anndata/base.py", line 15, in <module>
import pandas as pd
File "/opt/R-4.1.1/lib64/R/library/reticulate/python/rpytools/loader.py", line 44, in _import_hook
level=level
File "/home/dfermin/anaconda3/envs/h5ad/lib/python3.7/site-packages/pandas/__init__.py", line 50, in <module>
from pandas.core

Which seems a bit strange since that GLIBCXX library is installed in the environment:

strings /home/dfermin/anaconda3/envs/h5ad/lib/* | grep 3.4.21
GLIBCXX_3.4.21
GLIBCXX_3.4.21
GLIBCXX_3.4.21
GLIBCXX_3.4.21
GLIBCXX_3.4.21
GLIBCXX_3.4.21

Any suggestions how I can fix this?

In case it helps I can find/use the correct python environment in R:

> reticulate::py_discover_config()
python:         /home/dfermin/anaconda3/envs/h5ad/bin/python
libpython:      /home/dfermin/anaconda3/envs/h5ad/lib/libpython3.7m.so
...
johnblair7 commented 1 year ago

I am having the same issue with basically the same error, so any help would be much appreciated - thanks!:

library(sceasy)
  library(reticulate)
  use_condaenv('sceasy')
  sceasy::convertFormat(obj, from="seurat", to="anndata",
                        outFile='obj.h5ad')
Error in py_module_import(module, convert = convert) : 
  ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /home/blairj/miniconda3/envs/sceasy/lib/python3.11/site-packages/pandas/_libs/window/aggregations.cpython-311-x86_64-linux-gnu.so)
5: stop(<environment>)
4: py_module_import(module, convert = convert)
3: reticulate::import("anndata", convert = FALSE)
2: func(obj, outFile = outFile, main_layer = main_layer, ...)
1: sceasy::convertFormat(obj, from = "seurat", to = "anndata", outFile = "obj.h5ad")
reticulate::py_discover_config()
python:         /home/blairj/miniconda3/envs/sceasy/bin/python
libpython:      /home/blairj/miniconda3/envs/sceasy/lib/libpython3.11.so
pythonhome:     /home/blairj/miniconda3/envs/sceasy:/home/blairj/miniconda3/envs/sceasy
version:        3.11.4 (main, Jul  5 2023, 13:45:01) [GCC 11.2.0]
numpy:          /home/blairj/miniconda3/envs/sceasy/lib/python3.11/site-packages/numpy
numpy_version:  1.25.2
andrewdchen commented 1 year ago

I resolved this by downgrading pandas to 1.5.1! condas install pandas=1.5.1