squidpy.gr.spatial_neighbors

squidpy.gr.spatial_neighbors(adata, spatial_key='spatial', coord_type=None, n_rings=1, n_neigh=6, radius=None, transform=None, key_added=None)[source]

Create a graph from spatial coordinates.

Parameters
  • adata (AnnData) – Annotated data object.

  • spatial_key (str) – Key in anndata.AnnData.obsm where spatial coordinates are stored.

  • coord_type (Union[str, CoordType, None]) –

    Type of coordinate system. Valid options are:

    • visium - Visium coordinates.

    • generic - generic coordinates.

    If None, use visium if spatial_key is present in anndata.AnnData.obsm, otherwise use generic.

  • n_rings (int) – Number of rings of neighbors for Visium data.

  • n_neigh (int) – Number of neighborhoods to consider for non-Visium data.

  • radius (Optional[float]) – Radius of neighbors for non-Visium data.

  • transform (Union[str, Transform, None]) –

    Type of adjacency matrix transform. Valid options are:

    • ’spectral’ - spectral transformation of the adjacency matrix.

    • ’cosine’ - cosine transformation of the adjacency matrix.

    • None - no transformation of the adjacency matrix.

  • key_added (Optional[str]) – Key which controls where the results are saved.

Return type

None

Returns

Modifies the adata with the following keys: