sepal

sepal#

squidpy.gr.sepal(adata, *, max_neighs, genes=None, n_iter=30000, dt=0.001, thresh=1e-08, connectivity_key='spatial_connectivities', spatial_key='spatial', layer=None, use_raw=False, copy=False, n_jobs=None, show_progress_bar=True, table_key=None)[source]#

Identify spatially variable genes with Sepal.

Sepal is a method that simulates a diffusion process to quantify spatial structure in tissue. See [Anderson and Lundeberg, 2021] for reference.

Parameters:
adata AnnData | SpatialData

Annotated data object.

table_key str | None (default: None)

Key in spatialdata.SpatialData.tables where the table is stored. Required when adata is a spatialdata.SpatialData object and ignored otherwise.

max_neighs Literal[4, 6]

Maximum number of neighbors of a node in the graph. Valid options are:

  • 4 - for a square-grid (ST, Dbit-seq).

  • 6 - for a hexagonal-grid (Visium).

genes str | Sequence[str] | None (default: None)

List of gene names, as stored in anndata.AnnData.var_names, used to compute sepal score.

If None, it’s computed anndata.AnnData.var ['highly_variable'], if present. Otherwise, it’s computed for all genes.

n_iter int | None (default: 30000)

Maximum number of iterations for the diffusion simulation. If n_iter iterations are reached, the simulation will terminate even though convergence has not been achieved.

dt float (default: 0.001)

Time step in diffusion simulation.

thresh float (default: 1e-08)

Entropy threshold for convergence of diffusion simulation.

connectivity_key str (default: 'spatial_connectivities')

Key in anndata.AnnData.obsp where spatial connectivities are stored. Default is: anndata.AnnData.obsp ['spatial_connectivities'].

spatial_key str (default: 'spatial')

Key in anndata.AnnData.obsm where spatial coordinates are stored.

layer str | None (default: None)

Layer in anndata.AnnData.layers to use. If None, use anndata.AnnData.X.

use_raw bool (default: False)

Whether to access anndata.AnnData.raw.

copy bool (default: False)

If True, return the result, otherwise save it to the adata object.

n_jobs int | None (default: None)

Number of parallel threads to use. None and -1 use numba’s default thread count (NUMBA_NUM_THREADS); asking for more threads than that warns and falls back to it, while 0 and values below -1 raise, since scanpy only supports n_jobs >= -1.

show_progress_bar bool (default: True)

Whether to show the progress bar or not.

Returns:

DataFrame | None – If copy = True, returns a pandas.DataFrame with the sepal scores.

Otherwise, modifies the adata with the following key:

Notes

If some genes in anndata.AnnData.uns ['sepal_score'] are NaN, consider re-running the function with increased n_iter.