sparrow.tb.nhood_enrichment

sparrow.tb.nhood_enrichment#

sparrow.tb.nhood_enrichment(sdata, labels_layer, table_layer, output_layer, celltype_column='annotation', seed=0, overwrite=False)#

Calculate the nhood enrichment using squidpy via sq.gr.spatial_neighbors and sq.gr.nhood_enrichment.

Parameters:
  • sdata (SpatialData) – Input SpatialData object containing spatial data.

  • labels_layer (list[str]) – The labels layer(s) of sdata used to select the cells via the _REGION_KEY in sdata.tables[table_layer].obs. Note that if output_layer is equal to table_layer and overwrite is True, cells in sdata.tables[table_layer] linked to other labels_layer (via the _REGION_KEY), will be removed from sdata.tables[table_layer] (also from the backing zarr store if it is backed).

  • table_layer (str) – The table layer in sdata.

  • output_layer (str) – The output table layer in sdata.

  • celltype_column (str (default: 'annotation')) – This will be passed to cluster_key of squidpy.gr.nhood_enrichment.

  • seed (int (default: 0)) – seed

  • overwrite (bool (default: False)) – If True, overwrites the output_layer if it already exists in sdata.

Return type:

SpatialData

Returns:

: The updated SpatialData object.