theislab / ncem

Learning cell communication from spatial graphs of cells
https://ncem.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
103 stars 13 forks source link

Error while loading custom data in NCEM #108

Closed archanabhardwaj closed 2 years ago

archanabhardwaj commented 2 years ago

Hello

I am trying to run NCEM after running the deconvolution in cell2location method. I followed entire workflow as given in https://github.com/theislab/ncem_benchmarks/blob/main/notebooks/data_preparation/deconvolution/cell2location_human_lymphnode.ipynb and saved dataset as "cell2location_test.h5ad" based on the information given in the "Collect ncem anndata object" section. Next, I tried to read h5ad data into NCEM for further analysis with custom loader function.

adata_vis # stores information of my cell2location_test.h5ad file

ncem = InterpreterInteraction()

ncem.data = customLoader( adata=adata_vis, cluster='cell_type', patient='A1', library_id='sam_A1', radius=52 )

But its giving me error such as AttributeError: 'numpy.ndarray' object has no attribute 'toarray'

If I am doing something wrong, please correct me.

Thanks in advance

AnnaChristina commented 2 years ago

Hi @archanabhardwaj,

thank you for your interest in running ncem on your own data.

Please store .X as sparse matrix format and the stated code will work. However, the stated tutorial is specifically designed for targeted spatial omics data. You can still use the stated tutorial, but we will also push a specific tutorial for deconvoluted visium soon.

AnnaChristina commented 2 years ago

I am closing the issue for now, but feel free to open it again in case of further questions.