zcang / COMMOT

MIT License
75 stars 13 forks source link

Error in communication_deg_detection #9

Closed wJDKnight closed 1 year ago

wJDKnight commented 1 year ago

I have installed commot[tradeSeq], R3.6.3, and R package tradeSeq. when running ct.tl.communication_deg_detection(adata, database_name = 'testDB', pathway_name='true_pathway', summary = 'receiver') the error comes out.

RRuntimeError: Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/opt/R/3.6.3/lib/R/library/methods/libs/methods.so': libR.so: cannot open shared object file: No such file or directory

I've checked that '/opt/R/3.6.3/lib/R/library/methods/libs/methods.so' exists. I have tried to set directories of R library. And here is the output of%run -m rpy2.situation

rpy2 version: 3.4.2 Python version: 3.8.13 (default, Oct 21 2022, 23:50:54) [GCC 11.2.0] Looking for R's HOME: Environment variable R_HOME: /opt/R/3.6.3/ Calling R RHOME: /opt/R/3.6.3/lib/R Environment variable R_LIBS_USER: /opt/R/3.6.3/lib/R/library Warning: The environment variable R_HOME differs from the default R in the PATH. R's additions to LD_LIBRARY_PATH: :/opt/R/3.6.3/lib/R/library/methods/libs:/opt/R/3.6.3/lib/R/library/ R version: In the PATH: R version 3.6.3 (2020-02-29) -- "Holding the Windsock" Loading R library from rpy2: OK Additional directories to load R packages from: None C extension compilation: include: ['/opt/R/3.6.3/lib/R/include'] libraries: ['R', 'pcre2-8', 'pcre', 'lzma', 'bz2', 'z', 'tirpc', 'rt', 'dl', 'm', 'icuuc', 'icui18n'] library_dirs: ['/usr/local/lib', '/opt/R/3.6.3/lib/R/lib'] extra_compile_args: [] extra_link_args: ['-Wl,--export-dynamic', '-fopenmp']

wJDKnight commented 1 year ago

I updated the rpy2 to 3.5.9. A new error comes up. I was running the "Visium data example {https://commot.readthedocs.io/en/latest/notebooks/visium-mouse_brain.html#}". I used ct.tl.communication_deg_detection(adata_dis500, database_name = 'cellchat', pathway_name='PSAP', summary = 'receiver')

Traceback (most recent call last): File "", line 1, in File "/root/miniconda3/envs/commot_env/lib/python3.8/site-packages/commot/tools/_downstream_analysis.py", line 146, in communication_deg_detection adata_r = anndata2ri.py2rpy(adata_deg) File "/root/miniconda3/envs/commot_env/lib/python3.8/site-packages/anndata2ri/init.py", line 48, in py2rpy return converter.py2rpy(obj) File "/root/miniconda3/envs/commot_env/lib/python3.8/functools.py", line 875, in wrapper return dispatch(args[0].class)(*args, kw) File "/root/miniconda3/envs/commot_env/lib/python3.8/site-packages/anndata2ri/py2r.py", line 56, in py2rpy_anndata x = {} if obj.X is None else dict(X=mat_converter.py2rpy(obj.X.T)) File "/root/miniconda3/envs/commot_env/lib/python3.8/functools.py", line 875, in wrapper return dispatch(args[0].class)(*args, *kw) File "/root/miniconda3/envs/commot_env/lib/python3.8/site-packages/anndata2ri/scipy2ri/py2r.py", line 43, in wrapper return f(obj) File "/root/miniconda3/envs/commot_env/lib/python3.8/site-packages/anndata2ri/scipy2ri/py2r.py", line 53, in csc_to_rmat return methods.new( File "/root/miniconda3/envs/commot_env/lib/python3.8/site-packages/rpy2/robjects/functions.py", line 207, in call return (super(SignatureTranslatedFunction, self) File "/root/miniconda3/envs/commot_env/lib/python3.8/site-packages/rpy2/robjects/functions.py", line 130, in call res = super(Function, self).call(new_args, new_kwargs) File "/root/miniconda3/envs/commot_env/lib/python3.8/site-packages/rpy2/rinterfacelib/conversion.py", line 45, in cdata = function(*args, **kwargs) File "/root/miniconda3/envs/commot_env/lib/python3.8/site-packages/rpy2/rinterface.py", line 817, in call raise embedded.RRuntimeError(_rinterface._geterrmessage()) rpy2.rinterface_lib.embedded.RRuntimeError: Error in validObject(.Object) : invalid class “dgCMatrix” object: 1: invalid object for slot "i" in class "dgCMatrix": got class "array", should be or extend class "integer" invalid class “dgCMatrix” object: 2: invalid object for slot "p" in class "dgCMatrix": got class "array", should be or extend class "integer" invalid class “dgCMatrix” object: 3: invalid object for slot "Dim" in class "dgCMatrix": got class "array", should be or extend class "integer" invalid class “dgCMatrix” object: 4: invalid object for slot "x" in class "dgCMatrix": got class "array", should be or extend class "numeric"

zcang commented 1 year ago

Hi, I tried a few combinations and the R 3.6.3+rpy2 3.4.2 was the only combination that worked at the time I tried. I guess the error can be resolved by properly set LD_LIBRARY_PATH? Or a fresh configuration like this one might help: https://commot.readthedocs.io/en/latest/installation.html

wJDKnight commented 1 year ago

Thank you. I will try rpy2 3.4.2. For now, I just outputted the results to .csv and finished the tradeSeq part in R.

zcang commented 1 year ago

Yes, I also find this way easier. I hope to implement the GAMs in python but am occupied by too many other things right now.