monkeybread.calc.number_of_neighbors_from_masks
- monkeybread.calc.number_of_neighbors_from_masks(adata, query_to_mask, reference_mask, 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.
Groups are specified from masks (i.e., Boolean-valued lists) that specify whether each cell in the dataset belongs to each group.
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.query_to_mask (
Dict[str,List[bool]]) – A dictionary mapping the name of a query group to a Boolean mask (i.e., Boolean-valued list). Each element of a mask corresponds to an index inadata.Trueindicates the cell belongs to the group, andFalseindicates the cell does not belong to the group.reference_mask (
List[bool]) – A mask specifying cells in the reference group.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.