monkeybread.calc.shortest_distances
- monkeybread.calc.shortest_distances(adata, groupby, group1, group2, basis='X_spatial')
Calculates the distance from each cell in one group to the nearest cell in another group.
- Parameters:
adata (
AnnData) – Annotated data matrix.groupby (
str) – A categorical column inadata.obsto classify groups.group1 (
Union[str,List[str]]) – Either one value or a list of values fromadata.obs[groupby].group2 (
Union[str,List[str]]) – Either one value or a list of values fromadata.obs[groupby].basis (
Optional[str] (default:'X_spatial')) – Coordinates inadata.obsm[{basis}]to use. Defaults tospatial.
- Return type:
- Returns:
: A dataframe, indexed by cells in
group1. The dataframe has two columns,distanceandnearest_cell, corresponding to the distance to the nearest cell ingroup2and the index of that cell respectively.