voyagerpy.spatial.losh#
- voyagerpy.spatial.losh(adata: AnnData, feature: str | Sequence[str], graph_name: str | None = None, inference: None | Literal['permutation'] | Literal['chi-square'] = None, inplace: bool = True, key_added: str = 'losh', layer: str | None = None) AnnData#
Compute LOSH for a feature. Local spatial heterogeneity (LOSH) is a measure of how spatially clustered a feature is. It is defined as the ratio of the variance of the feature in the neighborhood of a cell to the variance of the feature in the entire dataset. The neighborhood is defined by the spatial graph.
- Parameters:
adata (AnnData) – The AnnData object to compute LOSH for.
feature (Union[str, Sequence[str]]) – The feature(s) to compute LOSH for. Must be a column in
adata.obsor in``adata.var_names``.graph_name (Optional[str], optional) – The neighborhood graph name, defaults to None.
inference (Union[None, Literal["permutation"], Literal["chi, optional) – The inference method to pass to
esda.LOSHconstructor, defaults to Noneinplace (bool, optional) – Whether to add the results to adata inplace or copy it, defaults to True
key_added (str, optional) – The key in
adata.obsmto store the results in, defaults to “losh”layer (Optional[str], optional) – If not None, use this layer for gene features, defaults to None
- Raises:
ImportError – If
esdais not installed.- Returns:
The updated AnnData object. If inflace is False, returns a copy.
- Return type:
AnnData