spatialvi.data.compute_niche_composition

spatialvi.data.compute_niche_composition#

spatialvi.data.compute_niche_composition(adata, labels_key, index_key='nn_index', composition_key='niche_composition', copy=False)[source]#

Compute neighborhood cell type composition.

Parameters:
  • adata (AnnData) – AnnData object with neighbor indices.

  • labels_key (str) – Key in obs for cell type labels.

  • index_key (str) – Key in obsm for neighbor indices.

  • composition_key (str) – Key to store composition in obsm.

  • copy (bool) – Whether to return a copy of the AnnData.

  • adata (AnnData)

  • labels_key (str)

  • index_key (str)

  • composition_key (str)

  • copy (bool)

Return type:

AnnData | None

Returns:

AnnData with composition if copy=True, else None.