monkeybread.calc.shortest_distances_pairwise

monkeybread.calc.shortest_distances_pairwise(adata, groupby, group1, group2, basis='X_spatial')

Calculates the distance from each cell in one group to the nearest cell in another group. Performs this calculation between all pairs of cell types in group1 and group2.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • groupby (str) – A categorical column in adata.obs to classify groups.

  • group1 (List[str]) – A list of values from adata.obs[groupby].

  • group2 (List[str]) – A list of values from adata.obs[groupby].

  • basis (Optional[str] (default: 'X_spatial')) – Coordinates in adata.obsm[{basis}] to use. Defaults to spatial.

Return type:

Dict[str, Dict[str, DataFrame]]

Returns:

: A dictionary mapping each value in group1 to a dictionary that maps each value in group2 to a dataframe. This dataframe is indexed by by cells in the group1 value. The dataframe has two columns, distance and nearest_cell, corresponding to the distance to the nearest cell in the given group2 cell type and the index of that cell respectively.