abelson-lab / scATOMIC

Pan-Cancer Single Cell Classifier
MIT License
57 stars 5 forks source link

pymagic_is_available() exit false #26

Closed kendomaniac closed 4 months ago

kendomaniac commented 4 months ago

Hi, I am attempting to install scATOMIC on docker based on ubuntu 22.04 I installed Python 3.10.12 I installed with pip magic-impute (pip install --user magic-impute) If I import magic in python shell everything is fine. However, if I do in R: library(reticulate) library(Rmagic) install.magic() pymagic_is_available()

I get this message: pymagic_is_available() Loading required package: Matrix Attempting to install MAGIC python package with reticulate Error in value[3L] : Cannot locate MAGIC Python package, please install through pip (e.g. pip install magic-impute) and then restart R.

However, I run your lung tutorial: lung_cancer_demo_data <- demo_lung_data cell_predictions <- run_scATOMIC(lung_cancer_demo_data)

results_lung <- create_summary_matrix(prediction_list = cell_predictions, use_CNVs = F, modify_results = T, mc.cores = 12, raw_counts = lung_cancer_demo_data, min_prop = 0.5 )

table(results_lung$scATOMIC_pred)

I got the expected output.

Any suggestion? Thanks Raf raffaele.calogero@unito.it

inofechm commented 4 months ago

Hi Raf, It seems odd that the tutorial data is working yet pymagic_is_available is giving the error. Could you run: library(Rmagic) data(magic_testdata) data_MAGIC <- magic(magic_testdata)

if you get an output like below it means that the magic package is working and you can just ignore the pymagic_is_available and proceed. In this case, I would just say that it may be a bug in pymagic_is_available on docker, unfortunately RMagic isn't really maintained actively anymore. Calculating MAGIC... Running MAGIC on 500 cells and 197 genes. /Users/inofechmozes/.local/lib/python3.9/site-packages/magic/magic.py:425: UserWarning: Input matrix contains unexpressed genes. Please remove them prior to running MAGIC. warnings.warn( Calculating graph and diffusion operator... Calculating PCA... Calculated PCA in 0.07 seconds. Calculating KNN search... /Users/inofechmozes/opt/miniconda3/lib/python3.9/site-packages/graphtools/graphs.py:290: RuntimeWarning: Detected zero distance between 10 pairs of samples. Consider removing duplicates to avoid errors in downstream processing. warnings.warn( Calculated KNN search in 0.09 seconds. Calculating affinities... Calculated affinities in 0.07 seconds. Calculated graph and diffusion operator in 0.24 seconds. Calculating imputation... Calculated MAGIC in 0.26 seconds.

If this isn't working I would guess that R isn't interfacing to the right python environment. You can add the following line before you load the libraries and reticulate and this may solve the issue: Sys.setenv(RETICULATE_PYTHON = Sys.which("python"))

Let me know if this works, Ido

kendomaniac commented 4 months ago

Hi Ido, I tested it and I get exactly the same output you provided me. thank yo so much! Raf