voyagerpy.spatial.compute_correlogram#

voyagerpy.spatial.compute_correlogram(adata: AnnData, feature: str | Sequence[str], method: str = 'moran', graph_name: str | None = None, order: int | None = None, layer: str | None = None, force: bool = False, key_added: str = 'correlogram') DataFrame#

Compute the correlogram of a feature.

Parameters:
  • adata (AnnData) – The AnnData object storing the graph.

  • feature (Union[str, Sequence[str]]) – The feature(s) to compute the correlogram for.

  • method (str, optional) – The metric to compute at each order of neighbors, defaults to “moran”

  • graph_name (Optional[str], optional) – The name of the neighborhood graph, defaults to None. Should be a key in adata.uns["spatial"]["higher_order] or adata.uns["spatial"].

  • order (Optional[int], optional) – The order to use for computing the correlogram. If None, compute_higher_order_neighbors must have been called, defaults to None.

  • layer (Optional[str], optional) – If not None, use this layer for gene features, defaults to None

  • force (bool, optional) – Whether to recompute the correlogram for values computed in an earlier call to this function, defaults to False

  • key_added (str, optional) – The key to add to adata.uns["spatial"][method] for storing the correlogram, defaults to “correlogram”

Raises:
  • ImportError – If either libpysal or esda are not installed.

  • NotImplementedError – If method is not “moran” or “corr”.

  • RuntimeError – If order is None and compute_higher_order_neighbors has not been called.

Returns:

The dataframe containing the correlogram. It is stored in adata.uns["spatial"][method][key_added][graph_name].

Return type:

pd.DataFrame