STcompare is an R package for comparing spatial gene expression patterns across spatial transcriptomics (ST) datasets, addressing cases where traditional non-spatial differential expression methods fail to capture spatially distinct variation. jef.works/STcompare is the STcompare R documentation website.
STcompare enables differential spatial comparison tests orthogonal to traditional differential gene (DGE) analysis. With DGE methods, simulated spatially distinct gene expression patterns A and B are identified as not differentially expressed because they have the same mean gene expression. Conversely, highly spatially similar gene expression patterns A and C are differentially expressed because they have very different mean gene expression.
STcompare enables two differential spatial comparison tests:
Spatial Correlation: Person correlation assumes that each sample is independent and identically distributed random variables. However, in terms of gene expression, the gene expression of one cell influences the gene expression of the neighboring cells. Spatial Correlation computes the empirical p-value instead to consider the dependent relationship.
Spatial Fold Change: Computes a Similarity score for each gene in the comparison, compares the change in expression at matched locations.
To make comparisons, STcompare relies on matched spatial locations in the ST datasets. As such, single cell resolution ST datasets first must be first aligned using SEraster such that shared tissue structures are coincide in the same common coordinate framework and subsequently must be rasterized onto a shared pixel grid such that there is a one-to-one correspondence of units to be compared.
require(remotes)
remotes::install_github('JEFworks-Lab/STcompare')
Clifton K, Jiang V, Singh S, Matsuura R, Rabb H, Fan J., STcompare: Comparative spatial transcriptomics data analysis to characterize differentially spatially patterned genes. bioRxiv 2025.11.21.689847. doi: https://doi.org/10.1101/2025.11.21.689847