saezlab / liana

LIANA: a LIgand-receptor ANalysis frAmework
https://saezlab.github.io/liana/
GNU General Public License v3.0
173 stars 30 forks source link

Library issue with natmi and squidpy #17

Closed paulyashna closed 3 years ago

paulyashna commented 3 years ago

Hi,

I have installed natmi and squidpy via conda using the suggested liana_env.yml file as described. Conda env was setup successfully and there were no errors.

However, I keep getting the following errors. Do you have an idea what is causing this. Any hints in this direction would be helpful:

with squidpy: Error: attempt to select less than one element in get1index

with natmi: Error: ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found

P.S.: my system administrator has trying fixing this library, but this has not helped. Grateful for any ideas from your end.

Thanks, Yashna

dbdimitrov commented 3 years ago

Hi Yashna,

Regarding Squidpy, it seems that the idents in the Seurat object are not appropriately set and the Squidpy pipeline cannot allocate the correct cluster metadata - this is an easy fix. Please see the following comment: https://github.com/saezlab/liana/issues/13#issuecomment-884836511

Regarding NATMI, I have not encountered this error previously, but I found this issue, in case it helps.

PS, I'm in the process of re-implementing most of the packages in R, with the intent to resolve such issues.

Cheers, Daniel

paulyashna commented 3 years ago

Hi Daniel,

Thanks for replying quickly. When I fix the Seurat object idents for squidpy, i get the same error as in natmi.

From the side of systems admin: libstdc++.so.6 library is updated and the package is able to access the newer versions of the libstdc++.so.6 library object. i.e. it finds the library on running: “locate libstdc++.so.6”. The issues isn’t that it can’t find the file, it’s that it doesn’t like the version that it finds. Does LIANA have any requirements regarding specific gcc versions?

Thanks for your help. Best Regards, Yashna

dbdimitrov commented 3 years ago

Hi Yashna,

I think I actually recall coming across this now. For me it was related to pandas and if I remember correctly, I followed this https://github.com/BVLC/caffe/issues/4953 to solve it.

Possibly it is simply not locating the library as it looks for it exclusively in the conda environment. So let me know if installing it in conda works: conda activate liana_env conda install libgcc

I hope this works.

hzorkic commented 3 years ago

Hi Daniel,

I am simply trying to run the tutorial shown on the tutorial site. I'm pretty sure the venv was set up correctly, but these are the errors I get when running squidpy and natmi. As you can see, connectome works just fine.

$squidpy
<Rcpp::exception in py_run_file_impl(file, local, convert): ModuleNotFoundError: No module named 'squidpy'>

$connectome
# A tibble: 9,396 × 8
   source target ligand receptor weight_norm weight_sc p_val_adj.lig p_val_adj.rec
   <chr>  <chr>  <chr>  <chr>          <dbl>     <dbl>         <dbl>         <dbl>
 1 CD8 T  B      BMPR2  ACVR1              0    0.0375             1             1
 2 B      B      BMPR2  ACVR1              0    0.0375             1             1
 3 NK     B      BMPR2  ACVR1              0    0.0375             1             1
 4 CD8 T  CD8 T  BMPR2  ACVR1              0   -0.0750             1             1
 5 B      CD8 T  BMPR2  ACVR1              0   -0.0750             1             1
 6 NK     CD8 T  BMPR2  ACVR1              0   -0.0750             1             1
 7 CD8 T  NK     BMPR2  ACVR1              0    0.0375             1             1
 8 NK     NK     BMPR2  ACVR1              0    0.0375             1             1
 9 B      NK     BMPR2  ACVR1              0    0.0375             1             1
10 B      B      GDF11  ACVR1B             0    0.105              1             1
# … with 9,386 more rows

$natmi
<simpleError in file(file, ifelse(append, "a", "w")): cannot open the connection>

Any help would be appreciated!

paulyashna commented 3 years ago

conda install libgcc

Hi Daniel,

Installing it through conda (this installs the latest version of libgcc 7.2.0) has not worked for me.

Is there a specific libgcc version that should be installed? Appreciate your time and help on this.

Thanks, Yashna

dbdimitrov commented 3 years ago

Hi Hayley and Yashna,

What I would propose is to perhaps try to simplify the conda environment - a lot of the packages that are in the current one are there to provide a stable environment so that NATMI works - I have now re-implemented the NATMI algorithm in R and will soon make a release with it.

In the meantime, I would suggest to try create a clean environment for Squidpy alone:

conda env remove -n liana_env conda create -n liana_env conda install -c anaconda python=3.8.5 pip install squidpy

This way it should be an environment that is perfectly clean from any polluting dependencies and should work with Squidpy

hzorkic commented 3 years ago

@dbdimitrov after executing the following commands, squidpy still does not work:

$squidpy
<simpleError in use_python(python, required = required): Specified version of python '/Users/zorkich/miniconda3/envs/liana_env/bin/python' does not exist.> 
paulyashna commented 3 years ago

Hi @dbdimitrov ,

Thanks for your quick reply.

I am able to successfully run call_squidpy after reinitiating conda env only with squidpy. However, it still does not work as a liana_wrap. I may have to check again how it is taking the Idents from my seurat object.

Thanks a lot for this. Looking forward for updates on 'natmi'.

Best Regards, Yashna

dbdimitrov commented 3 years ago

@hzorkic hmm it seems that either your reticulate isn't recognising the conda environment or that the environment itself is not set up.

What happens if you try to start python and import squidpy in the conda environment?

hzorkic commented 3 years ago

Daniel,

I'm relatively new to envs. Please let me know if I am understanding you correctly- you want me to activate the environment, start python, and then import squidpy with pip ?

Thank you for your help!!

dbdimitrov commented 3 years ago

Hi Hayley,

Yes, exactly!

conda activate liana_env
python
import squdipy

This is to confirm if python and squidpy got appropriately installed in conda

If either is missing attempt to install both with the code from above: conda create -n liana_env conda install -c anaconda python=3.8.5 and check if you are indeed in the appropriate environment (liana_env)

hzorkic commented 3 years ago

bingo!!! thank you so much!!

hzorkic commented 3 years ago

@dbdimitrov hello again, squidpy was working fine, but now i am getting this error. Note: I have note pulled since the last time i messaged.

> ## RUN cellphonedb alone with OmniPath
> cc_res <- call_squidpy(
+   seurat_object = testdata,
+   op_resource = select_resource('OmniPath')[[1]])
Error in UseMethod("select") : 
  no applicable method for 'select' applied to an object of class "character"

Any idea what's up?

hzorkic commented 3 years ago

followup: if i run squidpy as such:

# Run liana
liana_test <- liana_wrap(testdata,
                         method = c("sca", "natmi", "connectome",
                                    "cellchat", "squidpy"),
                         resource = c('OmniPath'),
                         # CellChat requires normalized data
                         cellchat.params = list(.normalize=TRUE))

I do get output, and it matches what you have on the tutorial, but I am worried it is incorrect as all of the pvalues are NaN...

$squidpy
# A tibble: 9,396 × 8
   ligand receptor source target means pvalue uniprot_source unprot_target
   <chr>  <chr>    <chr>  <chr>  <dbl>  <dbl> <chr>          <chr>        
 1 NRP2   SEMA4F   B      B          0    NaN O60462         O95754       
 2 NRP2   SEMA4F   B      CD8 T      0    NaN O60462         O95754       
 3 NRP2   SEMA4F   B      NK         0    NaN O60462         O95754       
 4 NRP2   SEMA4F   CD8 T  B          0    NaN O60462         O95754       
 5 NRP2   SEMA4F   CD8 T  CD8 T      0    NaN O60462         O95754       
 6 NRP2   SEMA4F   CD8 T  NK         0    NaN O60462         O95754       
 7 NRP2   SEMA4F   NK     B          0    NaN O60462         O95754       
 8 NRP2   SEMA4F   NK     CD8 T      0    NaN O60462         O95754       
 9 NRP2   SEMA4F   NK     NK         0    NaN O60462         O95754       
10 BAMBI  BMPR1A   B      B          0    NaN Q13145         P36894 
dbdimitrov commented 3 years ago

Hi @hzorkic,

I don't see anything that should be the cause for squidpy not to work when called via its call_ function. This is in fact exactly how I run the unit test for squidpy.

Regarding the liana_wrap output, most of the Squidpy pvalues are usually NaNs (due to many of the genes having an expression of 0 and hence pvalues for those are not calculated). I can have a proper look on Monday and come back to you.

PS, I recommend the installing the latest update of liana. I've made some considerable changes to it's stability and should now be much less laborious to install.