Skip to content
New issue

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

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

Already on GitHub? # to your account

Error with delaunay=True #946

Open
Thapeachydude opened this issue Jan 24, 2025 · 0 comments
Open

Error with delaunay=True #946

Thapeachydude opened this issue Jan 24, 2025 · 0 comments

Comments

@Thapeachydude
Copy link

Thapeachydude commented Jan 24, 2025

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:

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!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant