spateo.tools.cluster.cluster_spagcn#

Module Contents#

Functions#

spagcn_vanilla(→ Optional[anndata.AnnData])

Integrating gene expression and spatial location to identify spatial domains via SpaGCN.

spateo.tools.cluster.cluster_spagcn.spagcn_vanilla(adata: anndata.AnnData, spatial_key: str = 'spatial', key_added: str | None = 'spagcn_pred', n_pca_components: int | None = None, e_neigh: int = 10, resolution: float = 0.4, n_clusters: int | None = None, refine_shape: Literal[hexagon, square] = 'hexagon', p: float = 0.5, seed: int = 100, numIterMaxSpa: int = 2000, copy: bool = False) anndata.AnnData | None[source]#

Integrating gene expression and spatial location to identify spatial domains via SpaGCN. Original Code Repository: https://github.com/jianhuupenn/SpaGCN

Reference:

Jian Hu, Xiangjie Li, Kyle Coleman, Amelia Schroeder, Nan Ma, David J. Irwin, Edward B. Lee, Russell T. Shinohara & Mingyao Li. SpaGCN: Integrating gene expression, spatial location and histology to identify spatial domains and spatially variable genes by graph convolutional network. Nature Methods volume 18, pages1342–1351 (2021)

Parameters:
adata

An Anndata object after normalization.

spatial_key

the key in .obsm that corresponds to the spatial coordinate of each bucket.

key_added

adata.obs key under which to add the cluster labels. The initial clustering results of SpaGCN are under key_added, and the refined clustering results are under f’{key_added}_refined’.

n_pca_components

Number of principal components to compute. If n_pca_components == None, the value at the inflection point of the PCA curve is automatically calculated as n_comps.

e_neigh

Number of nearest neighbor in gene expression space. Used in dyn.pp.neighbors(adata, n_neighbors=e_neigh).

resolution

Resolution in the Louvain clustering method. Used when `n_clusters`==None.

n_clusters

Number of spatial domains wanted. If n_clusters != None, the suitable resolution in the initial Louvain clustering method will be automatically searched based on n_clusters.

refine_shape

Smooth the spatial domains with given spatial topology, “hexagon” for Visium data, “square” for ST data. Defaults to None.

p

Percentage of total expression contributed by neighborhoods.

seed

Global seed for random, torch, numpy. Defaults to 100.

numIterMaxSpa

SpaGCN maximum number of training iterations.

copy

Whether to copy adata or modify it inplace.

Returns:

Depending on the parameter copy, when True return an updates adata with the field adata.obs[key_added] and adata.obs[f'{key_added}_refined'], containing the cluster result based on SpaGCN; else inplace update the adata object.