BIMSBbioinfo / ikarus

Identifying tumor cells at the single-cell level using machine learning
MIT License
43 stars 12 forks source link

ValueError: output array is read-only when calling preprocess_adata #18

Closed ImNotaGit closed 8 months ago

ImNotaGit commented 1 year ago

I am trying to run ikarus from R with reticulate. To prepare the data I used this line following the tutorial:

adata = ikarus$data$preprocess_adata(adata)

This give the error:

Error in py_call_impl(callable, dots$args, dots$keywords) :
  ValueError: output array is read-only

BTW, I also wonder what preprocess_adata does internally. If not using this function, would a regular log-normalization (i.e. normalize by total UMI counts, multiplied by a scaling factor, then log-transform with a pseudocount) do the job?

I am using R 4.2.1, python 3.10.13. Since this seems to be an issue happening in python, below I list the python module versions installed:

Package                 Version
----------------------- ------------
aiohttp                 3.8.5
aiosignal               1.3.1
anndata                 0.9.2
arboreto                0.1.6
async-timeout           4.0.3
attrs                   23.1.0
BitVector               3.5.0
bokeh                   3.2.2
boltons                 23.0.0
certifi                 2023.7.22
charset-normalizer      3.2.0
click                   8.1.7
cloudpickle             2.2.1
contourpy               1.1.0
ctxcore                 0.2.0
cycler                  0.11.0
cytoolz                 0.12.2
dask                    2023.9.0
dill                    0.3.7
distributed             2023.9.0
docutils                0.20.1
fonttools               4.42.1
frozendict              2.3.8
frozenlist              1.4.0
fsspec                  2023.9.0
GMM-Demux               0.2.2.1
h5py                    3.9.0
idna                    3.4
igraph                  0.10.6
ikarus                  0.0.3
importlib-metadata      6.8.0
interlap                0.2.7
Jinja2                  3.1.2
joblib                  1.3.2
kiwisolver              1.4.5
leidenalg               0.10.1
llvmlite                0.40.1
locket                  1.0.0
loompy                  3.0.7
lz4                     4.3.2
MarkupSafe              2.1.3
matplotlib              3.7.2
msgpack                 1.0.5
multidict               6.0.4
multiprocessing-on-dill 3.5.0a4
natsort                 8.4.0
networkx                3.1
numba                   0.57.1
numexpr                 2.8.5
numpy                   1.24.4
numpy-groupies          0.9.22
packaging               23.1
pandas                  2.1.0
partd                   1.4.0
patsy                   0.5.3
Pillow                  10.0.0
pip                     23.2.1
psutil                  5.9.5
pyarrow                 13.0.0
pynndescent             0.5.10
pyparsing               3.0.9
pyscenic                0.12.1
python-dateutil         2.8.2
pytz                    2023.3.post1
PyYAML                  6.0.1
requests                2.31.0
scanpy                  1.9.4
scikit-learn            1.3.0
scipy                   1.11.2
seaborn                 0.12.2
session-info            1.0.0
setuptools              68.1.2
six                     1.16.0
sklearn                 0.0.post7
sortedcontainers        2.4.0
statistics              1.0.3.5
statsmodels             0.14.0
stdlib-list             0.9.0
tabulate                0.9.0
tblib                   2.0.0
texttable               1.6.7
threadpoolctl           3.2.0
toolz                   0.12.0
tornado                 6.3.3
tqdm                    4.66.1
tzdata                  2023.3
umap-learn              0.5.3
urllib3                 2.0.4
wheel                   0.41.2
xyzservices             2023.7.0
yarl                    1.9.2
zict                    3.0.0
zipp                    3.16.2
melonheader commented 11 months ago

Hello @ImNotaGit,

The error message you received suggests that there might be an issue with how the data is being passed between pythonand R. I often had problems with reticulate and, similarly often, it was challenging to debug. If reticulate can be avoided, I would suggest running Ikarus in plain python.

CarloManenti commented 9 months ago

Hi, I was having a simular issue! Have you tried using the copy method on the passed object? like this… adata = ikarus$data$preprocess_adata(adata$copy()) . It should fix the issue.

melonheader commented 8 months ago

@CarloManenti Thank you for the comment. I will be closing this issue for now. Feel free to re-open if the suggested approach doesn't work.