scverse / scverse/squidpy

spatial_autocorr crashes when the graph contains singletons

Open
#1,256 0 comments 0 reactions 1 assignee View on GitHub

@timtreis is already working on this.

Since Aug 18, 2026.

Dominant language
Python
Stars
598
Forks
121
Avg merge
3d 11h
Merged PRs (30d)
3

Description

Report

Hi,

I thought I'd document something that i ran into. Unfortunately I don't have the logs anymore but let me know and I can try to reproduce if necessary.
I ran sq.gr.spatial_autocorr and it crashed with a seg fault. Upon debugging I realized that I had added an edge pruning step to my graph building, which led to some cells not having any neighbor anymore. If I'm not mistaken, there's a normalization step in spatial_autocorr, performed on the spatial weights matrix. Singletons get a sum of weights of 0 which cascades into a seg fault downstream.
A more transparent error upon detecting singletons would definitely help. Alternatively, the function could be filtering them out automatically?
I'm currently running this step on a filtered version of the AnnData, then exporting the scores separately so I haven't been bothered by not having the scores stored in .uns

Cheers!

Versions

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.