The source code for SHouT (spatial heterogeneity quantification tool), which aids the analysis of spatial cell graphs with respect to spatial heterogeneity.
SHouT provides two sample-level scores, namely (1) global homophily (edge-based), and (2) global entropy (node-based).
Additionally, SHouT provides three node- (here, cell-) level scores, namely (1) local entropy (node-based), (2) local homophily (edge-based), and (3) egophily (node-based).
For tutorial, go to https://github.com/bionetslab/SHouT/blob/main/tutorial.ipynb.
For cutaneous T-cell lymphoma (CTCL) case study, go to .
-
SHouT starts by computing sample-specific spatial neighborhood graphs
$G=(V,E,\lambda_V)$ from the pre-processed imaging data, where$V\subseteq\mathcal{C}$ is the set of cells for the sample under consideration, the set$E$ contains an edge$cc^\prime$ for two cells$c,c^\prime\in V$ if$c$ and$c^\prime$ are spatially adjacent (computed with Squidpy's \texttt{spatial_neighbors} function with the parameter \texttt{delaunay} set to \texttt{True}), and$\lambda_V$ denotes the restriction of the cell type label function$\lambda$ to$V$ . -
Subsequently, the two global scores, and three node-specific scores are calculated.
Global entropy is formally defined as:
where
Global homophily is formally defined as:
where,
NOTE: We get one global score in the range of [0, 1] per radius for the entire network.
-
In case of local heterogeneity scores, SHout accepts as input a radius
$r$ (or a set of radii). -
It then calculates local scores within the
$r$ -hop neighborhood$N_r(c)={c^\prime\in V\mid d_G(c,c^\prime\leq r}$ of an individual cell$c\in V$ . Here,$r$ is a hyper-parameter and$d_G:V\times V\to\mathbb{N}$ is the shortest path distance.
Local entropy is formally defined as:
Here, as opposed to global entropy, cell type fractions
Local homophily is formally defined as:
Here, as opposed to global homophily, we only consider the subset of edges
Egophily is defined as:
where, egophily
Install conda environment as follows (there also exists a requirements.txt)
conda create --name shout
conda activate shout
pip install scipy==1.10.1 numpy==1.23.5 squidpy==1.3.0The CTCL case study can be accessed at: https://github.com/bionetslab/ctcl_case_study
Please cite SHouT as follows:
- S. Sarkar, A. Möller, A. Hartebrodt, M. Erdmann, C. Ostalecki, A. Baur, D. B. Blumenthal (2024). Spatial cell graph analysis reveals skin tissue organization characteristic for cutaneous T cell lymphoma. NPJ Syst. Biol. Appl. 10, 143, https://doi.org/10.1038/s41540-024-00474-x.
