Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with delaunay=True #70

Open
Thapeachydude opened this issue Jan 24, 2025 · 1 comment
Open

Error with delaunay=True #70

Thapeachydude opened this issue Jan 24, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@Thapeachydude
Copy link

Report

Hello,

I'm running into an issue in the very first step sq.gr.spatial_neighbors, whenever delaunay is set to True.

sq.gr.spatial_neighbors(adata = anndata, spatial_key = "spatial", coord_type = "generic", percentile = 99, n_neighs = 15, library_key= "sample") works, but sq.gr.spatial_neighbors(adata = anndata, spatial_key = "spatial", coord_type = "generic", percentile = 99, delaunay = True, library_key= "sample") crashes.

The full error message:

>>> sq.gr.spatial_neighbors(adata = anndata, spatial_key = "spatial", coord_type = "generic", percentile = 99, delaunay = True, library_key= "grid")
Traceback (most recent call last):
  File "/home/mpohl/.local/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3805, in get_loc
    return self._engine.get_loc(casted_key)
  File "index.pyx", line 167, in pandas._libs.index.IndexEngine.get_loc
  File "index.pyx", line 173, in pandas._libs.index.IndexEngine.get_loc
TypeError: '(array([18304, 19417,     3, 19416, 19418,     1], dtype=int32), slice(None, None, None))' is an invalid key

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/mpohl/.local/lib/python3.10/site-packages/squidpy/gr/_build.py", line 239, in spatial_neighbors
    mats.append(_build_fun(adata[adata.obs[library_key] == lib]))
  File "/home/mpohl/.local/lib/python3.10/site-packages/squidpy/gr/_build.py", line 293, in _spatial_neighbor
    Adj, Dst = _build_connectivity(
  File "/home/mpohl/.local/lib/python3.10/site-packages/squidpy/gr/_build.py", line 395, in _build_connectivity
    dists = np.array(list(chain(*(
  File "/home/mpohl/.local/lib/python3.10/site-packages/squidpy/gr/_build.py", line 396, in <genexpr>
    euclidean_distances(coords[indices[indptr[i] : indptr[i + 1]], :], coords[np.newaxis, i, :])
  File "/home/mpohl/.local/lib/python3.10/site-packages/pandas/core/frame.py", line 4102, in __getitem__
    indexer = self.columns.get_loc(key)
  File "/home/mpohl/.local/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3817, in get_loc
    self._check_indexing_error(key)
  File "/home/mpohl/.local/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 6059, in _check_indexing_error
    raise InvalidIndexError(key)
pandas.errors.InvalidIndexError: (array([18304, 19417,     3, 19416, 19418,     1], dtype=int32), slice(None, None, None))

I'm used to doing single-cell analysis in R but haven't had much python exposure, so any insights would be much appreciated.
Thanks!

Version information

No response

@Thapeachydude Thapeachydude added the bug Something isn't working label Jan 24, 2025
@marcovarrone
Copy link
Collaborator

Hi @Thapeachydude, it looks like a squidpy-specific problem, so I suggest you write an issue in their repository!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants