rapids_singlecell.gr.spatial_neighbors_delaunay#
- rapids_singlecell.gr.spatial_neighbors_delaunay(adata, *, spatial_key='spatial', table_key=None, elements_to_coordinate_systems=None, library_key=None, radius=None, percentile=None, transform=None, set_diag=False, key_added='spatial', copy=False)[source]#
Build a Delaunay graph with Euclidean edge lengths.
radiusoptionally prunes edges to an inclusive interval beforepercentile; a scalar means(0, radius). Larger 2D inputs use validated GPU triangulation; small, 3D, and failed inputs use SciPy/Qhull. Of duplicate coordinates, one observation gets the edges.- Parameters:
- adata
AnnData|SpatialData Annotated data matrix, or a SpatialData object containing the selected table. SpatialData is optional and imported only for SpatialData input.
- spatial_key
str(default:'spatial') Key in
adata.obsmcontaining coordinates. For SpatialData, transformed element centroids (x, y) are written here in table observation order.- table_key
str|None(default:None) Key in
SpatialData.tables. Required for SpatialData input; ignored for AnnData input.- elements_to_coordinate_systems
dict[str,str] |None(default:None) Mapping from spatial element names to coordinate system names. Required for SpatialData input and must cover all regions annotated by the table. Graphs are built independently per region; ignored for AnnData input.
- library_key
str|None(default:None) Categorical column in
adata.obsdefining independent libraries. For SpatialData, the table region key is used instead.- radius
float|tuple[float,float] |None(default:None) Optional inclusive Euclidean distance cutoff. A scalar means
(0, radius); a pair specifies the interval.Nonekeeps all edges.- percentile
float|None(default:None) Prune edges above this distance percentile (0 to 100) independently per library, after radius pruning. Stored zeros, including the diagonal, contribute to the percentile.
Nonedisables percentile pruning.- transform
Literal['spectral','cosine'] |None(default:None) Connectivity transform:
None,"spectral"(normalization by column degrees), or"cosine"(similarity between connectivity rows). Applied after pruning and adding the requested diagonal; distances are unchanged.- set_diag
bool(default:False) Whether to set connectivity self-loops before transforming the graph. Distance diagonals are zero; cosine can create connectivity self-loops even when this is
False.- key_added
str(default:'spatial') Prefix for graph keys in
adata.obspand neighbor metadata inadata.uns. For SpatialData, results are stored in the selected table.- copy
bool(default:False) Return the graph matrices instead of storing graphs and metadata. For SpatialData, centroid coordinates are still written to the table.
- adata
- Return type:
- Returns:
SpatialNeighborsResult | None With
copy=True, return connectivity and distance matrices as SciPy CSR matrices. Built-in builders store float32 connectivities and distances; Squidpy stores Euclidean distances as float64. Otherwise, returnNoneand store'{key_added}_connectivities'and'{key_added}_distances'inadata.obsp, and graph parameters inadata.uns['{key_added}_neighbors']. For SpatialData,adatahere denotes the selected table.