Garfield.analysis.calc_neighbor_prop

Garfield.analysis.calc_neighbor_prop(adata, batch_key='replicates', celltype_key='Cluster', n_neighbors=25, spatial_key='spatial', output_key=None)[source]

Normalize the cell type abundance based on the nearest neighbors for each batch in the AnnData object.

Parameters:
  • adata (AnnData) – The AnnData object containing the spatial data and cell type information.

  • batch_key (str, optional) – The key in adata.obs to identify different batches (default is ‘replicates’).

  • celltype_key (str, optional) – The key in adata.obs representing the cell types (default is ‘Cluster’).

  • n_neighbors (int, optional) – The number of nearest neighbors to consider for each cell (default is 25).

  • spatial_key (str, optional) – The key in adata.obsm containing the spatial coordinates (default is ‘spatial’).

  • output_key (str, optional) – The key to store the normalized cell type abundances in adata.obsm (default is None).

Returns:

adata – The updated AnnData object with normalized cell type abundances added to obsm.

Return type:

AnnData