sinfonia.statistics.spatially_variable_genes

sinfonia.statistics.spatially_variable_genes(adata, mode='moran_geary', n_top_genes=2000, subset=False, inplace=True, coordinate_key='spatial', n_neighbors=30, layer=None, seed=None)

Identify spatially variable genes by SINFONIA.

Mode

    1. moran_geary identify spatially variable genes based on Moran’s I and rescaled Geary’s C scores.

    1. moran identify spatially variable genes based on Moran’s I scores.

    1. geary identify spatially variable genes based on rescaled Geary’s C scores.

param adata

AnnData object of shape n_obs × n_vars. Rows correspond to cells and columns to genes.

param mode

Mode for identifying spatially variable genes. By default, mode=’moran_geary’.

param n_top_genes

Number of spatially variable genes to keep. By default, n_top_genes=2000.

param subset

Inplace subset to spatially variable genes if True otherwise merely indicate spatially variable genes. By default, subset=False.

param inplace

Whether to place calculated metrics in .var. By default, inplace=True.

param coordinate_key

Key in adata.obsm where spatial coordinates are stored. By default, coordinate_key=’spatial’.

param n_neighbors

Number of nearest neighbors used to construct the spatial neighbor graph. By default, n_neighbors=30.

param layer

If provided, use adata.layers[layer] for expression values instead of adata.X. Note that SINFONIA expects logarithmized data. By default, layer=None.

param seed

Random seed for reproducibility. By default, seed=None.

returns

AnnData object with identified spatially variable genes and additional fields:

  • adata.var[‘spatially_variable’] - boolean indicator of spatially variable genes.

  • adata.uns[‘svg’] - mode used to identify spatially variable genes if inplace=True.

  • adata.var[‘moranI’] - Moran’s I scores if inplace=True and mode=’moran_geary’ or mode=’moran’.

  • adata.var[‘gearyC’] - rescaled Geary’s C scores if inplace=True and mode=’moran_geary’ or mode=’geary’.

rtype

adata