Teichlab / cellphonedb

MIT License
342 stars 105 forks source link

Cellphone is claiming that no functional R environment is installed #286

Closed HeinrichB87 closed 3 years ago

HeinrichB87 commented 3 years ago

Hello,

with the recent version I get an error when running the dot_plot function

"As there is no R environment set up, some functionalities will be disabled, e.g. plot You cannot perform this plot command unless there is a working R setup according to CellPhoneDB specs"

Tested with Python 3.7.9 and 3.9.2 R-version is 4.0.4 and works fine with the recent r-studio using ggplot2 in other contexts.

Can anybody help?

Very much appreciated!

prete commented 3 years ago

Hi @HeinrichB87 cellphonedb uses rpy2 to invoke R. It's difficult to pinpoint the error without knowing more, but you can try this python code from the same environment that you're running cellphonedb to try to get more info about why it's not working (if it's related to R and not to missing ggplot2 or pheatmap):

from rpy2 import situation
print(situation.get_r_home())
print(situation.r_version_from_subprocess())

if either of those has a Falsey value or throws an exception that's probably where the issue is coming from.

Alternatively, you can wrap CellphoneDB in a conda environment, for example using environment.yml from #245 or #270. That would guarantee that the R environment is visible to the package.

weikekaifa commented 3 years ago

Hello, My python version is 4.8.3. I couldn't install cellphonedb with "pip install cellphonedb" command. I got the error "'pip' is not recognized as an internal or external command, operable program or batch file." Can anybody help me? i am very grateful!

weikekaifa commented 3 years ago

Hello, My friend got five files after running the command "cellphonedb method statistical_analysis test_meta.txt test_counts.txt". And when he is running the "cellphonedb method statistical_analysis test_meta.txt test_counts.txt", he got the error "No such command "plot"". Can anybody help me? i am very grateful!"

prete commented 3 years ago

Hi @weikekaifa a) python version 4.8.3 does not exist. May be you're confusing conda version with python? b) 'pip' is not recognized as an internal or external command means that it's not part of your path. You need to add pip to your environment PATH or try something like python -m pip install cellphonedb (assuming python IS in your path) c) cellphonedb method statistical_analysis test_meta.txt test_counts.txt I don't think that command has anything to do with plot. Are you sure that's the command he's running and not cellphonedb plot ?

That being said, if your issue doesn't have something to do with no functional R environment is installed, please open a new issue instead of asking your questions in an existing one that's unrelated.

prete commented 3 years ago

Hi @HeinrichB87 did you manage to get your environment working?

If you're still having issues: could you make sure you've got R_HOME and R_USER environment variables? or try the method described here to install rpy2: https://jianghaochu.github.io/how-to-install-rpy2-in-windows-10.html ? or try it from a conda environment?

bioguy2018 commented 3 years ago

@prete Hello, I have problem with rpy2! apparently the version that is matching with the cellphone db is rpy 2.9.5‑cp37 which as indicated is supposed to use python 3.7 but I am using 3.8 and with the new rpy2 I somehow can't get the r environment done! I have tried the yml file and also isolated env in python and anaconda and it doesn't work! I am not sure if it is really the source of problem but it would be a hassle to downgrade my python and start from the scratch...is there an alternative way? or is it possible that you share the plotting codes so one is able to plot separately in R and not using python for it?

bioguy2018 commented 3 years ago

I found the r codes already and I am sharing the link if anyone is curious about it: https://github.com/Teichlab/cellphonedb/tree/master/cellphonedb/src/plotters/R I guess it's much easier to modify the code if necessary rather than installing rpy2 😃

prete commented 3 years ago

Hi @bioguy2018! You are right, if you've got a working R environment that's not recognized by CellphoneDB or you're having rpy2 issues the easiest thing to do is:

  1. Download plot_dot_by_column_name.R and plot_heatmaps.R scripts from the repository.

  2. Open R terminal or RStuido.

  3. Load the script using source("plot_dot_by_column_name.R") or source("plot_heatmaps.R") accordingly.

  4. Invoke the plot function for each case: dot_plot(...) or heatmaps_plot(...) using the right parameters.

prete commented 3 years ago

@bioguy2018 did you managed to run the scripts manually to get your plots?

bioguy2018 commented 3 years ago

@prete Yes! I did! I just needed to change one or two things ! Thanks!