Abstract
Spatial transcriptomics produces high-dimensional gene expression measurements with spatial context. Obtaining a biologically meaningful low-dimensional representation of such data is crucial for effective interpretation and downstream analysis. Here, we present Spatial Transcriptomics Analysis with topic Modeling to uncover spatial Patterns (STAMP), an interpretable spatially aware dimension reduction method built on a deep generative model that returns biologically relevant, low-dimensional spatial topics and associated gene modules. STAMP can analyze data ranging from a single section to multiple sections and from different technologies to time-series data, returning topics matching known biological domains and associated gene modules containing established markers highly ranked within. In a lung cancer sample, STAMP delineated cell states with supporting markers at a higher resolution than the original annotation and uncovered cancer-associated fibroblasts concentrated on the tumor edge’s exterior. In time-series data of mouse embryonic development, STAMP disentangled the erythro-myeloid hematopoiesis and hepatocytes developmental trajectories within the liver. STAMP is highly scalable and can handle more than 500,000 cells.
Similar content being viewed by others
Main
Spatial transcriptomics is an essential experimental technique for exploring tissue architecture as it captures gene expression profiles while retaining their spatial context1. Consequently, spatially aware analyses are required to incorporate gene expression and spatial information to fully exploit such data. In commonly employed workflows, dimension reduction forms the initial processing step, which is particularly important as its accuracy in capturing the relevant data variability impacts data visualization and downstream analyses such as clustering to identify biologically relevant spatial domains or cell types. Thereafter, differential expression analysis typically follows to enable annotation. Alternatively, interpretable dimension reduction is an attractive option that exploits the computed contribution of each gene to the low-dimensional embeddings. By visualizing such embeddings on the spatial coordinates and examining the contributing input genes, one can decipher anatomical regions or cell types without clustering and differential expression analysis. This also gives greater confidence in the biological relevance of the reduced dimensions compared to black-box modeling approaches.
Classical dimensional reduction methods such as principal-component analysis (PCA), non-negative matrix factorization (NMF)2 and latent Dirichlet allocation (LDA)3 are often used in single-cell analysis4,5,6. They return interpretable embeddings but may lack expressivity and do not incorporate spatial information. Alternatively, autoencoder (AE) approaches such as linearly decoded variational autoencoder (LDVAE)7 combine nonlinear encoders with linear decoders to balance expressive power and interpretability, but also do not incorporate spatial information. Spatial transcriptomics specific methods like SpaGCN8, BASS9, BayesSpace10 and GraphST11 conversely employ sophisticated models such as graph neural networks or the Potts model to incorporate spatial information. These methods offer flexibility and can jointly analyze omics data with spatial information; however, the embeddings returned by these methods are usually interpreted post hoc, with clustering and differential expression analysis. Current interpretable methods that incorporate spatial information into dimension reduction employ Gaussian processes or hidden Markov random fields, as exemplified by methods like MEFISTO12, non-negative spatial factorization hybrid (NSFH)13 and spatial identification of cells using matrix factorization (SpiceMix)14. They provide spatially aware interpretable dimensional reduction but are computationally costly.
Here, we present STAMP for interpretable spatially aware dimension reduction. STAMP builds upon the deep generative model prodLDA15, which ensures scalability through auto-encoding and black-box variational inference16,17. STAMP uses a simplified graph convolution network18,19 as an inference network, allowing spatial information to be incorporated at a small increase in computational cost. STAMP outputs a latent representation consisting of spatially organized topics with associated gene modules containing genes ranked by their contribution to the topic. This explicitly links the importance of each gene to a topic, contributing to interpretability. If desired, further analysis such as gene set enrichment or pathway analysis can assign further biological meanings to each topic. STAMP computes a topic proportion score for each cell and each topic, with the proportions summing to 1 within each cell. For cells with a dominant topic, the interpretation associated with that dominant topic can also be assigned. We also introduce structured sparsity-inducing priors20,21 on the gene modules learned such that the modules are both sparse across topics and within topics. We tested STAMP on several datasets and showed that the learned topics correspond to known anatomical structures in tissues. This obviates the need for an additional clustering step. Furthermore, the relevant marker genes were highly ranked in the accompanying gene modules, highlighting STAMP’s interpretability and offering an alternative to differential expression analysis.
We benchmarked STAMP against other dimension reduction methods that output non-negative latent embeddings and their corresponding gene modules, and showed that STAMP performed favorably in identifying biologically relevant domains and their gene modules. In addition, STAMP also outperformed other methods in terms of scalability. Finally, STAMP is the first topic modeling method that can capture shared topics across time-series spatial transcriptomic data. With a mouse embryonic development dataset, STAMP revealed spatiotemporally linked topics and their associated gene modules. These topics matched known biological structures and the associated gene modules tracked changes in the contributing genes across time.
Results
Workflow of STAMP
STAMP combines topic modeling with deep generative models, thus inheriting the benefits of interpretability and scalability. It takes in gene expression values with their spatial context and outputs explainable latent topics with associated gene modules (Fig. 1a,b). Each associated gene has a gene module score that denotes its contribution to the topic. In its most basic form that handles a single sample, STAMP models the observed expression xng of gene g in cell n as a sample drawn from a Gamma Poisson distribution determined by a combination of the latent topic znk (the proportion of topic k in cell n), gene module wkg (the contribution of gene g to topic k), background residual rg and dispersion αg. To promote structured sparsity in the gene modules wkg, we utilize a structured regularized horseshoe prior22,23. This prior ensures that each gene is involved in only a subset of topics and each topic involves only a limited number of genes in the associated gene module, which facilitates biological interpretation of the modules and provides robustness to these modules (a detailed description of the prior is given in the Methods section). For handling multiple samples, we add a batch correction term, wbatch, to capture batch related variations present in the data. Lastly, we expand STAMP to handle time-series data, allowing the gene modules to vary across different time points by imposing a Gaussian process prior with a Matern kernel. To incorporate spatial information into the model, we use a simplified graph convolutional network (SGCN) as our inference network that takes in gene expression and an adjacency matrix built from the spatial locations (Fig. 1a). The whole model is trained end to end with black-box variational inference by maximizing the evidence lower bound (ELBO). A detailed description of the model can be found in the Methods and Supplementary Note 1.
a, STAMP workflow. STAMP takes in the gene expression values and a neighborhood graph built from the spot locations. STAMP covers three different analysis scenarios, single sample, multi-sample and time-series modules. STAMP uses black-box variational inference and simplified graph convolutions network (SGCN) to find the variational parameters. b, Capabilities of STAMP. The gene module scores wkg and topic proportions znk are outputs of STAMP. These outputs can be used for downstream analysis such as horizontal, vertical integration and time-series analysis.
We first validated STAMP’s ability to recover different layers of patterns using a simulated dataset. Following the approach of Townes et al.13, we generated data with five overlapping patterns (Extended Data Fig. 1a), where each spot could be associated with multiple patterns. STAMP was able to cleanly recover the five patterns (Extended Data Fig. 1a,b). We also evaluated other methods, including Leiden24 clustering, spatially aware dimension reduction with STAGATE25, GraphST11 and SpatialPCA26, followed by k-means clustering. None of these clustering-based analyses was able to correctly recover all the patterns (Extended Data Fig. 1c). This demonstrates the advantage of STAMP’s topic-modeling approach over clustering algorithms in deconvoluting spatially overlapping patterns. Unlike traditional clustering, which assigns each spot to a single cluster, topic modeling provides a probabilistic topic composition for each spot, allowing for multiple identities (topics) to be represented. Additionally, we tested cluster-free methods, namely LDA, LDVAE, NMF, NSFH and SpiceMix. While these methods outperformed clustering approaches, they were less effective than STAMP (Supplementary Note 2).
STAMP reveals spatial domains of mouse hippocampus
Next, we demonstrated STAMP’s ability to identify biologically relevant topics and gene modules of known tissue structures. We applied STAMP to a mouse hippocampus dataset of 39,220 spots generated using Slide-seq V2 (ref. 27). Using the Allen Brain Atlas as the ground truth for anatomical regions11,28 (Fig. 2a), we compared the performance of STAMP and five other methods, NMF2, LDA3, LDVAE7 and two recent methods developed for spatial transcriptomics, NSFH13 and SpiceMix14. All these methods output non-negative latent embeddings and their corresponding gene modules.
a, Allen Mouse Brain Atlas reference with the hippocampus region annotated. b, Boxplots of module coherence and module diversity scores of STAMP and the five competing methods obtained over five different runs with different seeds. In the box plot, the center line denotes the median, box limits denote the upper and lower quartiles and whiskers denote 1.5 × interquartile range. c, Selected spatial topics related to the hippocampus as captured by the methods. Topics were binarized for ease of visualization. d, Gene module rankings (number) and scores (color) of known gene markers for the different hippocampus regions. e, Visualization of the spatial topics identified by STAMP and expression levels of the corresponding highest-ranking genes from each gene module.
We first quantitated the performance of STAMP and competing methods in terms of the topic associated gene modules (Fig. 2b). We employed two commonly used metrics in topic modeling literature, module coherence29 and module diversity30. Module coherence measures the degree of coexpression among the top-ranking genes within a module, whereas module diversity measures the uniqueness of a gene module. STAMP scored the highest in both metrics with a median module coherence of 0.162 and module diversity of 0.9. All other methods scored much poorer in the coherence metric with NMF being second (0.127). For diversity, LDVAE scored second (0.87) while being much poorer at module coherence (0.11). LDA was the weakest performer, scoring last in both module coherence (0.1) and diversity (0.44).
Visual examination of STAMP’s output showed well-defined spatial topics that corresponded to seven key anatomical regions of the hippocampus proper, namely Cornu Ammonis 1 (CA1), CA2, CA3, dentate gyrus (DG), third ventricle (V3), medial habenula (MH) and lateral habenula (LH) (Fig. 2c and Extended Data Fig. 2). In contrast, no other method was able to separate the CA2 and CA3 regions, nor correctly capture the LH region. LDA, NMF and NSFH correctly captured CA1, DG, V3 and MH, but failed to capture the LH and separate CA2 and CA3. LDVAE captured CA1 and DG, but not LH and merged CA2 with CA3, as well as V3 with MH. SpiceMix performed the poorest, failing to capture any anatomical regions (Extended Data Fig. 2 and Supplementary Figs. 1–6). We further investigated the respective gene modules by examining the rankings of published gene markers of the anatomical regions (Fig. 2d). For all regions except CA3, at least one marker was found within the top ten (Wfs1 and Pou3f1 in CA1, Rgs14 in CA2, C1ql2 and Prox1 in DG31,32, Enpp2, Igf2 and Ttr in V3, Tac2 and Gpr151 in MH and Cbln1 and Cbln2 in LH33,34). These well-established marker genes for their respective anatomical regions provide evidence that STAMP can generate biologically meaningful topics and gene modules. We then visualized the spatial distributions of STAMP’s topic proportions and expressions of the top gene from the respective module, affirming that the topic proportions and gene expression levels are congruent (Fig. 2e).
STAMP uncovers a topic of cancer-associated fibroblasts
We next assessed STAMP’s ability to uncover cell states and associated gene modules using one sample from a human non-small cell lung cancer (NSCLC) dataset acquired with CosMx SMI35. The selected Lung #5-3 sample is composed of 93,206 spots capturing 960 genes (Fig. 3a). Here we set STAMP to return 15 topics and their gene modules. The gene modules were analyzed with DISCO’s scEnrichment36 tool to annotate the topics present (Supplementary Table 1). We found the topic annotations to agree well with the manually annotated cell types in the original study, confirming the accuracy of the topics and their gene modules in capturing cellular states (Extended Data Fig. 3a,b). We next plotted the gene module rankings of known cell type markers36,37 to verify the gene modules’ biological relevance (Fig. 3b). Most cell type markers to be highly ranked within their respective gene modules with at least one marker in the top 10 (except for tumor edge) and most within the top 20, confirming the gene modules’ biological relevance. We also visualized the spatial expression of the top genes per topic and aggregated expression of the top 20 genes. These genes showed high spatial coexpression patterns and accurately correlated with their respective topics, highlighting the coherence between the gene modules and their topics (Supplementary Fig. 7).
a, NSCLC sample data acquired using CosMx Spatial Molecular Imager (SMI) with the original cell type annotation. b, Gene module rankings (number) and scores (color) of marker genes for each topic. c, Spatial plots of topics annotated using their gene modules. d, Spatial co-occurrence of different cell types with respect to CAFs (Topic 13) as computed using Squidpy. CAFs are the closest to the tumor edge (Topic 9). e, Canonical pathway enrichment analysis obtained from ingenuity pathway analysis (IPA) of CAFs against the other fibroblast populations. Spot color reflects the IPA z-score enrichment of CAFs versus fibroblasts, with red indicating predicted pathway activation and blue indicating pathway repression. The x axis shows the level of significance via −log10 (adj. P). Adj. P values were calculated with the Fisher’s exact test (right tailed) followed by the Benjamini–Hochberg adjustment. NK, natural killer; cDC, conventional dendritic cell; mDC, myeloid dendritic cell; pDC, plasmacytoid dendritic cell.
STAMP’s topics also achieved cell type annotation at a higher resolution than the original study (STAMP in Fig. 3c, original in Extended Data Fig. 3a, comparison in Extended Data Fig. 3b). For example, STAMP segregated the tumor into three domains, tumor (Topic 15), tumor interior (Topic 8) and tumor edge (Topic 9), supported by marker genes. The fibroblasts were also resolved at a higher resolution into two topics of fibroblasts and one of cancer-associated fibroblasts (CAFs). The two fibroblast topics possessed different signatures with higher expression of collagen genes such as COL3A1 and COL1A1 in the Topic 6 fibroblasts and proteoglycan genes such as DCN, MMP2 and LUM in the Topic 11 fibroblasts, representing different fibroblast subsets (Extended Data Fig. 3c). Collagen proteins make up the bulk of the extracellular matrix (ECM) of connective tissues by forming bundles of fibers that make up the main tissue structure, whereas proteoglycans are soluble glycoproteins that form large complexes with collagen fibers. We also annotated the CAFs (Topic 13) based on reported CAF signature genes including PDGFRB, ACTA2, MYH11, IGFBP5 and IGFBP3 (refs. 38,39,40) (Supplementary Table 1 and Fig. 3b). We found the CAF topic to be concentrated on the exterior of the tumor edge, matching reports of CAFs forming a barrier separating tumor tissues from other stroma regions41. We therefore quantitated the spatial relationships between the topics by computing their co-occurrence probabilities using Squidpy42. The computed co-occurrence probability with respect to the CAF topic showed that it has the highest co-occurrence with the tumor edge, thus further strengthening our assigned annotation (Fig. 3d).
As CAFs exert an important influence on the tumor microenvironment to promote inflammation and tumor progression, we were interested in the contributing molecular pathways. We thus characterized the CAF topic by computing its differentially expressed genes with respect to the other fibroblasts (Topics 6 and 11), followed by pathway analysis (Fig. 3e). The analysis revealed upregulated cytokine signaling which can be attributed to inflammatory molecules secreted within the tumor tissue43. Fibrosis pathways were also upregulated, suggesting a potential overlap in molecular mechanisms between the CAFs and the development of pulmonary fibrosis pathways44,45. Finally, the wound-healing pathway was also upregulated, which has been reported to contribute to the formation of stroma tissue during epithelial tumor development and is involved in protumor crosstalk with tumor cells46,47.
STAMP stitches mouse anterior and posterior brain sections
Due to acquisition technology limitations, separate experiments are needed to capture larger areas of tissue from the same section. To analyze such multi-sample data, we incorporated an additional latent variable into the model to create STAMP with a batch correction capability (Fig. 1a). We first demonstrated STAMP’s ability to discover common topics across different samples using two 10x Genomics Visium datasets of mouse brain sagittal sections48,49, divided into posterior and anterior (Fig. 4a). Here we benchmarked STAMP against NMF, LDA, LDVAE, NSFH and SpiceMix, evaluating them by metrics and visual inspection. We first quantified their performance in terms of gene module coherence and diversity (Fig. 4b). STAMP exhibited top performance in both module diversity and module coherence. LDVAE was second in both metrics. Like the mouse hippocampus example, LDA attained the worst performance in both metrics. Using the Allen Brain Atlas11,28 as references (Fig. 4c), we visually compared the outputs of STAMP and competing methods (Fig. 4d and Supplementary Figs. 8–13). Overall, all methods were able to discover topics that were aligned between two sections but not all matched the reference well. STAMP was able to cleanly capture the cerebral cortex layers, the internal structures of the hippocampus (CA and DG) and cerebellum and separated the caudoputamen (CP) and nucleus accumbens (ACB). Among the competing methods, only LDA and NMF were able to separate some of the upper cortex layers, while only NMF and NSFH captured the CA and DG in the hippocampus and separated the CP and ACB. Conversely, the cerebellum’s structure was captured by all methods except LDA.
a, Hematoxylin and eosin (H&E) image of the mouse brain anterior and posterior sections. b, Boxplots of module coherence and module diversity scores of STAMP and five competing methods obtained over five different runs with different seeds. In the box plot, the center line denotes the median, box limits denote the upper and lower quartiles and whiskers denote 1.5 × interquartile range. c, Annotated mouse brain sagittal section image from the Allen Mouse Brain Atlas. d, Spatial topics returned by STAMP and the five competing methods. Each topic was binarized for ease of visualization in a single figure. e, Layers of the cerebral cortex specifically identified by STAMP. f, Gene module rankings (number) and scores (color) of known gene markers in different layers of the brain.
We further investigated STAMP’s topics and their associated gene modules, focusing on the cortex layers and hippocampus (Fig. 4e). STAMP was able to identify topics shared by the two brain sections and aligned them well. To verify that the layers were correctly captured, we checked the rankings of reported markers50,51,52 in their respective gene modules (Fig. 4f). We found most markers to rank within the top 20 and three layers had one marker ranked within the top 5. This affirmed the ability of STAMP’s model in capturing topics and gene modules that are biologically meaningful.
STAMP identifies shared topics across different technologies
Here we showcased STAMP’s ability to recover topics and gene modules from multiple datasets acquired with different technologies. Here we used three mouse olfactory bulb (Fig. 5a) datasets each acquired with a different technology, Slide-seq V2, Stereo-seq and 10x Genomics Visium, for a total of 148,087 cells. From the Uniform Manifold Approximation and Projection (UMAP) visualization generated with PCA, a substantial batch effect is present in the original data (Fig. 5b). We benchmarked STAMP alongside LDA, LDVAE, NMF, NSFH and SpiceMix to assess data integration performance. We added three more algorithms, DeepST53, PRECAST and STAligner54, which provide uninterpretable embeddings but are able to correct for batch effects in spatial data. The methods SpiceMix, DeepST and STAligner were unable to produce results on these datasets due to memory constraints.
a, Annotated 4,6-diamidino-2-phenylindole (DAPI) stained image illustrating the mouse olfactory bulb’s laminar organization. b, UMAPs computed using the latent space/topics returned by every method. The UMAPs are colored by their respective technology. c, Table displaying the scIB metrics computed for each method. A score of 1 indicates optimal performance. d, Gene module rankings (number) and scores (color) of marker genes returned by STAMP for each topic. e, Identified topics of different olfactory layers in the 10x Genomics Visium, Stereo-seq and Slide-seq V2 data. f, Dataset of 12 DLPFC slices with the original annotation. g, Table displaying the scIB metrics and aggregate scores computed for each method. A score of 1 indicates optimal performance.
We fitted 12 topics to the data with all methods and visualized their output with UMAP. In STAMP’s output, the three datasets were highly mixed (Fig. 5b). Some mixing could be observed for LDVAE and PRECAST but substantial batch-specific clusters were still visible. For LDA, NMF and NSFH, the datasets remained separated in a batch-specific manner as they are not explicitly designed to handle batch effects. We further quantified the data integration with scIB55 metrics (silhouette score, iLISI, kBET, graph connectivity and PCR comparison) and the aggregate results (Fig. 5c) broadly matched the UMAP plots. STAMP obtained the best aggregate score while LDVAE was second, followed by PRECAST, NMF, LDA and NSFH ranked at the bottom with aggregate scores comparable to the PCA output, implying poor data integration.
Examining the associated gene modules of STAMP’s topics, we found genes associated with the known layers of the mouse olfactory bulb, enabling manual annotation (Fig. 5d and Supplementary Fig. 14). We were able to identify the rostral migratory stream (RMS), granule cell layer (GCL), inner plexiform layer (IPL), mitral cell layer (MCL), external plexiform layer, glomerular layer (GL) and olfactory nerve layer (ONL). Many of the reported markers were highly ranked within their modules, namely Mbp56 (ranked first in RMS), Nrgn57 and Penk58 (ranked first and second, respectively in GCL), Pcp4 and Gad1 (ranked first and third respectively in IPL), Shisa3 and Doc2g59 (ranked second and eighth respectively in MCL), Calb2 (ref. 60) (ranked second in GL) and Kctd12 (ref. 56) (ranked seventh in ONL). Of note, the GCL and IPL shared many upregulated genes such as Pcp4 and Penk. We also visualized the topics’ spatial distribution in the three datasets (Fig. 5e) and found them to be correctly organized according to the olfactory bulb’s structure (Fig. 5a)61. This clearly demonstrated STAMP’s ability to identify shared topics across data acquired with different technologies and correct for substantial batch effects.
We next ran STAMP on a collection of 12 dorsolateral prefrontal cortex (DLPFC) slices62 acquired with 10x Genomics Visium (Fig. 5f). The original data was annotated to indicate the cortex layers and white matter. The availability of this ground truth annotation enabled us to test the conservation of biological characteristics (bioconservation) while minimizing batch effects (batch correction) with a comparatively large number of batches. Here we fitted ten topics with STAMP and competing methods. Visualizing the integrated outputs with UMAP, all methods except for PRECAST were able to maintain separation between the cortex layers and white matter (Extended Data Fig. 4a). All the methods mixed the batches to various degrees, but batch-specific regions are highly visible in the DeepST and PRECAST outputs (Extended Data Fig. 4b). For quantitative assessment, we employed five metrics for bioconservation (isolated labels, k-means-based NMI, k-means-based ARI, silhouette score for annotation labels and cLISI) and five for batch correction (silhouette score for batch, iLISI, kBET, graph connectivity and PCR comparison) from the scIB metrics. In the aggregate scoring, STAMP was top for both bioconservation and batch correction (Fig. 5g). For bioconservation, STAMP was top for all metrics except for cLISI where it trailed DeepST with only a small deficit (0.96 versus 0.97). STAMP was also able to capture the clear layered patterns with its topics (Supplementary Fig. 19).
STAMP unveils spatiotemporal topics in embryo development
Last, we demonstrated STAMP’s ability to discover spatiotemporally linked topics and associated gene modules from time-series spatial transcriptomic data. We analyzed Stereo-seq data of mouse embryo samples at eight time points from E9.5 to E16.5 for an overall dataset size of more than 540,000 cells63 (Fig. 6a). To account for dynamic changes in gene expression, the gene modules were allowed to vary across time points with a Gaussian process. This dynamic formulation allows STAMP to capture connected topics across time. We fitted 40 topics that captured matching tissues across different time points, illustrating their developmental trajectories (Extended Data Fig. 5a). The binarized topics (Extended Data Fig. 5b) resolved biological details that matched or exceeded the dataset’s original clustering and annotation (Fig. 6a). It is worth noting that the spatial smoothness of STAMP’s topics can be controlled by adjusting the number of layers in the SGCN, where a higher number of layers results in smoother topics. We demonstrated this with the results obtained from the embryo section at E11.5 with different numbers of SGCN layers and used Moran’s I index to quantitatively demonstrate the changes in spatial smoothness of the topics (Extended Data Fig. 6a,b).
a, Stereo-seq data series of mouse embryo development from E9.5 to E16.5 with the original annotation. b, STAMP identified spatial temporal patterns such as the skeleton, heart, skin, jaw, choroid plexus, dorsal forebrain, lung and meninges. All the fitted topics can be found in Extended Data Fig. 5. c, Comparison of the original annotation (left) and STAMP’s output (Topic 2). STAMP merged the dermomyotome and muscle regions into a single topic. The spatial gene expression of NEB (identified from the associated gene module) supports the merger. d, UMAP and PCA plots of STAMP’s output revealed continuous trajectories of spatially connected gene modules. e, Hepatocyte and hematopoiesis topics identified by STAMP. f, GSEA normalized enrichment scores computed with the hepatocyte and hematopoiesis topics’ gene modules. Top 15 pathways ordered by the normalized enrichment score were selected and shown. g, Gene module scores of selected markers in the hepatocyte and hematopoiesis topics. AGM, aorta-gonad-mesonephros; GI, gastrointestinal.
Tissues identified with STAMP’s topics include major organs such as the skeleton, liver, heart, skin, jaw and lung. Within the cranial region, STAMP resolved tissues like the choroid plexus and forebrain (Fig. 6b). Examining the individual topics, we could also observe the correspondence of topics across time, tracking tissue development trajectories (Fig. 6b). One example was the heart (Topic 9) that grew in size and our results for E11.5 suggested the formation of heart chambers64. Another example is the skin (Topic 21) that started to develop at E9.5 and by E13.5 (ref. 65) we could see a discernible structure enveloping the embryo. For the meninges (Topic 15), it maintained a consistent structural form throughout development. Moreover, STAMP can map the developmental continuum, linking distinct early and late forms that are typically identified as unrelated clusters by conventional clustering analysis. For example, STAMP captured continuous muscle development from dermomyotome to a full-grown muscle in a single topic (Topic 2), whereas the original annotation shows it as two different clusters (Fig. 6c). Notably, the associated gene module contained Neb, which is an important skeletal muscle development marker, and its expression had the same spatial distribution as the topic, thus supporting the merging.
The associated gene modules also reflected both the similarities within each topic between time points and the gradual changes across time. In the UMAP visualization, gene modules of the same topic clustered close together (Fig. 6d, left). With PCA, gene modules of the same topic also clustered together. Notably, the principal components also captured the progressive changes of many topics across time (Fig. 6d, right). These ordered and gradual changes highlighted STAMP’s ability to model them with the gene modules. They also illustrated the development programs that were shared between tissues and that the gene modules could be further exploited for further biological insights.
To show the biological information captured by the connected gene modules, we focused on two important topics, hematopoiesis (Topic 12) and hepatocyte (Topic 23), which are colocalized in the developing liver (Fig. 6e). During embryonic development, hematopoiesis occurs at the yolk sac during early development before shifting to the liver from seeded hematopoietic stem cells. By E12.5, the liver is the main site of hematopoiesis before a gradual shift to the nearby spleen by E15.5 (ref. 66). Further migration to the bone marrow then begins after E16.5. Consequently, both the hematopoiesis and hepatocyte topics almost entirely overlap spatially from E12.5; however, their gene modules clearly separate them. Using gene set enrichment analysis (GSEA), the hepatocyte topic’s gene module showed strong enrichment of lipid processing and other metabolic processes, while gene sets related to hematopoietic process, especially erythrocyte and hemoglobin related metabolic processes, were highly represented for the hematopoiesis topic (Fig. 6f). We further confirmed that the markers of erythrocytes and hepatocytes have high gene module scores (ranked within top 100) within the hematopoiesis67 and hepatocyte topics68,69, respectively (Fig. 6g).
Discussion
In this work, we developed STAMP, a deep probabilistic approach for identifying topics and relevant gene modules in spatial transcriptomics data. To incorporate spatial information, we feed an adjacency matrix built from the spatial locations to STAMP that encodes the spatial adjacency using an SGCN. STAMP also employs a regularized horseshoe prior on the gene modules to encourage structured sparsity, which leads to more robust and interpretable estimates. We tested STAMP on several datasets, achieving favorable performance in terms of both module coherence and diversity when compared to other competing methods such as NMF, LDA, LDVAE, NSFH and SpiceMix. In the mouse hippocampus dataset, STAMP identified distinct gene modules associated with different anatomical regions within the hippocampus, capturing the molecular heterogeneity underlying this brain region’s functional diversity. With the human lung cancer dataset, STAMP captured the spatially organized gene expression patterns that corresponded to specific tumor regions and cell types. This enabled annotation at a higher resolution than the original study, segregating the tumor into different regions such as tumor edge and tumor interior, as well as resolving additional fibroblast subsets such as CAFs.
We also extended STAMP to integrate multiple datasets and even time-series data. We performed integrative analyses of two mouse brain sagittal sections (anterior and posterior), capturing biologically accurate topics that were also aligned along the shared edge between both sections. STAMP also demonstrated the capability to integrate data acquired from different technologies and batches with data of mouse olfactory bulb sections, as well as human DLPFC sections.
Most notably, we employed STAMP to model spatiotemporally linked topics in a series of developing mouse embryo sections at eight time points. STAMP unveiled intricate anatomical structures at a higher resolution compared to the original study’s annotations. By analyzing the associated gene modules in terms of highly ranked genes and enriched pathways, we annotated the higher resolution topics and revealed their biological significance. For example, STAMP accurately captured the liver and hematopoiesis topics with relevant genes highly ranked within their associated gene modules. Notably, the hematopoiesis and liver topics coincided spatially during the time at which the embryonic liver was the main site of hematopoiesis. These results highlight the power of spatial transcriptomics and the utility of STAMP in deciphering complex biological systems.
We also note some of STAMP’s limitations and areas for future development. In its current form, STAMP is unable to facilitate comparative analysis between different conditions such as normal versus cancer or mutant versus wild type. Such analyses are important in health and disease-related studies to capture and dissect the detailed phenotypic differences and potentially lead to mechanistic explanations. Therefore, a future development is to modify STAMP to recover topics that are different across conditions. Additionally, a further development is the optional inclusion of previous knowledge as input, such as gene sets or pathways, cell type or niche information, which may be partially available for the tissue of interest. This can help guide the construction of gene modules with prior biological knowledge and potentially achieve better accuracy and biological relevance. Last, another avenue of further development is to extend STAMP to handle spatial multi-omics data70 or image data, including the mosaic data scenario, where not all datasets have the same data modalities available. The inclusion of additional data modalities increases the information content capture, including orthogonal information, thereby increasing the overall accuracy.
We designed STAMP to be user friendly and capable of processing data from different experimental platforms. STAMP can scale to very large datasets with hundreds of thousands of cells with the largest dataset tested having more than 500,000 cells, ensuring its relevance as the size of datasets grows (Extended Data Fig. 7). All analyses were conducted on a server equipped with an Intel Core i7-8665U CPU and an NVIDIA Titan V GPU with 12 GB of memory.
Methods
STAMP model
Section 1 model composition
STAMP is a Bayesian model that decomposes the expression xng of gene g in cell n into topic proportion znk (the proportion of the k-th topic in cell n) and gene embedding βkg of gene g in the k-th topic. We model the gene expression xng as a sample drawn from a Gamma Poisson distribution, where μng is the mean expression of gene g in cell n and αg is the gene-specific dispersion term.
Mean term μ ng
We model the mean term μng as a summation over k topics of the multiplication between the library size ln, the topic proportion znk and the gene embedding βkg
where k labels the k-th topic.
Library size l n
We model the library size as the observed total gene counts for each cell:
Topic proportion z nk
We model the topic proportion as a logistic-normal prior that we softmax over the topic dimension to ensure that the topic proportion per cell sums to 1. We model the covariances across topics in the form of UUT + σI decomposition, where I refers to the identity matrix. The rank of the covariance matrix (dimensionality of uk) is a hyperparameter that we set equal to the number of topics.
Gene embedding β kg
Scenario 1: single sample
We model the gene embedding βkg as the sum of the background residual term rg and the gene module score wkg. The residual term rg captures the gene module shared across all topics, downweighing genes that are highly expressed across all topics. We model it as a normal prior centered around the log of the observed log-normalized mean \({\bar{x}}_{g}\), with a small \(\epsilon\) set to 1 × 10−8 to ensure positivity. The gene module score wkg is modeled with a structured horseshoe prior that introduces shrinkage to the gene module by selectively loading genes onto the topic only if they have sufficient information to overcome the prior, thereby giving rise to more robust gene modules.
Each level of the structured horseshoe prior hierarchy contributes to the structured sparsity. Specifically, δg controls the gene-wise sparsity. When δg approaches 0, the prior on wkg approaches a spike at zero for gene g, deeming the gene irrelevant for all topics. The same principle applies to τk, which encourages topic-wise shrinkage. λkg controls element-wise shrinkage, allowing each gene module to turn off specific genes that are irrelevant to its associated topic. When \({c}^{2}\ll {{\widetilde{\lambda }}^{2}}_{{kg}}\), the prior on wkg approaches normal(0, c2), therefore regularizing wkg even when the parameters are weakly identified.
Scenario 2: multiple sample
For each batch, we model the gene-wise batch effect of gene g of batch s, \({\delta }_{{sg}}^{{batch}}\), as a zero-mean Student’s t-distribution with a small s.d. of 0.01 and degree of freedom of 10 as we expect most of the genes to be unaffected by batch effects. The Student’s t-distribution has heavier tails compared to the normal distribution, allowing the possibility of accommodating large batch effect present in the data. The topic-wise batch effect of topic k, \({\tau }_{k}^{{batch}}\), is modeled as a β prior, controlling the amount of batch effect present in each topic. The Beta prior puts more mass on both ends (near 0 and 1). The contribution of batch effect \({w}_{{skg}}^{{batch}}\) is therefore given by an outer product of the gene and topic-wise batch effect terms. Last, the batch-specific gene embedding \({\beta }_{{skg}}^{{batch}}\) is the sum of \({w}_{{skg}}^{{batch}}\), gene module wkg and background residual rg. The former two terms are retained from the last scenario.
Scenario 3: time series
In the context of time-series data analysis, we expect the gene module wkg to vary across time points t. Here, we model each wkg as an independent Gaussian process with a Matern 3/2 kernel. The Matern 3/2 kernel κ(t, t′) consists of two hyperparameters, the output variance \({\widetilde{\sigma}}_{{kg}}^{2}\) that controls the average distance of the function from its mean and the length scale parameter l that determines the smoothness of the function. We fix l to 1 as we want to recover gene modules that are coherent across time and set \({\widetilde{\sigma }}_{{kg}}^{2}\) to be the regularized horseshoe prior described in the previous section. Last, we put a normal prior on the background residual term rtg at each time point for each gene.
Dispersion term α g
We model the square root of the dispersion as a Half-Cauchy prior. The prior places most of its mass toward zero, signaling that most of the genes do not exhibit overdispersion.
Section 2 inference
Black-box variational inference is used to approximate the posterior, building on the automatic differentiation variational inference (ADVI) framework from Pyro71. The joint probability for the single sample scenario is given by
where Θ = Δ, Λ, T, c, W, U, σ, A, R and
To approximate the posterior p(Θ|X), we choose the mean-field variational family \({q}_{\phi }\left(\bf{\Theta} \right)=\prod {q}_{\phi }\left(\Theta \right)\), which factorizes into independent distributions for each parameter Θ. Specifically, we utilize normal distributions for the real parameters W, U, R and lognormal distributions for the positive parameters Δ, Λ, T, c, σ and A, ensuring that they have the same support as the prior distribution.
To approximate the posterior for p(Z|X), we make use of simplified graph convolutional network that also takes in spatial information. The simplified graph convolutional network takes in the gene expression counts and the spatial adjacency graph, and outputs the mean Zu and variance Zσ for the variational parameters qϕ (Z|X, A).
where A is the adjacency matrix, I is the identity matrix, \(\widetilde{\bf{D}}\) is the degree of \(\widetilde{\bf{A}}\), X is the gene expression matrix and NN is the neural network used. Therefore, the ELBO is given by
where ϕ denotes the learnable parameters of both the graph neural network and the variational posteriors. The first term represents the expectation of the joint density with respect to the variational distribution q, while the second term is the entropy of the variational distribution. The gradient of the ELBO is given by
We compute a noisy, unbiased gradient estimate using unbiased Monte-Carlo estimates that rely on reparametrized gradients16. This approach stabilizes the optimization procedure by reducing variance and allows for optimization through stochastic optimization techniques such as Adam72. We provided more details of the training and simplified graph convolution network in Supplementary Note 1.
Outputs and post-processing
The output topic proportions znk and gene module scores wkg are taken to be the mean of the variational posteriors q(znk|X, A) and q(wkg), respectively. We further post-process the gene module scores by downweighing the lowly-expressed genes. The new gene module score is given by
where rg is the mean of the variational posterior q(rg). We set \(\epsilon\) to the tenth quantile of rg.
Binarization of topics
Each cell was assigned to a topic based on the largest value in its topic proportion.
Method comparison
We compared STAMP with several existing methods that can identify topics and their corresponding gene modules. We limited the competing methods to those whose latent topics are non-negative, therefore omitting methods such as PCA and its related extensions such as SpatialPCA and MEFISTO12,26. Therefore, we compared STAMP to NMF, linear decoded variational autoencoder (LDVAE), LDA, non-negative spatial matrix factorization hybrid (NSFH) and SpiceMix.
NMF
NMF factorizes a given gene expression matrix into two non-negative matrices, which can be interpreted as a set of underlying ‘metagenes’ and ‘metasamples’. We ran NMF from the scikit-learn package with the Kullback divergence loss and set max-iter to 1,000 to avoid convergence errors. The KL loss NMF is equivalent to a NMF with Poisson likelihood.
LDA
LDA is a generative statistical model under a family of models named topic models that was originally developed for text count data. It assumes a Dirichlet prior on top of the generating process compared to NMF. We ran LDA from the scikit-learn package with its default parameters.
LDVAE
LDVAE is a deep latent factor model which replaces the neural network decoder of scVI73 with a linear decoder. We ran LDVAE with the default parameters except for the use of a logistic-normal distribution as the latent topics’ distributions to enforce positivity.
NSFH
Non-negative spatial factorization is a spatially aware probabilistic dimension reduction model based on transformed Gaussian processes and NMF. We ran NSFH with the default parameters, with half of the factors as spatial factors and the other half as nonspatial factors as suggested. We also used 3,000 inducing points.
SpiceMix
SpiceMix is a spatially aware probabilistic dimension reduction model that uses NMF and hidden Markov random field to model the spatial dependencies. We ran SpiceMix with the default parameters except for using k-means as the initialization scheme to obtain the exact number of topics as we failed to obtain the right number of topics with the default initialization scheme.
DeepST
DeepST is a tool that aligns and integrates multiple spatial transcriptomics datasets. It makes use of data augmentation for preprocessing. It uses graph neural networks to incorporate spatial information and a denoising autoencoder for integration. We ran DeepST with its default parameters.
GraphST
GraphST is a tool that aligns and integrates multiple spatial transcriptomics datasets. It makes use graph neural networks with a contrastive loss to incorporate spatial information. We ran GraphST with its default parameters.
PRECAST
PRECAST is a probabilistic algorithm that aligns and integrates multiple spatial datasets. Precast combines factor analysis with an intrinsic autoregressive component for integration and incorporating spatial information. We ran PRECAST with the default parameters.
STAligner
STAligner is a tool that aligns and integrates multiple spatial transcriptomics datasets. It uses graph attention neural networks to incorporate spatial information and a triplet loss for integration. We ran STAligner with its default parameters.
Evaluation metrics
To evaluate the gene modules found, we used two metrics popular in topic modeling. The first is module coherence, which we measure with normalized pointwise mutual information (NPMI). NPMI quantifies the co-occurrence of genes, and the module coherence is calculated by taking the mean of NPMI.
where P(gi, gj) refers to the joint probability of two genes occurring in the same cell, P(gi) refers to the probability of observing gene i and K is the number of topics. We use the observed counts of each gene to measure the probabilities. To prevent housekeeping or background genes from dominating the metric, we only consider a gene to be present in a cell if its expression falls within the top 25th percentile. We used the top 20 ranked genes from the topic’s gene module for our evaluation. The unnormalized version of the metric has been used in single-cell studies74,75.
The second is module diversity that measures how unique gene modules are using ranked bias overlap (RBO)30. RBO compares two gene modules Mi and Mj of equivalent size and returns a number between 0 and 1, where 1 means the two gene modules are identical and 0 means they are completely unique. We calculate RBO scores between each pair of gene modules using the top 20 ranked genes. The module diversity score is then calculated by taking the mean of the minimum (1 – RBO) score per topic. This ensures that modules with a higher diversity obtain a higher score.
To evaluate the batch correction capabilities of the different methods, we utilized the scIB metrics. We employed the scib metrics package from https://github.com/YosefLab/scib-metrics to generate the results.
Data resources and preprocessing
The spatial adjacency graphs were built with the function squidpy.pp.spatial_neighbors with six nearest neighbors (one hexagonal ring) for structured data (10x Genomics Visium) or with the number of neighbors equivalent to 1/1,000 of the whole dataset. Highly variable genes were selected using Scanpy’s highly variable genes command with flavor = ‘seurat_v3’, which follows the Seurat’s pipeline.
Mouse hippocampus data, Slide-seq V2
We obtained the Slide-seq V2 data from the SeuratData package (https://github.com/satijalab/seurat-data). We then converted it to a h5ad object for further analysis. We filtered out genes that are expressed in less than 1% of the data and cells that have fewer than 100 genes. We then selected for 6,000 highly variable genes.
Human non-small cell lung cancer data, CosMx SMI
We obtained the processed Giotto76 object from https://nanostring.com/products/cosmx-spatial-molecular-imager/nsclc-ffpe-dataset. The data were then transformed into a h5ad object. We filtered out genes that are expressed in less than 1% of the data and cells that have fewer than 50 counts. We then selected for 600 highly variable genes.
Mouse brain anterior and posterior data, 10x Genomics Visium
We obtained the 10x Genomics Visium mouse brain data from the 10x Genomics Data Repository (https://www.10xgenomics.com/resources/datasets). The two files are Mouse Brain Serial Section 2 (sagittal–anterior) and Mouse Brain Serial Section 2 (sagittal–posterior). We filtered out genes that are expressed in less than 3% of the cells and mean nonzero expression <1. We then selected for 2,000 highly variable genes.
DLPFC, 10x Genomics Visium
The dataset of 12 human DLPFC tissue sections were obtained from https://github.com/LieberInstitute/spatialDLPFC. We filtered out genes that are expressed in less than 3% of the cells. We then selected for 4,000 highly variable genes.
Mouse olfactory bulb data, Stereo-seq/Slide-seq V2/10x Genomics Visium
We obtained the Stereo-seq data from https://db.cngb.org/stomics/mosta/download/. The Slide-seq V2 data were obtained from https://singlecell.broadinstitute.org/single_cell/study/SCP815/highly-sensitive-spatial-transcriptomics-at-near-cellular-resolution-with-slide-seqv2#study-download. The 10x Genomics Visium data were obtained from https://www.10xgenomics.com/datasets/adult-mouse-olfactory-bulb-1-standard. We first filtered out cells that have fewer than 50 genes and filtered out genes that are expressed in less than 3%, 1%, 1% of the cells for 10x Genomics Visium, Slide-seq v2 and Stereo-seq, respectively. We concatenated the data and then selected a total of 6,000 highly variable genes.
Mouse embryo data, Stereo-seq
We obtained the 50-binned mouse embryo file (Mouse_embryo_all_stage.h5ad) from https://db.cngb.org/stomics/mosta/download/ which included time points from E9.5 to E16.5. We replaced the time point E10.5 with E10.5_E2S1.MOSTA.h5ad. We first filtered out cells that have fewer than 50 genes and genes that are expressed in less than 1% of the cells for each time point. We next selected 6,000 highly variable genes, to which we then applied another filtering of spatially variable genes with Moran’s I down to 2,000 genes.
Over-representation and gene set enrichment analysis of gene modules
We performed over-representation analysis to identify corresponding cell types associated with each topic with the top 20 genes for each topic. We used the enrich function from gseapy77 to conduct over-representation analysis with our gene modules scores as inputs. For the human CoxMx SMI Lung data, we used the scEnrichment function from the DISCOtoolkit available at https://github.com/JinmiaoChenLab/DISCOtoolkit_py. For the Stereo-seq mouse embryo data, we used the gsea function from gseapy to conduct GSEA with our gene modules score as input. We used the Gene Ontology Biological Process gene sets from MSigDB78 as our input gene sets.
Differential gene expression analysis of gene modules
We performed differential expression analysis to identify marker genes of each topic. We used the Gamma Poisson generalized linear models provided by glmGamPoi79 to fit the coefficients for each topic, followed by a quasi-likelihood ratio test with empirical Bayesian shrinkage to identify differentially expressed genes.
Computation server employed
All analyses were conducted on a server equipped with an Intel Core i7-8665U CPU and an NVIDIA Titan V GPU with 12 GB of memory.
Reporting summary
Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article.
Data availability
The pre-reprocessed data objects used in this study have been uploaded to Zenodo and are freely available at https://doi.org/10.5281/zenodo.8201825 (ref. 80).
Code availability
An open-source Python implementation using Pyro71 of STAMP is available at https://github.com/JinmiaoChenLab/scTM. Scripts to reproduce this can be found at Zenodo at https://doi.org/10.5281/zenodo.8201825 (ref. 80).
References
Moses, L. & Pachter, L. Museum of spatial transcriptomics. Nat. Methods 19, 534–546 (2022).
Lee, D. D. & Seung, H. S. Learning the parts of objects by non-negative matrix factorization. Nature 401, 788–791 (1999).
Blei, D. M., Ng, A. Y. & Jordan, M. I. Latent Dirichlet allocation. J. Mach. Learn. Res. 3, 993–1022 (2003).
Wolf, F. A., Angerer, P. & Theis, F. J. SCANPY: large-scale single-cell gene expression data analysis. Genome Biol. 19, 15 (2018).
Bravo González-Blas, C. et al. cisTopic: cis-regulatory topic modeling on single-cell ATAC-seq data. Nat. Methods 16, 397–400 (2019).
Carbonetto, P., Sarkar, A., Wang, Z. & Stephens, M. Non-negative matrix factorization algorithms greatly improve topic model fits. Preprint at https://arxiv.org/abs/2105.13440 (2022).
Svensson, V., Gayoso, A., Yosef, N. & Pachter, L. Interpretable factor models of single-cell RNA-seq via variational autoencoders. Bioinformatics 36, 3418–3421 (2020).
Hu, J. et al. SpaGCN: integrating gene expression, spatial location and histology to identify spatial domains and spatially variable genes by graph convolutional network. Nat. Methods 18, 1342–1351 (2021).
Li, Z. & Zhou, X. BASS: multi-scale and multi-sample analysis enables accurate cell type clustering and spatial domain detection in spatial transcriptomic studies. Genome Biol. 23, 168 (2022).
Zhao, E. et al. Spatial transcriptomics at subspot resolution with BayesSpace. Nat. Biotechnol. 39, 1375–1384 (2021).
Long, Y. et al. Spatially informed clustering, integration, and deconvolution of spatial transcriptomics with GraphST. Nat. Commun. 14, 1155 (2023).
Velten, B. et al. Identifying temporal and spatial patterns of variation from multimodal data using MEFISTO. Nat. Methods 19, 179–186 (2022).
Townes, F. W. & Engelhardt, B. E. Nonnegative spatial factorization applied to spatial genomics. Nat. Methods 20, 229–238 (2023).
Chidester, B., Zhou, T., Alam, S. & Ma, J. SPICEMIX enables integrative single-cell spatial modeling of cell identity. Nat. Genet. 55, 78–88 (2023).
Srivastava, A. & Sutton, C. Autoencoding variational inference for topic models. In International Conference on Learning Representations https://openreview.net/pdf?id=BybtVK9lg (ICLR, 2017).
Kingma, D. P. & Welling, M. Auto-encoding variational bayes. Preprint at https://arxiv.org/abs/1312.6114 (2013).
Ranganath, R., Gerrish, S. & Blei, D. Black box variational inference. In Proc. 17th International Conference on Artificial Intelligence and Statistics 814–822 (PMLR, 2014).
Frasca, F. et al. SIGN: scalable inception graph neural networks. Preprint at https://arxiv.org/abs/2004.11198 (2020).
Wu, F. et al. Simplifying graph convolutional networks. In Proc. 36th International Conference on Machine Learning 6861–6871 (PMLR, 2019).
Carvalho, C. M., Polson, N. G. & Scott, J. G. Handling sparsity via the horseshoe. In Proc. 12th International Conference on Artificial Intelligence and Statistics 73–80 (PMLR, 2009).
Piironen, J. & Vehtari, A. Sparsity information and regularization in the horseshoe and other shrinkage priors. Electron. J. Stat. 11, 5018–5051 (2017).
Zhao, S., Gao, C., Mukherjee, S. & Engelhardt, B. E. Bayesian group factor analysis with structured sparsity. J. Mach. Learn. Res. 17, 1–47 (2016).
Qoku, A. & Buettner, F. Encoding domain knowledge in multi-view latent variable models: a Bayesian approach with structured sparsity. In Proc. of The 26th International Conference on Artificial Intelligence and Statistics 11545–11562 (PMLR, 2023).
Traag, V. A., Waltman, L. & van Eck, N. J. From Louvain to Leiden: guaranteeing well-connected communities. Sci. Rep. 9, 5233 (2019).
Dong, K. & Zhang, S. Deciphering spatial domains from spatially resolved transcriptomics with an adaptive graph attention auto-encoder. Nat. Commun. 13, 1739 (2022).
Shang, L. & Zhou, X. Spatially aware dimension reduction for spatial transcriptomics. Nat. Commun. 13, 7203 (2022).
Stickels, R. R. et al. Highly sensitive spatial transcriptomics at near-cellular resolution with Slide-seqV2. Nat. Biotechnol. 39, 313–319 (2021).
Allen Institute for Brain Science. Allen Brain Atlas: Mouse Brain. https://mouse.brain-map.org/static/atlas (2008).
Bouma, G. Normalized (pointwise) mutual information in collocation extraction. In Proc. of German Society for Computational Linguistics 30 31–40 (GSCL, 2009).
Webber, W., Moffat, A. & Zobel, J. A similarity measure for indefinite rankings. ACM Trans. Inf. Syst. 28, 20:1–20:38 (2010).
Cembrowski, M. S., Wang, L., Sugino, K., Shields, B. C. & Spruston, N. Hipposeq: a comprehensive RNA-seq database of gene expression in hippocampal principal neurons. eLife 5, e14997 (2016).
Dudek, S. M., Alexander, G. M. & Farris, S. Rediscovering area CA2: unique properties and functions. Nat. Rev. Neurosci. 17, 89–102 (2016).
Seigneur, E., Polepalli, J. S. & Südhof, T. C. Cbln2 and Cbln4 are expressed in distinct medial habenula-interpeduncular projections and contribute to different behavioral outputs. Proc. Natl Acad. Sci. USA 115, E10235–E10244 (2018).
Wallace, M. L. et al. Anatomical and single-cell transcriptional profiling of the murine habenular complex. eLife 9, e51271 (2020).
He, S. et al. High-plex imaging of RNA and proteins at subcellular resolution in fixed tissue by spatial molecular imaging. Nat. Biotechnol. 40, 1794–1806 (2022).
Li, M. et al. DISCO: a database of deeply integrated human single-cell omics data. Nucleic Acids Res. 50, D596–D602 (2022).
Domínguez Conde, C. et al. Cross-tissue immune cell analysis reveals tissue-specific features in humans. Science 376, eabl5197 (2022).
Han, C., Liu, T. & Yin, R. Biomarkers for cancer-associated fibroblasts. Biomark. Res. 8, 64 (2020).
Grout, J. A. et al. Spatial positioning and matrix programs of cancer-associated fibroblasts promote T-cell exclusion in human lung tumors. Cancer Discov. 12, 2606–2625 (2022).
Remsing Rix, L. L. et al. IGF-binding proteins secreted by cancer-associated fibroblasts induce context-dependent drug sensitization of lung cancer cells. Sci. Signal. 15, eabj5879 (2022).
Guo, S. & Deng, C.-X. Effect of stromal cells in tumor microenvironment on metastasis initiation. Int. J. Biol. Sci. 14, 2083–2093 (2018).
Palla, G. et al. Squidpy: a scalable framework for spatial omics analysis. Nat. Methods 19, 171–178 (2022).
Landskron, G., De la Fuente, M., Thuwajit, P., Thuwajit, C. & Hermoso, M. A. Chronic inflammation and cytokines in the tumor microenvironment. J. Immunol. Res. 2014, 149185 (2014).
Ballester, B., Milara, J. & Cortijo, J. Idiopathic pulmonary fibrosis and lung cancer: mechanisms and molecular targets. Int. J. Mol. Sci. 20, 593 (2019).
Wong, K. Y. et al. Cancer-associated fibroblasts in nonsmall cell lung cancer: from molecular mechanisms to clinical implications. Int. J. Cancer 151, 1195–1215 (2022).
Dvorak, H. F. Tumors: wounds that do not heal. Similarities between tumor stroma generation and wound healing. N. Engl. J. Med. 315, 1650–1659 (1986).
Foster, D. S., Jones, R. E., Ransom, R. C., Longaker, M. T. & Norton, J. A. The evolving relationship of wound healing and tumor stroma. JCI Insight 3, e99911 (2018).
10x Genomics. Mouse Brain Serial Section 2 (Sagittal-Posterior). https://www.10xgenomics.com/datasets/mouse-brain-serial-section-2-sagittal-anterior-1-standard-1-1-0 (2023).
10x Genomics. Mouse Brain Serial Section 2 (Sagittal-Anterior). https://www.10xgenomics.com/datasets/mouse-brain-serial-section-2-sagittal-anterior-1-standard-1-1-0 (2023).
Tasic, B. et al. Adult mouse cortical cell taxonomy revealed by single cell transcriptomics. Nat. Neurosci. 19, 335–346 (2016).
Sorensen, S. A. et al. Correlated gene expression and target specificity demonstrate excitatory projection neuron diversity. Cereb. Cortex 25, 433–449 (2015).
Siavash, F. D. et al. Neonatal Tbr1 dosage controls cortical layer 6 connectivity. Neuron 100, 831–845.e7 (2018).
Xu, C. et al. DeepST: identifying spatial domains in spatial transcriptomics by deep learning. Nucleic Acids Res. 50, e131 (2022).
STAligner enables the integration and alignment of multiple spatial transcriptomics datasets. Nat. Comput. Sci. 3, 831–832 (2023).
Luecken, M. D. et al. Benchmarking atlas-level data integration in single-cell genomics. Nat. Methods 19, 41–50 (2022).
Wang, I.-H. et al. Spatial transcriptomic reconstruction of the mouse olfactory glomerular map suggests principles of odor processing. Nat. Neurosci. 25, 484–492 (2022).
Rueda-García, V. & Rondón-Barragán, I. S. Molecular characterization of neurogranin (NRGN) gene from red-bellied pacu (Piaractus brachypomus). Mol. Neurobiol. https://doi.org/10.1007/s12035-023-03700-5 (2023).
Erwin, S. R. et al. A sparse, spatially biased subtype of mature granule cell dominates recruitment in hippocampal-associated behaviors. Cell Rep. 31, 107551 (2020).
Ståhl, P. L. et al. Visualization and analysis of gene expression in tissue sections by spatial transcriptomics. Science 353, 78–82 (2016).
Tepe, B. et al. Single-cell RNA-seq of mouse olfactory bulb reveals cellular heterogeneity and activity-dependent molecular census of adult-born neurons. Cell Rep. 25, 2689–2703.e3 (2018).
Xu, H. et al. Unsupervised spatially embedded deep representation of spatial transcriptomics. Genome Med. 16, 12 (2024).
Maynard, K. R. et al. Transcriptome-scale spatial gene expression in the human dorsolateral prefrontal cortex. Nat. Neurosci. 24, 425–436 (2021).
Chen, A. et al. Spatiotemporal transcriptomic atlas of mouse organogenesis using DNA nanoball-patterned arrays. Cell 185, 1777–1792.e21 (2022).
de Boer, B. A., van den Berg, G., de Boer, P. A. J., Moorman, A. F. M. & Ruijter, J. M. Growth of the developing mouse heart: an interactive qualitative and quantitative 3D atlas. Dev. Biol. 368, 203–213 (2012).
Jacob, T. et al. Molecular and spatial landmarks of early mouse skin development. Dev. Cell 58, 2140–2162.e5 (2023).
Yumine, A., Fraser, S. T. & Sugiyama, D. Regulation of the embryonic erythropoietic niche: a future perspective. Blood Res. 52, 10–17 (2017).
Merryweather-Clarke, A. T. et al. Global gene expression analysis of human erythroid progenitors. Blood 117, e96–e108 (2011).
Gordillo, M., Evans, T. & Gouon-Evans, V. Orchestrating liver development. Development 142, 2094–2108 (2015).
Mu, T. et al. Embryonic liver developmental trajectory revealed by single-cell RNA sequencing in the Foxa2eGFP mouse. Commun. Biol. 3, 1–12 (2020).
Tang, L. Spatially resolved multiomics. Nat. Methods 20, 1871 (2023).
Bingham, E. et al. Pyro: deep universal probabilistic programming. J. Mach. Learn. Res. 20, 1–6 (2019).
Kingma, D. P. & Ba, J. Adam: a method for stochastic optimization. In International Conference on Learning Representations (ICLR, 2015).
Lopez, R., Regier, J., Cole, M. B., Jordan, M. I. & Yosef, N. Deep generative modeling for single-cell transcriptomics. Nat. Methods 15, 1053–1058 (2018).
Kunes, R. Z., Walle, T., Land, M., Nawy, T. & Pe’er, D. Supervised discovery of interpretable gene programs from single-cell data. Nat. Biotechnol. 42, 1084–1095 (2024).
Bravo González-Blas, C. et al. SCENIC+: single-cell multiomic inference of enhancers and gene regulatory networks. Nat. Methods 20, 1355–1367 (2023).
Dries, R. et al. Giotto: a toolbox for integrative analysis and visualization of spatial expression data. Genome Biol. 22, 78 (2021).
Fang, Z., Liu, X. & Peltz, G. GSEApy: a comprehensive package for performing gene set enrichment analysis in Python. Bioinformatics 39, btac757 (2023).
Liberzon, A. et al. Molecular signatures database (MSigDB) 3.0. Bioinformatics 27, 1739–1740 (2011).
Ahlmann-Eltze, C. & Huber, W. glmGamPoi: fitting Gamma-Poisson generalized linear models on single cell count data. Bioinformatics 36, 5701–5702 (2020).
Zhong, C. et al. Interpretable spatially aware dimension reduction of spatial transcriptomics with STAMP. Zenodo https://doi.org/10.5281/zenodo.8201825 (2024).
Acknowledgements
We thank A. M. Vargas Velazquez and Z. Ong for providing interpretation on the mouse embryo and brain data, respectively. We also thank M. Li for providing support on the DISCO scEnrichment analysis. This work was supported by AI, Analytics and Informatics (AI3) Horizontal Technology Programme Office seed grant (Spatial Transcriptomics ST in Conjunction with Graph Neural Networks for Cell–cell Interaction; C211118015) from A*STAR, Singapore; Open Fund Individual Research Grant (Mapping Hematopoietic Lineages of Healthy and High-risk Acute Myeloid Leukemia Patients with FLT3-ITD Mutations using Single-cell Omics; OFIRG18nov-0103) from Ministry of Health, Singapore; Use-Inspired Basic Research Fund (Identify Novel Targets for Cell Type-specific Immunotherapy using Spatial and Single-cell Omics in Conjunction with AI Analytics) from A*STAR, Singapore; the National Research Foundation, Singapore and Singapore Ministry of Health’s National Medical Research Council under its Open Fund-Large Collaborative Grant (‘OFLCG’) (MOH-OFLCG18May-0003).
Author information
Authors and Affiliations
Contributions
J.C. conceptualized and supervised the project. C.Z. designed the model. C.Z. developed the STAMP software. C.Z., K.S.A. and J.C. wrote the manuscript. C.Z. prepared the figures.
Corresponding author
Ethics declarations
Competing interests
The authors declare no competing interests.
Peer review
Peer review information
Nature Methods thanks Xin Maizie Zhou and the other, anonymous, reviewer(s) for their contributions to the peer review of this work. Primary Handling Editor: Rita Strack, in collaboration with the Nature Methods team. Peer reviewer reports are available.
Additional information
Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Extended data
Extended Data Fig. 1 STAMP and clustering algorithm results on simulated data.
a Ground truth topics in the simulated data. b Topics generated by STAMP. c Clusters generated by four different clustering algorithms, Leiden, GraphST, STAGATE, and SpatialPCA.
Extended Data Fig. 2 Binarized topics of STAMP and other methods.
Binarized topics identified by STAMP, NMF, SpiceMix, LDA, LDVAE and NSFH on the mouse hippocampus data acquired with Slide-seq V2.
Extended Data Fig. 3 Additional results of the SMI NSCLC data.
a Original annotation of the Nanostring SMI NSCLC data. b Heatmap of topic proportions returned by STAMP compared against the original annotations. The color intensity denotes topic proportion. c Topic proportion of fibroblasts and CAFs (Topics 6 and 11, and 13, respectively), and expression of the top three genes returned in each gene module of the topics.
Extended Data Fig. 4 Additional results on Visium mouse brain data.
a UMAP of the latent embeddings returned by STAMP and other methods for the 10x Genomics Visium DLPFC dataset, colored by the ground truth annotation. b UMAP of the latent embeddings returned by STAMP and other methods for the 10x Genomics Visium DLPFC dataset, colored by library id (sections).
Extended Data Fig. 5 Additional results on Stereo-seq mouse embryo data.
a Topic proportions identified by STAMP across all time points of the Stereo-seq mouse embryo data. b Binarized topics identified by STAMP across all time points of the Stereo-seq mouse embryo data.
Extended Data Fig. 6 Hyperparameter analysis on STAMP.
a Binarized topics identified by STAMP with different hyperparameter settings on the number of neural network layers. b Moran’s I score of STAMP’s topics with different hyperparameter settings on the number of neural network layers.
Extended Data Fig. 7 Computational time for STAMP and other methods.
Computation time required by STAMP and competing methods for different numbers of input cells. The x-axis is in log scale.
Supplementary information
Supplementary Information
Supplementary Figs. 1–24, Supplementary Notes 1 and 2 and Supplementary Tables 1 and 2.
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Zhong, C., Ang, K.S. & Chen, J. Interpretable spatially aware dimension reduction of spatial transcriptomics with STAMP. Nat Methods 21, 2072–2083 (2024). https://doi.org/10.1038/s41592-024-02463-8
Received:
Accepted:
Published:
Issue date:
DOI: https://doi.org/10.1038/s41592-024-02463-8
This article is cited by
-
Transcriptomics, single-cell sequencing and spatial sequencing-based studies of cerebral ischemia
European Journal of Medical Research (2025)
-
Spatial omics technology potentially promotes the progress of tumor immunotherapy
British Journal of Cancer (2025)
-
Spatial profiling of chromatin accessibility in formalin-fixed paraffin-embedded tissues
Nature Communications (2025)
-
SIMVI disentangles intrinsic and spatial-induced cellular states in spatial omics data
Nature Communications (2025)
-
Interpretable spatially aware dimension reduction of spatial transcriptomics with STAMP
Nature Methods (2024)