monkeybread.calc.cell_contact
- monkeybread.calc.cell_contact(adata, groupby, group1, group2, basis='spatial', radius=None)
Detects contact between two groups of cells.
The output takes the form of a dictionary mapping from cells in
group1
to cells ingroup2
that the cell contacts. If a cell is present in bothgroup1
andgroup2
, the mapping will be reflexive - the cell may both appear in the keys and the values.- Parameters
adata (
AnnData
) – Annotated data matrix.groupby (
str
) – A categorical column inadata.obs
to classify groups.group1 (
Union
[str
,List
[str
]]) – Either one group or a list of groups fromadata.obs[groupby]
.group2 (
Union
[str
,List
[str
]]) – Either one group or a list of groups fromadata.obs[groupby]
.basis (
Optional
[str
] (default:'spatial'
)) – Coordinates inadata.obsm[X_{basis}]
to use. Defaults tospatial
.radius (
Optional
[float
] (default:None
)) – The radius in which cells are considered touching. If not provided, will be calculated using half of the average radius of group1 + half of the average radius of group2. This requires width and height columns to be present inadata.obs
.
- Return type
- Returns
A mapping from cell ids in
group1
to sets of cell ids ingroup2
indicating contact.