monkeybread.calc.shortest_distances
- monkeybread.calc.shortest_distances(adata, groupby, group1, group2, basis='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.obs
to 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:'spatial'
)) – Coordinates inadata.obsm[X_{basis}]
to use. Defaults tospatial
.
- Return type
- Returns
A dataframe, indexed by cells in
group1
. The dataframe has two columns,distance
andnearest_cell
, corresponding to the distance to the nearest cell ingroup2
and the index of that cell respectively.