dynamo.tl.moran_i

dynamo.tl.moran_i(adata, X_data=None, genes=None, layer=None, weighted=True, assumption='permutation', local_moran=False)[source]

Identify genes with strong spatial autocorrelation with Moran’s I test.

This can be used to identify genes that are potentially related to critical dynamic process. Moran’s I test is first introduced in single cell genomics analysis in (Cao, et al. 2019). Note that moran_i supports performing spatial autocorrelation analysis for any layer or normalized data in your adata object. That is you can either use the total, new, unspliced or velocity, etc. for the Moran’s I analysis.

Parameters:
  • adata (AnnData) – An AnnData object.

  • X_data (Optional[ndarray]) – The user supplied data that will be used for Moran’s I calculation directly. Defaults to None.

  • genes (Optional[List[str]]) – The list of genes that will be used to subset the data for dimension reduction and clustering. If None, all genes will be used. Defaults to None.

  • layer (Optional[str]) – The layer that will be used to retrieve data for dimension reduction and clustering. If None, .X is used. Defaults to None.

  • weighted (bool) – Whether to consider edge weights in the spatial weights graph. Defaults to True.

  • assumption (Literal['permutation', 'normality', 'randomization']) – Assumption of the Moran’s I test. Inference for Moran’s I is based on a null hypothesis of spatial randomness. The distribution of the statistic under the null can be derived using either an assumption of normality (independent normal random variates), or so-called randomization (i.e., each value is equally likely to occur at any location). An alternative to an analytical derivation is a computational approach based on permutation. This calculates a reference distribution for the statistic under the null hypothesis of spatial randomness by randomly permuting the observed values over the locations. The statistic is computed for each of these randomly reshuffled data sets, which yields a reference distribution. Defaults to “permutation”.

  • local_moran (bool) – Whether to also calculate local Moran’s I. Defaults to False.

Raises:
  • ImportError – Package pysal not installed.

  • ValueErrorX_data is provided but genes does not correspond to its columns.

Return type:

AnnData

Returns:

The updated AnnData object with a new key ‘Moran_’ + type in the .uns attribute, storing the Moran’ I test results.