theislab / graphcompass

GraphCompass: Graph Comparison Tools for Differential Analyses in Spatial Systems
MIT License
32 stars 0 forks source link

ValueError: setting an array element with a sequence. #62

Closed mairamirza closed 2 months ago

mairamirza commented 2 months ago

Hi, I am using this tutorial https://github.com/theislab/graphcompass/blob/main/notebooks/wlkernel/wlkernel_visium.ipynb from Graphcompass Github. I am encountering a ValueError when trying to compute Weisfeiler-Lehman Graph Kernels using the code below. After investigating, it seems the issue is related to the version of NumPy. To resolve it, I would need to downgrade NumPy to version 1.21.1, which also requires downgrading pandas. But, GraphComapss requires pandas version 2.1.0 or higher. I would appreciate any help in resolving this compatibility issue.

Thank you in advance.

      gc.tl.wlkernel.compare_conditions(
       adata=adata,
       library_key=library_key,
       cluster_key=cluster_key,
       compute_spatial_graphs=True,
       kwargs_spatial_neighbors={
            'coord_type': 'grid',
            'n_neighs': 6,
        },
    )
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[17], line 4
      1 # compute WWL kernels
      2 ### results are stored in adata.uns["wl_kernel"]
----> 4 gc.tl.wlkernel.compare_conditions(
      5    adata=adata,
      6    library_key=library_key,
      7    cluster_key=cluster_key,
      8    compute_spatial_graphs=True,
      9    kwargs_spatial_neighbors={
     10         'coord_type': 'grid',
     11         'n_neighs': 6,
     12     },
     13 )

File ~/localenv/mirza/anaconda/envs/GraphCompass/lib/python3.9/site-packages/graphcompass/tl/_WLkernel.py:115, in compare_conditions(adata, library_key, cluster_key, cell_types_keys, compute_spatial_graphs, kwargs_nhood_enrich, kwargs_spatial_neighbors, copy, **kwargs)
    112         features = features.toarray()
    113     node_features.append(np.array(features))
--> 115 node_features = np.array(node_features)
    116 # compute the kernel
    117 print("Computing WWL kernel matrix...")

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (17,) + inhomogeneous part.
merelkuijs commented 2 months ago

Hi! Thanks for opening an issue. We are familiar with this bug and are in the process of resolving it. In the meanwhile, could you try again using the following dependencies:

aiobotocore==2.5.4
aiohttp==3.9.3
aioitertools==0.11.0
aiosignal==1.3.1
anndata==0.10.5.post1
annotated-types==0.6.0
array_api_compat==1.4.1
asciitree==0.3.3
asttokens==2.4.1
async-timeout==4.0.3
attrs==23.2.0
botocore==1.31.17
certifi==2024.2.2
charset-normalizer==3.3.2
click==8.1.7
click-plugins==1.1.1
cligj==0.7.2
cloudpickle==3.0.0
colorcet==3.1.0
comm==0.2.2
contourpy==1.2.0
cycler==0.12.1
Cython==3.0.8
dask==2024.2.1
dask-image==2023.8.1
datashader==0.16.0
debugpy==1.8.1
decorator==5.1.1
distributed==2024.2.1
docrep==0.3.2
exceptiongroup==1.2.1
executing==2.0.1
fasteners==0.19
fiona==1.9.5
fonttools==4.49.0
frozenlist==1.4.1
fsspec==2023.6.0
geopandas==0.14.3
graphcompass==0.2.2
h5py==3.10.0
idna==3.6
igraph==0.11.4
imageio==2.34.0
importlib-metadata==7.0.1
inflect==7.0.0
ipykernel==6.29.4
ipython==8.21.0
jedi==0.19.1
Jinja2==3.1.3
jmespath==1.0.1
joblib==1.3.2
jupyter_client==8.6.1
jupyter_core==5.7.2
kiwisolver==1.4.5
lazy_loader==0.3
leidenalg==0.10.2
llvmlite==0.42.0
locket==1.0.0
markdown-it-py==3.0.0
MarkupSafe==2.1.5
matplotlib==3.8.3
matplotlib-inline==0.1.7
matplotlib-scalebar==0.8.1
mdurl==0.1.2
msgpack==1.0.8
multidict==6.0.5
multipledispatch==1.0.0
multiscale_spatial_image==0.11.2
natsort==8.4.0
nest-asyncio==1.6.0
NetLSD==1.0.2
networkx==3.2.1
numba==0.59.0
numcodecs==0.12.1
numpy==1.23.4
ome-zarr==0.8.3
omnipath==1.0.8
packaging==24.0
pandas==2.2.1
param==2.0.2
parso==0.8.4
partd==1.4.1
patsy==0.5.6
pexpect==4.9.0
pillow==10.2.0
PIMS==0.6.1
platformdirs==4.2.0
POT==0.9.3
prompt-toolkit==3.0.43
psutil==5.9.8
ptyprocess==0.7.0
pure-eval==0.2.2
pyarrow==15.0.0
pyct==0.5.0
pydantic==2.6.3
pydantic_core==2.16.3
pygeos==0.14
Pygments==2.17.2
pynndescent==0.5.11
pyparsing==3.1.1
pyproj==3.6.1
python-dateutil==2.9.0.post0
python-igraph==0.11.4
pytz==2024.1
PyWavelets==1.5.0
PyYAML==6.0.1
pyzmq==26.0.2
requests==2.31.0
rich==13.7.1
s3fs==2023.6.0
scanpy==1.9.8
scikit-image==0.20.0
scikit-learn==1.4.1.post1
scipy==1.12.0
seaborn==0.13.2
session-info==1.0.0
shapely==2.0.3
six==1.16.0
slicerator==1.1.0
sortedcontainers==2.4.0
spatial_image==0.3.0
spatialdata==0.0.15
squidpy==1.4.1
stack-data==0.6.3
statannot==0.2.3
statsmodels==0.14.1
stdlib-list==0.10.0
tblib==3.0.0
texttable==1.7.0
threadpoolctl==3.3.0
tifffile==2024.2.12
toolz==0.12.1
tornado==6.4
tqdm==4.66.2
traitlets==5.9.0
typing_extensions==4.10.0
tzdata==2024.1
umap-learn==0.5.5
urllib3==1.26.18
validators==0.22.0
wcwidth==0.2.13
wrapt==1.16.0
wwl==0.1.2
xarray==2023.12.0
xarray-dataclasses==1.7.0
xarray-datatree==0.0.14
xarray-schema==0.0.3
xarray-spatial==0.3.7
yarl==1.9.4
zarr==2.17.0
zict==3.0.0
zipp==3.17.0

Could you paste these in a requirements file, e.g. requirements.txt, and then install the packages using pip install -r /path/to/requirements.txt?

mairamirza commented 2 months ago

Hey, Thank you so much for the suggestion. It worked!

merelkuijs commented 2 months ago

Great! I will close the issue then.