Skip to Content
BiologyBiology
  • Article
  • Open Access

2 December 2026

17 Pages

SpaRMA: Robust Multi-Slice Spatial Transcriptomics Integration via Masked Reconstruction and Multi-Positive Attention

,
,
,
,
,
and
1
School of Software, Yunnan University, Kunming 650091, China
2
Engineering Research Center of Cyberspace, Kunming 650091, China
3
Guangdong Institute of Intelligence Science and Technology, Hengqin, Zhuhai 519031, China
4
School of Information, Yunnan University, Kunming 650091, China

Simple Summary

Spatial transcriptomics measures gene expression while retaining the position of each measured spot in a tissue. Combining several slices can reveal larger structures or developmental changes, but technical differences may obscure their shared organization. SpaRMA learns from spatial neighborhoods by reconstructing masked spot profiles and weighting several plausible cross-slice matches. It produces a common representation for multi-slice integration and spatial-domain analysis.

Abstract

Joint analysis of multiple spatial transcriptomics slices can extend tissue coverage and support comparisons across samples or developmental stages. However, slice-specific variation must be reduced while spatially organized biological signals are retained. Graph-based integration is affected by two practical sources of uncertainty: incomplete spot-level expression can weaken local representation learning, and a single mutual-nearest-neighbor (MNN) correspondence may not represent all plausible cross-slice matches. We present SpaRMA, a two-stage spatial graph framework combining masked spot reconstruction with multi-positive attention. During masked reconstruction pretraining, complete spot profiles are masked while the spatial graph is retained, and the model reconstructs the selected profiles from neighboring spots. During clean joint training, the clean expression matrix is restored and several MNN-positive candidates are retained for each anchor; their triplet constraints are weighted by learned anchor–positive similarities. We evaluated SpaRMA on three benchmark datasets: four-slice DLPFC, 12-slice DLPFC, and Stereo-seq mouse embryo spanning four developmental stages. The DLPFC experiments evaluated annotation agreement together with batch mixing and biological conservation. The embryo analysis identified regionally organized domains interpreted using spatial correspondence and tissue-associated marker patterns. Repeated component ablations further supported the contribution of the combined design. Together, these results demonstrate the utility of SpaRMA for multi-slice spatial-domain analysis, without manual spatial-domain annotations entering the training objective.       

1. Introduction

Spatial transcriptomics (ST) measures gene expression together with spatial coordinates, enabling molecular variation to be studied within tissue architecture [1,2,3,4]. A single slice covers only part of a tissue or one developmental time point. Multi-slice analysis is therefore needed to study larger structures, multiple donors, or developmental series.
Technical differences in tissue handling, library preparation, sequencing depth, and capture efficiency can produce slice-specific shifts that are unrelated to the biological question. These effects may obscure shared tissue organization, separate comparable cell populations by slice, or fragment a continuous anatomical structure in the integrated representation. Multi-slice integration must therefore reduce technical variation while retaining spatial domains, tissue boundaries, and genuine biological differences among samples.
We organize related methods primarily by whether and how they use spatial information, while distinguishing slice correspondence estimation from representation learning. Expression-based methods, including Harmony [5], Seurat [6,7], MNN correction [8], and Scanorama [9], align expression profiles or low-dimensional representations without explicitly using spot coordinates in their standard batch-correction objectives. These approaches provide a basis for reducing expression-level batch effects, but do not directly constrain local tissue organization.
Spatially informed approaches additionally use tissue geometry, although they do not all solve the same task. PASTE estimates correspondences between adjacent slices through fused optimal transport based on expression and spatial distances [10]. STAMP instead uses a spatially aware topic model for multi-slice analysis [11]. These approaches illustrate different uses of tissue geometry, from estimating inter-slice correspondences to learning shared expression representations. Related spatial analysis and integration frameworks also include GraphST [12], PRECAST [13], SPIRAL [14], and STitch3D [15].
Within spatially informed representation learning, graph-based models encode local tissue neighborhoods. STAGATE introduced a graph attention autoencoder for learning expression representations from spatial neighborhoods [16]. Building on spatial graph representations, STAligner adds MNN-guided triplet learning for explicit cross-slice integration [17]. SpaCross combines cross-masked reconstruction, latent consistency, and adaptive spatial-semantic graph modeling [18]. Other graph-based approaches address multi-slice alignment and spatial-domain identification, including DGAE and STGAT [19,20]. INSPIRE combines spatial graph modeling, adversarial integration, and non-negative matrix factorization [21]. Thus, spatial graph encoding and cross-slice alignment are related but distinct components of an integration framework.
Two linked challenges motivate the present study. First, local expression measurements can provide incomplete evidence for spatial-domain identity. Spatial context can supplement this evidence, but neighboring spots may span different tissue domains. The representation-learning problem is therefore to use contextual information while retaining distinctions between anatomical regions, rather than simply increasing neighborhood similarity. This motivates learning representations that remain informative when part of the local expression input is unavailable.
Second, cross-slice correspondences must be inferred despite differences in tissue geometry and expression. An anchor may have several plausible counterparts rather than a uniquely supported match. Constraining alignment through one selected candidate does not represent this ambiguity, whereas retaining multiple candidates raises the question of how their contributions should be combined. An alignment objective should therefore accommodate multiple candidate matches while allowing their contributions to differ.
We address these challenges with SpaRMA, a two-stage spatial graph framework combining masked spot reconstruction and multi-positive attention. Masked reconstruction is an established representation-learning strategy [22], including in spatial transcriptomics [18,23,24]. In SpaRMA, pretraining masks complete spot profiles and sets the corresponding latent rows to zero before decoding, encouraging reconstruction through the retained spatial neighborhood. Clean joint training then restores the unmasked input and replaces a single-positive alignment constraint with separate triplet constraints for several MNN-positive candidates. Learned query–key similarities determine each candidate’s contribution to the alignment loss [25,26]. This formulation retains multiple possible correspondences rather than committing each anchor to one match. The two stages separate contextual reconstruction from cross-slice alignment: the first trains on controlled loss of local expression, while the second jointly optimizes full-input reconstruction and multi-candidate alignment. Their combination is the central design contribution of SpaRMA for learning spatial-domain representations under incomplete local evidence and uncertain cross-slice correspondence.
Our robustness-oriented design targets incomplete local expression and ambiguous cross-slice matches. We assess SpaRMA on three benchmark datasets: four-slice human dorsolateral prefrontal cortex (DLPFC-4), 12-slice DLPFC (DLPFC-12), and Stereo-seq mouse embryo. The DLPFC experiments examine spatial-domain agreement and cortical organization under within-donor and across-donor integration, respectively. The embryo analysis examines spatial domains across four developmental stages.

2. Materials and Methods

2.1. Overview

SpaRMA takes normalized gene expression matrices and spatial coordinates from multiple slices as input (Figure 1). A spatial graph is built independently for each slice. Training then proceeds in two stages. The first stage learns spatially contextualized representations through masked spot reconstruction. The second stage restores the clean input and jointly optimizes gene-expression reconstruction and cross-slice alignment. The final embedding is used for slice integration and spatial-domain clustering.
Figure 1. Overview of SpaRMA. Masked reconstruction pretraining masks complete spot profiles while retaining the spatial graph, sets the corresponding latent rows to zero before decoding, and evaluates reconstruction only on the selected spots. The [MASK] labels in the latent schematic identify the selected positions; the corresponding latent rows are numerically set to zero before decoding. Clean joint training restores the clean input and jointly optimizes reconstruction and attention-weighted cross-slice triplet constraints. Line width represents the learned weight of each MNN positive.

2.2. Preprocessing and Spatial Graph Construction

Preprocessing was performed independently for each slice. For the four-slice and 12-slice DLPFC experiments, respectively, 5000 and 10,000 highly variable genes (HVGs) were identified from each raw count matrix using the Seurat v3 procedure. Counts were then normalized to a total of 10 4 per spot, transformed using log ( 1 + x ) , and restricted to the selected HVGs. For each mouse embryo slice, the matrix stored in the count layer was copied to the working expression matrix, normalized to 10 4 counts per spot, and transformed using log ( 1 + x ) . Following the implemented embryo workflow, 5000 HVGs were then selected by calling Scanpy with flavor=‘seurat_v3’ on this log-normalized matrix. In both analyses, the slice-specific matrices were concatenated using an inner join, so only genes retained in every slice entered the model. No additional gene-frequency filtering or feature scaling was applied. Let X ( s ) ∈ R n s × F denote the processed expression matrix of slice s, where n s is the number of spots and F is the number of shared genes after concatenation.
Spatial coordinates c i ( s ) are used to construct a within-slice graph G ( s ) = ( V ( s ) , E ( s ) ) . Its adjacency matrix is
A i j ( s ) = 1 , i = j or j ∈ K 50 ( s ) ( i ) and ∥ c i ( s ) − c j ( s ) ∥ 2 < r s , 0 , otherwise ,
where K 50 ( s ) ( i ) contains the 50 nearest other spots in slice s, and  r s is the spatial-radius cutoff; the same cutoff is used for all slices within each dataset. The implementation first retrieves these neighbors and then retains those strictly within the radius. Every spot also has a self-loop. Coordinates are taken directly from obsm[‘spatial’] without additional rescaling. The DLPFC experiments used a radius of 150 in the Visium coordinates loaded by read_visium, whereas the mouse embryo experiment used a radius of 1.3 in the coordinates stored with the MOSTA data.
The slice graphs form a disjoint union. The combined adjacency is A = diag ( A ( 1 ) , … , A ( S ) ) , where S is the number of slices. Spatial edges remain within slices; encoder and decoder parameters are shared across all slices in both training stages. Cross-slice relationships are introduced through the alignment objective below.

2.3. Spatially Aware Graph Autoencoder

The encoder follows the spatial graph attention autoencoder design introduced in STAGATE [16]. For a slice containing n spots, let H ( 0 ) = X ∈ R n × F denote the initial node-feature matrix and let h i ( 0 ) = x i T ∈ R F be the initial feature vector of spot i. For a graph-attention layer l, let d l and d l + 1 be its input and output dimensions, respectively, and let W ( l ) ∈ R d l + 1 × d l be the trainable feature-transformation matrix. The compatibility score between spots i and j is
s i j ( l ) = a ( l ) T W ( l ) h i ( l ) ∥ W ( l ) h j ( l ) ,
where ‖ denotes concatenation and a ( l ) ∈ R 2 d l + 1 is a trainable attention vector. The edge score and its neighborhood-wise normalization are
e i j ( l ) = sigmoid s i j ( l ) ,
α i j ( l ) = exp e i j ( l ) ∑ p ∈ N ( i ) exp e i p ( l ) ,
where N ( i ) is the spatial neighborhood of spot i, including its self-loop. The normalized coefficients are used for message passing:
h i ( l + 1 ) = σ ∑ j ∈ N ( i ) α i j ( l ) W ( l ) h j ( l ) ,
where σ denotes the activation used by the corresponding layer and is the identity map when no nonlinear activation is applied. The encoder applies graph-attention aggregation from F to 512 dimensions followed by ELU, then a linear projection from 512 to 30 dimensions without neighborhood aggregation. Its output is the latent matrix Z ∈ R n × 30 . The transformation matrices and attention parameters are initialized using Xavier normal initialization with gain 1.414. The decoder applies graph-attention aggregation from 30 to 512 dimensions followed by ELU, then a linear projection to F. Decoder transformations are tied to the transposes of the corresponding encoder transformations. The decoder aggregation reuses the encoder attention scores before dropout; attention dropout is applied separately in each aggregation pass. Denoting the complete decoder by f dec , the reconstructed expression matrix is
X ^ = f dec ( Z , G ) ∈ R n × F .

2.4. Masked Spot Reconstruction

During masked pretraining, a subset M of spots is resampled independently within each slice at every epoch. Their complete expression rows are replaced by a trainable mask token initialized to zero, while the spatial graph is unchanged. The masking fraction is 0.10. The encoder processes this masked input. Before decoding, the latent rows corresponding to the same selected spots are set to zero; the decoder then produces the reconstruction X ^ mask . The reconstruction target is the expression matrix X before artificial masking, not the mask token. Writing X ˜ for the input after row masking and R M for the operation that sets rows indexed by M to zero, the generation step is
X ^ mask = f dec R M f enc ( X ˜ , G ) , G .
The functions f enc and f dec denote the encoder and decoder defined above. Loss is evaluated only on the selected rows:
L m a s k = MSE X M , X ^ M mask ,
where X M , X ^ M mask ∈ R | M | × F select the original and reconstructed rows indexed by M . For matrices A , B ∈ R u × v ,
MSE ( A , B ) = 1 u v ∑ i = 1 u ∑ g = 1 v ( A i g − B i g ) 2 .
This definition is used for both L m a s k and L r e c . The masked objective requires the model to recover each selected profile from information propagated through its spatial neighborhood. Graph-attention dropout is 0.05 during training and is disabled during evaluation.

2.5. Multi-Positive Attention for Cross-Slice Alignment

After masked pretraining, SpaRMA restores the clean expression matrix. Passing this matrix through the current encoder produces Z ∈ R N × 30 , whose ith row is the transpose of the embedding vector z i ∈ R 30 . MNN correspondences are recomputed at the start of joint training and every 100 epochs thereafter by cross-batch nearest-neighbor search in the current embedding using Euclidean distance. A pair is retained when each spot occurs in the other’s cross-batch neighbor list. Because these are multi-neighbor lists rather than one-neighbor matches, an anchor can have several mutual candidates in the same counterpart batch. The search uses 50 neighbors for DLPFC-4 and 100 for DLPFC-12 and mouse embryo; these search sizes are distinct from the retained-positive limit K.
Correspondence batches are individual slices in DLPFC-4 and donor groups in DLPFC-12. All pairs of these batches are considered. For mouse embryo, each of E9.5, E10.5, and E11.5 is paired with E12.5. Spatial graphs and masking remain slice-specific. For each prescribed batch pair, the MNN construction returns a list C i of distinct positive candidates for each anchor constraint i. The first min ( K , | C i | ) candidates in that returned list form P i . Candidate retention is performed separately for each batch pair; the same spot can therefore contribute an anchor constraint in more than one pair. Only anchors with a nonempty positive set contribute to the loss, and padded entries used for batching are excluded from both attention normalization and the loss. We used K = 3 for the four-slice DLPFC analysis and K = 15 for the 12-slice DLPFC and mouse embryo analyses.
For constraint i, a i denotes its anchor embedding; the same spot embedding can occur in constraints from different batch pairs. The embedding of positive candidate j ∈ P i is p j = z j . At each correspondence refresh, one negative spot is sampled reproducibly from the anchor-side batch using the experiment’s random seed. The sampling pool comprises all spots in that batch, without a domain-label or spatial-neighborhood exclusion. The sampled negative spot is shared across all positive triplets of that anchor constraint until the next refresh; its embedding n i is recomputed by the encoder during training. Manual domain annotations are not used for anchor, positive, or negative selection. Anchor and positive embeddings are projected by trainable matrices W Q , W K ∈ R 30 × 30 and normalized with a norm floor:
q i = W Q a i max ( ∥ W Q a i ∥ 2 , ϵ ) , k j = W K p j max ( ∥ W K p j ∥ 2 , ϵ ) .
The constant ϵ = 10 − 3 is a numerical norm floor. The anchor–positive similarity is calculated as
s i j = q i T k j .
The similarities are normalized across the retained positive set using softmax:
w i j = exp ( s i j ) ∑ l ∈ P i exp ( s i l ) .
Each candidate positive forms a separate triplet constraint with the same anchor and the negative embedding defined above:
ℓ i j = max 0 , ∥ a i − p j ∥ 2 − ∥ a i − n i ∥ 2 + m t .
A triplet is active when ∥ a i − p j ∥ 2 − ∥ a i − n i ∥ 2 + m t > 0 . The alignment loss averages the attention-weighted triplet constraints over all anchors:
L t r i a t t = 1 N a ∑ i = 1 N a ∑ j ∈ P i w i j ℓ i j .
Here, N a is the number of nonempty anchor constraints over all prescribed batch pairs, rather than the number of unique spots. The bias-free projection matrices are initialized as identity mappings and optimized jointly with the encoder during clean joint training. At each correspondence refresh, margin calibration uses the fraction of anchors with at least one active positive constraint. Defining
g i = min j ∈ P i ∥ a i − n i ∥ 2 − ∥ a i − p j ∥ 2 , ρ ( m ) = 1 N a ∑ i = 1 N a 1 { g i < m } ,
the target fraction is computed from the first candidate of each anchor under the same current embeddings and negatives, using the reference margin (1.0 for DLPFC and 2.5 for mouse embryo). The updated m t minimizes the absolute difference between ρ ( m ) and this target. The candidate margins are the observed g i values, their next larger representable floating-point values, and 1.0; ties in the fraction discrepancy are resolved in favor of the margin closest to 1.0. Calibration is performed before the first joint-training update and at subsequent correspondence refreshes; the selected margin remains fixed between refreshes. This calibration uses embedding distances without manual domain labels and counts active anchors rather than pooling all candidate triplets.

2.6. Training Objective and Output

After the clean expression matrix has been restored, the encoder and decoder generate
Z = f enc ( X , G ) , X ^ = f dec ( Z , G ) .
No input masking or latent re-masking is applied in this joint-training forward pass. Reconstruction is evaluated over all spots and genes:
L r e c = MSE X , X ^ ,
where the mean is taken over all entries of the clean input and reconstructed expression matrices. The joint objective is
L t o t a l = L r e c + L t r i a t t .
The two terms are summed directly, as implemented in the executed training workflow. Training uses Adam with an initial learning rate of 10 − 3 and weight decay 10 − 4 . During pretraining, model gradients and mask-token gradients are clipped separately at norm 5. During joint training, model and attention-projection gradients are clipped together at norm 5. The training schedule and optimizer settings are also listed in the supplementary parameter table. The model is optimized for 1000 full-graph epochs: 500 epochs of masked reconstruction followed by 500 epochs of clean-input joint training. Because each dataset is represented as one concatenated graph object, training is full-batch rather than mini-batch. No validation-label-based early stopping is applied. The trained encoder returns the joint embedding Z for UMAP visualization and spatial-domain clustering.

2.7. Post-Training Analysis

For DLPFC, the final embedding is clustered with mclust using the ellipsoidal equal-volume, equal-shape, and equal-orientation (EEE) covariance model and seven clusters, corresponding to the six cortical layers and white matter [27]. Agreement with the manual annotations is then quantified using the adjusted Rand index (ARI), normalized mutual information (NMI), and clustering accuracy (ACC). For mouse embryo, Louvain clustering was performed with resolution fixed at 0.4, yielding 15 domains in the reported result. Published annotations were used for post-training interpretation. Slice or developmental-stage mixing is inspected in the common UMAP space.
For the embryo marker-expression summary, raw counts for genes shared across the four embryo slices were normalized to 10 4 counts per spot. For each gene, the domain-versus-rest log 2 fold change was calculated from the ratio of mean normalized expression within the domain to that in all remaining spots across the four stages, adding 10 − 6 to both means before taking the ratio. Means were calculated on the linear, rather than log-transformed, expression scale. Detection percentages were calculated within each domain as the percentage of spots with a nonzero raw count for the gene.

3. Results

3.1. Datasets and Evaluation Metrics

We evaluated three benchmark datasets: DLPFC-4, DLPFC-12, and mouse embryo. The human DLPFC data were generated using the 10x Visium platform [28], with manual annotations for six cortical layers and white matter. DLPFC-4 comprises four Sections (151673–151676) from one donor and evaluates integration among slices with similar tissue organization. DLPFC-12 comprises 12 Sections (151507–151510, 151669–151672, and 151673–151676) from three donors and evaluates integration across greater variation in donor identity, tissue coverage, and cortical geometry.
We further analyzed four sagittal mouse embryo slices generated by Stereo-seq and distributed through the MOSTA resource [2]. The slices represent E9.5, E10.5, E11.5, and E12.5. The integrated embedding was partitioned using Louvain clustering. Published tissue annotations and selected tissue-associated marker genes were used only after training to interpret the resulting domains; they were not used to optimize the representation or select cross-slice correspondences.
Clustering agreement on DLPFC was quantified using ARI, NMI, and ACC. ARI measures agreement between two partitions while correcting for chance; NMI measures the shared information between predicted and annotated domains; and ACC measures the proportion of matched assignments after permutation of cluster labels. Mouse embryo domains were obtained using Louvain clustering [29] at the fixed resolution of 0.4 and were assessed through spatial coherence, post-training correspondence with tissue annotations, and the spatial distributions of selected tissue-associated marker genes.
For the four-slice comparison, ARI and NMI are calculated on the concatenated valid spot labels, and ACC uses one global optimal assignment of cluster labels to annotation classes. Figure 2C additionally shows the slice-level distributions as boxplots with all four observations. The twelve-slice scores reported in the Results are arithmetic means of the corresponding slice-level scores, consistent with Figure 3A, which also shows sample SDs and individual observations. Both figures describe selected runs, chosen after comparing annotation-based ARI scores; annotations were not used in model training. Supplementary Tables S1 and S2 summarize five repeated executions per configuration, using training seed 42 for DLPFC-4 and 2025 for DLPFC-12.
Figure 2. Integration of four contiguous human DLPFC slices. (A) Manual annotations and spatial-domain assignments from INSPIRE, Harmony, STAligner, SpaCross, and SpaRMA. The ARI in each method title is calculated once over the combined four-slice result. (B) Method-specific UMAPs for SpaRMA, STAligner, SpaCross, INSPIRE, and Harmony. Rows show slice identity, manual annotation, and predicted spatial domains, respectively; all three views within a column share coordinates. (C) ARI, NMI, and ACC for all six methods, including STAMP. Boxes span the first and third quartiles, and the central line marks the median. Whiskers extend to the most extreme observations within 1.5 times the interquartile range. Points show all four slice-level values. Axis limits differ among the three metrics. These are between-slice distributions, not repeated-training statistics. Layer colors are shared across the spatial and UMAP panels.
Figure 3. Integration of 12 human DLPFC slices from three donors. (A) Slice-level ARI, NMI, and ACC for SpaRMA, STAligner, INSPIRE, Harmony, and STAMP. Bars show the mean across 12 slices, black diamonds show individual slices, and error bars show the sample SD. (B) Manual annotations and spatial-domain assignments for every slice. Columns retain the original slice order; the donor correspondence is Sample 3, 151673–151676; Sample 1, 151507–151510; Sample 2, 151669–151672. Rows show the manual annotations followed by the five methods. (C) Method-specific UMAPs colored by donor identity, manual annotation, and predicted spatial domain, respectively. Each column shares coordinates across its three views. The donor legend identifies Sample 1, Sample 2, and Sample 3; layer colors are shared across (B,C). Spatial maps omit spots without manual annotation.

3.2. Baseline Methods

For the comparisons displayed in Figure 2 and Figure 3, we compared SpaRMA with Harmony, STAligner, INSPIRE, STAMP, and, in the four-slice experiment, SpaCross. The four-slice STAMP evaluation used its saved K-means assignments. The 12-slice STAMP evaluation used a saved author-released representation with downstream clustering, rather than a newly trained STAMP model. SpaCross was included only in the four-slice setting for which a corresponding result was available. PASTE is discussed as related work but is not included in these quantitative comparisons.
Each method was evaluated using its reproduced analysis workflow and the annotation-based metrics defined above. Manual domain labels do not enter the SpaRMA training loss. INSPIRE follows the tutorial’s annotation-availability filter; using annotation availability to retain spots is distinct from using domain identities as training targets. Four-slice agreement scores use 14,243 annotated spots. The 12-slice evaluation contains 47,329 annotated spots for SpaRMA, STAligner, Harmony, and STAMP, and 47,322 for INSPIRE. Spatial maps omit spots without manual annotation and do not assign them an artificial domain. Each method’s three UMAP views use the same saved coordinates, colored by sample identity, manual annotation, or predicted domain.

3.3. Integration of Four Contiguous Human DLPFC Slices

In addition to the analyses shown in Figure 2 and Figure 3, we performed repeated method comparisons using common evaluation spots and unified downstream clustering. The evaluation sets contain 14,243 spots for DLPFC-4 and 47,322 for DLPFC-12. Clustering uses mclust EEE with seven clusters and clustering seed 42; training seeds are 42 and 2025, respectively. Input preparation follows the requirements of each method, with common gene sets used where applicable. Scores are pooled for DLPFC-4 and averaged equally across slices for DLPFC-12. Results and actual execution counts are reported in Supplementary Tables S3 and S4.
The four contiguous Sections (151673–151676) provide a test of whether integration can recover shared cortical organization without reducing the result to sample mixing alone. Evaluating domain assignments jointly across the four slices, SpaRMA achieved an ARI of 0.639, compared with 0.613 for SpaCross, 0.584 for STAligner, 0.568 for INSPIRE, and 0.417 for Harmony. Its NMI and ACC were 0.727 and 0.803, respectively, also the highest among the methods shown in Figure 2. The combined evaluation and slice-level distributions are presented in Figure 2A,C.
Repeated comparisons under the common evaluation protocol further support the spatial-domain identification performance of SpaRMA on DLPFC-4 (Supplementary Table S3).
The biological relevance of this agreement is reflected in the placement of the recovered domains. SpaRMA preserved the superficial-to-deep cortical ordering and the separation of white matter across adjacent sections, including the locally different geometry of slice 151675. The displayed SpaRMA maps contain more contiguous cortical bands and fewer visually scattered assignments within these bands than the Harmony maps, making the laminar organization easier to distinguish. STAligner and SpaCross also produced continuous cortical regions, but their local assignments differed from the manual annotations near superficial and deep-layer regions. Thus, the quantitative advantage of SpaRMA is accompanied by recovery of the shared cortical arrangement, rather than continuity alone (Figure 2A).
In the SpaRMA embedding, interspersed slice identities coexist with cortical and white-matter distinctions, whereas Harmony shows greater overlap among annotated layers. Together with spatial organization and annotation agreement, this supports alignment of comparable regions while retaining anatomical distinctions (Figure 2B).

3.4. Integration of Twelve Human DLPFC Slices

Cross-donor integration introduces a different challenge: cortical organization must remain recognizable despite changes in tissue outline, coverage, and layer widths. The 12 sections from three donors therefore test whether the common representation can accommodate anatomical variation beyond adjacent sections from one donor.
In the twelve-slice comparison shown in Figure 3, SpaRMA achieved an ARI of 0.5075, compared with 0.4161 for INSPIRE, 0.3965 for STAligner, 0.2960 for Harmony, and 0.2347 for STAMP. Its NMI and ACC were 0.6303 and 0.6881, respectively (Figure 3A). These results support the ability of SpaRMA to recover annotated spatial domains across the three donors.
Repeated comparisons further support the spatial-domain identification performance of SpaRMA across the twelve slices, with complete results provided in Supplementary Table S4.
The cross-donor advantage is accompanied by recovery of cortical organization in different tissue layouts. In slices 151673–151676, SpaRMA retained the curved cortical ordering and white-matter region, with a recognizable Layer 4 band between Layers 3 and 5 at the position indicated by the manual annotations. In slices 151507–151510, the recovered domains followed the more oblique cortical bands. Slices 151669–151672 extend the comparison to a different tissue outline and broader superficial regions. STAligner and INSPIRE also recovered broad bands, whereas the displayed Harmony and STAMP assignments were more spatially interspersed. These observations connect the higher annotation-agreement scores to preservation of recognizable cortical organization across donors (Figure 3B).
Donor overlap in the SpaRMA embedding coexisted with broad cortical and white-matter distinctions, supporting the interpretation that the shared representation accommodates donor variation while retaining major anatomical organization. The corresponding Harmony embedding showed substantial overlap among annotated domains as well as among donors. This contrast reinforces the distinction between mixing samples and recovering a biologically organized common representation (Figure 3C).

3.5. Component Ablation Study

Complementary module ablations on DLPFC-4 and DLPFC-12 are reported in Supplementary Tables S1 and S2. Each configuration was evaluated over five repeated executions at a fixed training seed (42 for DLPFC-4 and 2025 for DLPFC-12). Values are reported as the mean and sample standard deviation. DLPFC-4 annotation-agreement scores are pooled across slices; DLPFC-12 scores are calculated per slice and averaged with equal weights. The full model achieved the highest mean ARI, NMI, and ACC among the four configurations in both settings, supporting the combined contribution of masked reconstruction and multi-positive attention. Graph iLISI is computed from 50 embedding-space nearest neighbors: the inverse Simpson diversity of batch identities is calculated for each spot and averaged across spots. The identities are slices in DLPFC-4 and donors in DLPFC-12.

3.6. Integration of Mouse Embryo Slices Across Developmental Stages

We next examined whether integration could identify spatially organized domains across sagittal mouse embryo slices from E9.5 to E12.5, where tissue size, geometry, and composition change substantially. Louvain clustering at resolution 0.4 yielded 15 spatial domains with regionally organized assignments within each section (Figure 4B). Published tissue annotations provided an anatomical reference (Figure 4A), and tissue names were assigned after training using spatial correspondence and marker expression.
Figure 4. Integration of sagittal mouse embryo slices across four developmental stages. (A) Published tissue annotations at E9.5, E10.5, E11.5, and E12.5, corresponding to samples E9.5_E1S1, E10.5_E2S1, E11.5_E1S1, and E12.5_E1S1, respectively. (B) Spatial domains inferred from the integrated representation; tissue identities are assigned only during post-training interpretation. (C) Common UMAP colored by developmental stage. (D) Spatial concordance between four representative inferred domains and selected tissue-associated marker-gene expression: forebrain with Sox2, liver with Trf, heart with Myl7, and muscle with Myog. In each pair of rows, the upper row highlights the interpreted domain and the lower row shows marker expression. (E) Marker-gene expression summary for the four interpreted domains. Panels D and E describe the expression patterns used in tissue interpretation rather than independent validation of the assigned tissue names. Color denotes the domain-versus-rest log 2 fold change, and point size denotes the percentage of spots in which the gene is detected.
Spots from the four developmental stages overlapped in the common UMAP (Figure 4C). To interpret the biological organization of this shared representation, we examined whether the inferred domains localized to anatomically plausible regions and exhibited corresponding tissue-associated expression patterns.
Four representative domains showed spatial correspondence with tissue-associated markers (Figure 4D). The forebrain-interpreted domain occupies part of the anterior neural region and overlaps with Sox2 expression, although the expression extends beyond the highlighted domain. The heart-interpreted region shows localized correspondence with Myl7, while the liver and muscle comparisons show localized Trf and Myog expression, respectively. The varying extent of marker expression across sections indicates that these genes provide complementary evidence for domain interpretation rather than exact domain boundaries.
Gene panels described the expression profiles of the four interpreted domains (Figure 4E). The matching domain–gene groups generally show positive domain-versus-rest log-fold changes, while detection percentages vary among genes. Together with the spatial marker maps, these expression profiles describe the basis for the tissue interpretations of the four representative domains. Because marker expression also informed domain naming, these panels characterize the named domains rather than provide independent validation of their identities.

4. Discussion

SpaRMA organizes graph-based multi-slice integration into two training stages. Masked spot reconstruction introduces controlled missingness during pretraining and requires the graph model to infer a spot profile from local context. Multi-positive attention replaces a single positive constraint with a weighted set of candidate constraints during cross-slice alignment.
The two modules target complementary sources of instability. Masked reconstruction exposes the encoder to controlled loss of complete spot profiles and requires spatial context to support their recovery. Multi-positive attention reduces dependence on one selected cross-slice match by distributing the alignment objective across several weighted candidates. In both DLPFC settings, the full model had the highest mean ARI, NMI, and ACC among the four ablation configurations over five repeated executions; the full model also had the highest mean Graph iLISI among these configurations. Together with the DLPFC-4 and DLPFC-12 comparisons, these results support the value of combining contextual reconstruction with multi-candidate alignment for spatial-domain representation.
Several questions remain for further study. Complete-row masking introduces a controlled loss of spot-level information; evaluating a wider range of gene-level noise, missingness patterns, and spatial distortions would clarify the robustness of the learned representations. Integration also depends on spatial-graph quality and the availability of cross-slice correspondences, particularly when tissue overlap is limited. The main DLPFC figures present selected-run results, whereas the repeated ablations characterize performance variation across runs. Matched comparisons should be interpreted with the reported method-specific inputs and repeat designs; the selected-run panels do not establish performance superiority across every execution. Graph construction and correspondence searches may also increase computational cost for larger datasets. For the embryo analysis, pathway- and trajectory-level validation would extend the biological interpretation beyond the representative spatial domains and marker profiles examined here.
  • Computational cost and scalability.
Training operates on the concatenated graph in full-batch mode. In the measured RTX 4090 tasks, the four-slice and twelve-slice SpaRMA runs required 226.69 and 686.81 s, with sampled process GPU-memory peaks of 6.373 and 19.822 GiB, respectively. These measurements include cached input loading, training, and in-program evaluation, but exclude external data preparation and registration. The embryo experiments included 95,896 spots. Memory is required for node representations, graph edges, training activations, and cross-slice candidate correspondences. Limiting the number of retained positive candidates controls one component of this cost but does not remove the full-graph memory requirement. Application to larger datasets would require evaluating graph partitioning or sampling while preserving cross-slice correspondences; performance and resource requirements at those scales have not been established here.

5. Conclusions

SpaRMA combines masked spot reconstruction with multi-positive attention for robust graph-based multi-slice ST integration. The first module uses spatial context to reconstruct masked spot profiles, and the second distributes alignment constraints across several cross-slice positive candidates. The DLPFC experiments and repeated ablations support the combined contribution of contextual reconstruction and multi-candidate alignment. The mouse embryo analysis further identified regionally organized domains with tissue-associated marker patterns. These results support the value of the two-stage design for maintaining major anatomical organization while learning a shared representation across the evaluated slices.

Supplementary Materials

The following supporting information can be downloaded at: https://www.mdpi.com/article/10.3390/biology15232241/s1, Supplementary Sections S1.1–S1.4 describe the ablation design, model and training parameters, evaluation metrics, and ablation results. Supplementary Tables S1 and S2 report the component-wise ablation results for DLPFC-4 and DLPFC-12, respectively. Supplementary Section S2 and Tables S3 and S4 report the repeated method comparisons on DLPFC-4 and DLPFC-12.

Author Contributions

H.P. conceived and supervised the project. S.Y. co-supervised the study and contributed to the study design. J.Y. and X.Z. designed the SpaRMA framework. J.Y. implemented the algorithm and performed the experiments. R.D. contributed to data curation and validation. A.Z. and A.K. contributed to validation and manuscript revision. J.Y. and X.Z. wrote the initial manuscript. S.Y. and H.P. revised and finalized the manuscript. S.Y. and H.P. acquired funding. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the National Natural Science Foundation of China (Grant No. 62502421), the Yunnan Research Project (Grant Nos. 202501AU070058, 202301AU070194, and 202401AT070614), the Yunnan Academician and Expert Workstation Project (Grant No. 202505AF350053), and the Yunnan International Joint Laboratory of Cross-Border Data Governance (Grant No. 202403AP140021).

Institutional Review Board Statement

Not applicable.

Data Availability Statement

The human DLPFC dataset is available through the spatialLIBD resource at http://research.libd.org/spatialLIBD/ (accessed on 1 November 2026). The mouse embryo dataset is available through the MOSTA resource at https://db.cngb.org/stomics/mosta/ (accessed on 1 November 2026). The source code is available at https://github.com/lucky111223/SpaRMA (accessed on 1 November 2026).

Acknowledgments

During the preparation of this manuscript, the authors used OpenAI’s ChatGPT (model version not recorded) and Codex (GPT-6-astra) and Google’s Gemini (3.1 Pro) to assist with language editing, code inspection, and debugging. All AI-assisted outputs were critically reviewed and verified by the authors. These tools were not used to generate experimental data or to independently determine the scientific interpretations or conclusions. The authors take full responsibility for the content of the manuscript.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Ståhl, P.L.; Salmén, F.; Vickovic, S.; Lundmark, A.; Navarro, J.F.; Magnusson, J.; Giacomello, S.; Asp, M.; Westholm, J.O.; Huss, M.; et al. Visualization and analysis of gene expression in tissue sections by spatial transcriptomics. Science 2016, 353, 78–82. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  2. Chen, A.; Liao, S.; Cheng, M.; Ma, K.; Wu, L.; Lai, Y.; Qiu, X.; Yang, J.; Xu, J.; Hao, S.; et al. Spatiotemporal transcriptomic atlas of mouse organogenesis using DNA nanoball-patterned arrays. Cell 2022, 185, 1777–1792.e21. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  3. Stickels, R.R.; Murray, E.; Kumar, P.; Li, J.; Marshall, J.L.; Di Bella, D.J.; Arlotta, P.; Macosko, E.Z.; Chen, F. Highly sensitive spatial transcriptomics at near-cellular resolution with Slide-seqV2. Nat. Biotechnol. 2021, 39, 313–319. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  4. Chen, K.H.; Boettiger, A.N.; Moffitt, J.R.; Wang, S.; Zhuang, X. Spatially resolved, highly multiplexed RNA profiling in single cells. Science 2015, 348, aaa6090. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  5. Korsunsky, I.; Millard, N.; Fan, J.; Slowikowski, K.; Zhang, F.; Wei, K.; Baglaenko, Y.; Brenner, M.; Loh, P.R.; Raychaudhuri, S. Fast, sensitive and accurate integration of single-cell data with Harmony. Nat. Methods 2019, 16, 1289–1296. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  6. Stuart, T.; Butler, A.; Hoffman, P.; Hafemeister, C.; Papalexi, E.; Mauck, W.M.; Hao, Y.; Stoeckius, M.; Smibert, P.; Satija, R. Comprehensive integration of single-cell data. Cell 2019, 177, 1888–1902.e21. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  7. Hao, Y.; Hao, S.; Andersen-Nissen, E.; Mauck, W.M.; Zheng, S.; Butler, A.; Lee, M.J.; Wilk, A.J.; Darby, C.; Zager, M.; et al. Integrated analysis of multimodal single-cell data. Cell 2021, 184, 3573–3587.e29. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  8. Haghverdi, L.; Lun, A.T.; Morgan, M.D.; Marioni, J.C. Batch effects in single-cell RNA-sequencing data are corrected by matching mutual nearest neighbors. Nat. Biotechnol. 2018, 36, 421–427. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  9. Hie, B.; Bryson, B.; Berger, B. Efficient integration of heterogeneous single-cell transcriptomes using Scanorama. Nat. Biotechnol. 2019, 37, 685–691. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  10. Zeira, R.; Land, M.; Strzalkowski, A.; Raphael, B.J. Alignment and integration of spatial transcriptomics data. Nat. Methods 2022, 19, 567–575. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  11. Zhong, C.; Ang, K.S.; Chen, J. Interpretable spatially aware dimension reduction of spatial transcriptomics with STAMP. Nat. Methods 2024, 21, 2072–2083. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  12. Long, Y.; Ang, K.S.; Li, M.; Chong, K.L.K.; Sethi, R.; Zhong, C.; Xu, H.; Ong, Z.; Sachaphibulkij, K.; Chen, A.; et al. Spatially informed clustering, integration, and deconvolution of spatial transcriptomics with GraphST. Nat. Commun. 2023, 14, 1155. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  13. Liu, W.; Liao, X.; Luo, Z.; Yang, Y.; Lau, M.C.; Jiao, Y.; Shi, X.; Zhai, W.; Ji, H.; Yeong, J.; et al. Probabilistic embedding, clustering, and alignment for integrating spatial transcriptomics data with PRECAST. Nat. Commun. 2023, 14, 296. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  14. Guo, T.; Yuan, Z.; Pan, Y.; Wang, J.; Chen, F.; Zhang, M.Q.; Li, X. SPIRAL: Integrating and aligning spatially resolved transcriptomics data across different experiments, conditions, and technologies. Genome Biol. 2023, 24, 241. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  15. Wang, G.; Zhao, J.; Yan, Y.; Wang, Y.; Wu, A.R.; Yang, C. Construction of a 3D whole organism spatial atlas by joint modelling of multiple slices with deep neural networks. Nat. Mach. Intell. 2023, 5, 1200–1213. [Google Scholar] [CrossRef] [Scilit]
  16. Dong, K.; Zhang, S. Deciphering spatial domains from spatially resolved transcriptomics with an adaptive graph attention auto-encoder. Nat. Commun. 2022, 13, 1739. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  17. Zhou, X.; Dong, K.; Zhang, S. Integrating spatial transcriptomics data across different conditions, technologies and developmental stages. Nat. Comput. Sci. 2023, 3, 894–906. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  18. Fang, D.; Min, W. SpaCross deciphers spatial structures and corrects batch effects in multi-slice spatially resolved transcriptomics. Commun. Biol. 2025, 8, 1393. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  19. Li, A.; Wang, R.; Duan, X.; Dai, Q. DGAE: Dynamic graph convolutional network for multi-slice spatial transcriptomics alignment and enhancement. IEEE Trans. Comput. Biol. Bioinform. 2026, 23, 1427–1439. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  20. Feng, Y.; Xiao, S.; Zhou, G.; Ding, W.; Yang, B.; Guo, Y.; Huang, X.; Zhou, Y.; Jin, S. STGAT: Spatial domain identification of consecutive slices based on graph contrastive learning. Brief. Bioinform. 2026, 27, bbag407. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  21. Zhao, J.; Zhang, X.; Wang, G.; Lin, Y.; Liu, T.; Chang, R.B.; Zhao, H. Interpretable, flexible and spatially aware integration of multiple spatial transcriptomics datasets from diverse sources. Nat. Genet. 2026, 58, 1138–1150. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  22. Hou, Z.; Liu, X.; Cen, Y.; Dong, Y.; Yang, H.; Wang, C.; Tang, J. GraphMAE: Self-supervised masked graph autoencoders. In Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, Washington, DC, USA, 14–18 August 2022; pp. 594–604. [Google Scholar] [CrossRef] [Scilit]
  23. Min, W.; Fang, D.; Chen, J.; Zhang, S. SpaMask: Dual masking graph autoencoder with contrastive learning for spatial transcriptomics. PLoS Comput. Biol. 2025, 21, e1012881. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  24. Hu, Y.; Lin, Z.; Xie, M.; Yuan, W.; Li, Y.; Rao, M.; Liu, Y.H.; Shen, W.; Zhang, L.; Zhou, X.M. MaskGraphene: An advanced framework for interpretable joint representation for multi-slice, multi-condition spatial transcriptomics. Genome Biol. 2025, 26, 380. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  25. Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, L.; Polosukhin, I. Attention is all you need. In Proceedings of the Advances in Neural Information Processing Systems, Long Beach, CA, USA, 4–9 December 2017; Volume 30, pp. 5998–6008. [Google Scholar]
  26. Wang, X.; Han, X.; Huang, W.; Dong, D.; Scott, M.R. Multi-similarity loss with general pair weighting for deep metric learning. In Proceedings of the 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition, Long Beach, CA, USA, 16–20 June 2019; pp. 5017–5025. [Google Scholar] [CrossRef] [Scilit]
  27. Scrucca, L.; Fop, M.; Murphy, T.B.; Raftery, A.E. mclust 5: Clustering, classification and density estimation using Gaussian finite mixture models. R J. 2016, 8, 289–317. [Google Scholar] [CrossRef] [Scilit]
  28. Maynard, K.R.; Collado-Torres, L.; Weber, L.M.; Uytingco, C.; Barry, B.K.; Williams, S.R.; Catallini, J.L.; Tran, M.N.; Besich, Z.; Tippani, M.; et al. Transcriptome-scale spatial gene expression in the human dorsolateral prefrontal cortex. Nat. Neurosci. 2021, 24, 425–436, Correction in Nat. Neurosci. 2021, 24, 612. https://doi.org/10.1038/s41593-021-00817-5. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  29. Blondel, V.D.; Guillaume, J.L.; Lambiotte, R.; Lefebvre, E. Fast unfolding of communities in large networks. J. Stat. Mech. Theory Exp. 2008, 2008, P10008. [Google Scholar] [CrossRef] [Scilit]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.