Closed Roger-GOAT closed 3 years ago
@Roger-GOAT thank you for your kind words!
Have you installed rpy2 in the same environment as scFates? From what I can read from your error message, you are running in a conda environment named scfates
.
Could you run the following code right before scf.tl.test_association
?
from rpy2.robjects import pandas2ri, Formula
from rpy2.robjects.packages import importr
import rpy2.rinterface
pandas2ri.activate()
Additionally if this works, could you then run the following to check whether rpy2 can access mgcv?
rmgcv = importr("mgcv")
@LouisFaure Thank you for your reply! I try
from rpy2.robjects import pandas2ri, Formula from rpy2.robjects.packages import importr import rpy2.rinterface
pandas2ri.activate()
It showed below:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/tmp/ipykernel_2120535/643095386.py in <module>
----> 1 from rpy2.robjects import pandas2ri, Formula
2 from rpy2.robjects.packages import importr
3 import rpy2.rinterface
4
5 pandas2ri.activate()
~/.local/lib/python3.8/site-packages/rpy2/robjects/__init__.py in <module>
14 from functools import partial
15 import types
---> 16 import rpy2.rinterface as rinterface
17 import rpy2.rlike.container as rlc
18
~/.local/lib/python3.8/site-packages/rpy2/rinterface.py in <module>
10 import warnings
11 from typing import Union
---> 12 from rpy2.rinterface_lib import openrlib
13 import rpy2.rinterface_lib._rinterface_capi as _rinterface
14 import rpy2.rinterface_lib.embedded as embedded
~/.local/lib/python3.8/site-packages/rpy2/rinterface_lib/openrlib.py in <module>
42 rlib = _rinterface_cffi.lib
43 else:
---> 44 rlib = _dlopen_rlib(R_HOME)
45
46
~/.local/lib/python3.8/site-packages/rpy2/rinterface_lib/openrlib.py in _dlopen_rlib(r_home)
35 raise ValueError('The library path cannot be None.')
36 else:
---> 37 rlib = ffi.dlopen(lib_path)
38 return rlib
39
OSError: cannot load library '/usr/local/lib/R/lib/libR.so': libRblas.so: cannot open shared object file: No such file or directory
How can I do to fix it?
This error is happening as rpy2 cannot find specific shared library, depending on how R has been installed.
In my memory I would have solved this issue by specifying the path R_HOME before importing rpy2/scFates:
import os
os.environ['R_HOME'] = '/path/to/R'
I have found that using CRAN installed R usually works best, in such case path would be something like: /usr/lib/R
If that still doesn't work then I suggest you to have a look at this issue https://github.com/rpy2/rpy2/issues/675
Closing this issue as it is more rpy2 R related than scFates
Thank you for the wonderful software! I run scf.tl.test_association(adata) showed:
However, I have "pip3 install rpy2" or "pip install rpy2" and the rpy2 had been installed. And I also install.packages('mgcv') in R.