opendvp.tl.spatial_autocorrelation#
- opendvp.tl.spatial_autocorrelation(adata, method='moran', x_y=('x_centroid', 'y_centroid'), k=8, threshold=10.0, island_threshold=0.1)#
Compute spatial autocorrelation statistics (Moran’s I or Geary’s C) for each gene in an AnnData object.
- Return type:
Parameters#
- adataAnnData
Annotated data matrix where observations are cells and variables are genes.
- method{‘moran’, ‘geary’}, default ‘moran’
Spatial statistic to compute: ‘moran’ or ‘geary’.
- x_ySequence[str], default (“x_centroid”, “y_centroid”)
Names of columns in
adata.obs
containing spatial coordinates.- kint, default 8
Number of neighbors for Moran’s I (ignored for Geary’s C).
- thresholdint or float, default 10.0
Distance threshold for neighbors for Geary’s C (ignored for Moran’s I).
- island_thresholdfloat, default 0.1 (10%)
If more than this fraction of samples are islands (no neighbors), raises error.
Returns:#
- None
Results are added to adata.var in-place.
Raises:#
- ValueError
If method is not ‘moran’ or ‘geary’.
- RuntimeError
If too many islands are detected in Geary’s C mode.