theislab / scCODA

A Bayesian model for compositional single-cell data analysis
BSD 3-Clause "New" or "Revised" License
147 stars 24 forks source link

Cannot import sccoda.util.comp_ana #39

Closed neurOnur closed 2 years ago

neurOnur commented 3 years ago

I installed scCODA (pip install sccoda) without any problem/warning and performed the basic analysis following the getting started tutorial, until the model setup and inference. Unfortunately I cannot import sccoda.util.comp_ana function into python. Following the tutorial:

from sccoda.util import cell_composition_data as dat
from sccoda.util import data_visualization as viz
from sccoda.util.comp_ana import comp_ana as mod

doesn't work for my python installation (conda, python 3.9), thus I used

import sccoda.util.cell_composition_data as dat
import sccoda.util.data_visualization as viz

successfully. When I try to import comp_ana using:

import sccoda.util.comp_ana as mod

The kernel crushes. If I import sccoda separately;

import sccoda

And look for the possible functions, but I only can see cell_composition_data and data_visualization, but not comp_ana

comp_ana.py is under the sccoda/util folder where it is supposed to be. I am not sure what exactly the problem is, but somehow comp_ana is 'invisible'.

I have a Macbook pro M1 with 8-core, my environment details are:

anndata     0.7.6
scanpy      1.8.1
sinfo       0.3.4
-----
PIL                 8.2.0
anyio               NA
appnope             0.1.2
argon2              20.1.0
attr                21.2.0
babel               2.9.1
backcall            0.2.0
brotli              NA
cairo               1.19.1
certifi             2021.05.30
cffi                1.14.5
chardet             4.0.0
cloudpickle         1.6.0
cycler              0.10.0
cython_runtime      NA
dask                2021.06.0
dateutil            2.8.1
decorator           4.4.2
fsspec              2021.06.0
google              NA
h5py                3.1.0
idna                2.10
igraph              0.9.6
ipykernel           5.5.5
ipython_genutils    0.2.0
jedi                0.18.0
jinja2              3.0.1
joblib              1.0.1
json5               NA
jsonschema          3.2.0
jupyter_server      1.8.0
jupyterlab_server   2.6.0
kiwisolver          1.3.1
leidenalg           0.8.4
llvmlite            0.36.0
markupsafe          2.0.1
matplotlib          3.4.2
mpl_toolkits        NA
natsort             7.1.1
nbclassic           NA
nbformat            5.1.3
numba               0.53.1
numexpr             2.7.3
numpy               1.19.5
packaging           20.9
pandas              1.2.4
parso               0.8.2
pexpect             4.8.0
pickleshare         0.7.5
pkg_resources       NA
prometheus_client   NA
prompt_toolkit      3.0.18
psutil              5.8.0
ptyprocess          0.7.0
pvectorc            NA
pyexpat             NA
pygments            2.9.0
pyparsing           2.4.7
pyrsistent          NA
pytz                2021.1
requests            2.25.1
sccoda              0.1.4
scipy               1.6.2
seaborn             0.11.1
send2trash          NA
six                 1.15.0
sklearn             0.24.2
sniffio             1.2.0
socks               1.7.1
sparse              0.12.0
statsmodels         0.12.2
storemagic          NA
tables              3.6.1
tblib               1.7.0
terminado           0.10.1
texttable           1.6.3
tlz                 0.11.1
toolz               0.11.1
tornado             6.1
traitlets           5.0.5
typing_extensions   NA
urllib3             1.26.5
wcwidth             0.2.5
websocket           0.57.0
yaml                5.4.1
zipp                NA
zmq                 22.1.0
-----
IPython             7.24.1
jupyter_client      6.1.12
jupyter_core        4.7.1
jupyterlab          3.0.16
notebook            6.4.0
-----
Python 3.9.4 | packaged by conda-forge | (default, May 10 2021, 22:13:15) [Clang 11.1.0 ]
macOS-11.2.3-x86_64-i386-64bit
8 logical CPU cores, i386
-----
Session information updated at 2021-09-26 14:07

I have tried this on a linux server as well with identical results. Thanks for the time

johannesostner commented 3 years ago

Hi!

First, it seems that there is a typo in your import statement. It should be from sccoda.util import comp_ana as mod or import sccoda.util.comp_ana as mod instead of from sccoda.util.comp_ana import comp_ana as mod.

From the list of installed packages, I can also see that you did not install all the dependencies of scCODA. I suppose that your kernel crashes because of this. Please install the packages via pip, as described in the installation guide.

neurOnur commented 3 years ago

Thanks! I managed to get it going on the linux server using a fresh environment with python 3.8 as recommended. I am not sure if this was the reason as it may be working well with later installations as well. Something in my environment was causing a problem (the typo was only on github). (Note: I used pip install --use-feature=2020-resolver sccoda for installation)

It still does not run on my macbook, but I believe this is some sort of a Tensorflow - M1 issue unrelated to scCODA.

mbuttner commented 2 years ago

Hi @neurOnur

there is a Mac-optimized Tensorflow version for the Apple M1 chip. I found the following tutorial to install tensorflow for Mac using Miniforge (not Anaconda). https://github.com/apple/tensorflow_macos/issues/153

However, the installation of tensorflow-probability was not straightforward to me (as it requires a custom build of bazel), and I could not successfully install scanpy using Miniforge on my Mac with M1 chip.

For now, until there is full support of tensorflow and tensorflow-probability for the M1 chip from Apple, I suggest that you resort to a different computer (or Google Colabs).

neurOnur commented 2 years ago

Hi @mbuttner, Thanks a lot, I indeed installed miniforge and tried to run sccoda, but couldn't finish the installation for a few reasons. It is still good to hear that it was the reasonable path to follow. For now the linux installation is doing the job for me, and I feel the best solution to all Apple M1 (I still love it) problems is simply to wait patiently