smart.build_graph

smart.build_graph.Cal_Spatial_Net(adata, radius=None, n_neighbors=None, model='KNN', verbose=True, include_self=False)

Construct spatial neighbor graph from spatial coordinates.

Parameters:
  • adata (anndata.AnnData) – AnnData object containing cell-level spatial coordinates in adata.obsm[‘spatial’].

  • radius (float, optional) – Radius for neighborhood search (used when model=’Radius’).

  • n_neighbors (int, optional) – Number of neighbors (used when model=’KNN’).

  • model ({'KNN', 'Radius'}, default='KNN') – Type of graph construction method.

  • verbose (bool, default=True) – If True, print summary of constructed graph.

  • include_self (bool, default=False) – Whether to include self-loops in the adjacency matrix.

Returns:

The adjacency matrix is stored in adata.uns[‘adj’], and edges in adata.uns[‘edgeList’].

Return type:

None