cassiopeia.sp.get_spatial_graph_from_anndata#

cassiopeia.sp.get_spatial_graph_from_anndata(adata, neighborhood_radius=30.0, neighborhood_size=None, connect_key='spatial')[source]#

Get a spatial graph structure from an spatial anndata

Construct a spatial graph connecting each node to its nearest neighbors in space. Assumes that the specified adata has spatial coordinates specified in the .obsm key.

Parameters:
adata AnnData

Anndata of spatially-resolved data. Only the spatial coordinates need to be stored, and this is used to construct a graph.

neighborhood_size float | None (default: None)

If a connectivitity graph is being constructed, this is the number of nearest neighbors to connect to a node.

neighborhood_radius int (default: 30.0)

Intead of passing in neighborhood_size, this is the radius of the connectivity graph.

connect_key str (default: 'spatial')

Key used to store spatial connectivities in adata.obsp. This will be passed into the key_added argument of sq.gr.spatial_neighbors and an etnry in adata.obsp will be added of the form {connect_key}_connectivities.

Return type:

DiGraph

Returns:

A networkx object storing the spatial graph.