scviva.model.base.SpatialNeighborhoodMixin#

class scviva.model.base.SpatialNeighborhoodMixin[source]#

Mixin for spatial neighbor graph computation.

Applied to: SCVIVA, ResolVI. Provides a single entry point for neighbor graph computation with pluggable backends (squidpy on CPU, RAPIDS on GPU).

The computed neighbor arrays are stored in: - adata.obsm["index_neighbor"] — dense int array, shape (n_cells, n_neighs) - adata.obsm["distance_neighbor"] — dense float array, shape (n_cells, n_neighs)

These keys match the upstream ResolVI module’s expected input format.

Methods table

compute_neighbors(adata[, spatial_key, ...])

Compute spatial neighbor graph and store in adata.obsm.

Methods

SpatialNeighborhoodMixin.compute_neighbors(adata, spatial_key='spatial', coord_type='generic', n_neighs=6, backend='squidpy')[source]#

Compute spatial neighbor graph and store in adata.obsm.

Parameters:
adata AnnData

AnnData object with spatial coordinates in adata.obsm[spatial_key].

spatial_key str

Key in adata.obsm for spatial coordinates.

coord_type str

Coordinate type passed to squidpy ("generic" or "visium"). Ignored when backend="rapids".

n_neighs int

Number of nearest neighbors.

backend Literal['squidpy', 'rapids']

"squidpy" (default): uses squidpy.gr.spatial_neighbors(). "rapids": uses cuGraph/cuML for GPU-accelerated computation.

Return type:

None