troutpy.tl.spatial_variability

troutpy.tl.spatial_variability#

troutpy.tl.spatial_variability(sdata, coord_keys=None, gene_key='gene', n_neighbors=10, kde_resolution=1000, square_size=20, n_threads=1, method='moran', copy=False)#

Computes spatial variability of extracellular RNA using Moran’s I.

Parameters:
  • sdata (SpatialData) – The spatial transcriptomics dataset in SpatialData format.

  • coord_keys (Optional[list] (default: None)) – The keys for spatial coordinates in the dataset (default: [‘x’, ‘y’]).

  • gene_key (str (default: 'gene')) – The key for gene identifiers in the dataset (default: ‘gene’).

  • n_neighbors (int (default: 10)) – Number of neighbors to use for computing spatial neighbors (default: 10).

  • kde_resolution (int (default: 1000)) – The kde_resolution for kernel density estimation (default: 1000).

  • square_size (int (default: 20)) – The square_size for kernel density estimation (default: 20).

  • n_threads (int (default: 1)) – The number of threads for LazyKDE processing (default: 1).

  • method (str (default: 'moran')) – The mode for spatial autocorrelation computation (default: “moran”).

Returns:

sdata: spatialdata.SpatialData Sdata containing Moran’s I values for each gene, indexed by gene names.