monkeybread.calc.number_of_neighbors
- monkeybread.calc.number_of_neighbors(adata, groupby, query_groups, reference_group, radius=75)
Given a set of query groups of cells, group_1, group_2, … group_N, and a reference group of cells, calculate the number of reference cells within the neighborhood of each cell in the query groups.
For example, our query groups might be “B cell” and “T cell” and our reference group might be “tumor cell”. This function computes the number of tumor cells in the neighborhood around each B cell and each T cell.
- Parameters:
adata (
AnnData) – Annotated data matrix.groupby (
str) – Key for column ofadata.obsstoring the cell type column used to group cells.query_groups (
List[str]) – List of query cell types inadata.obs[{groupby}]reference_group (
str) – Name of the query cell type inadata.obs[{groupby}]radius (
Optional[float] (default:75)) – Radius of the neighborhoods centered around each query cell.
- Returns:
: A
pd.DataFramestoring the number of neighbors that are of the reference group to each cell in the query groups.