Skip to main content
Cell Reports Methods logoLink to Cell Reports Methods
. 2026 Jul 17;6(9):101530. doi: 10.1016/j.crmeth.2026.101530

SpaDiff denoises sequence-based spatial transcriptomics via diffusion process

Jiazhang Cai 1, Yongkai Chen 2, Luyang Fang 1, Xinyi Liu 1, Wenxuan Zhong 1,∗, Guo-Cheng Yuan 3,∗∗, Ping Ma 1,4,∗∗∗
PMCID: PMC13615491  PMID: 42468536

Summary

Spot-swapping in sequence-based spatial transcriptomics redistributes RNA molecules across neighboring spots, distorting spatial gene expression and biasing downstream analysis. We introduce SpaDiff, a mass-conserving denoising framework that corrects this artifact through score-guided reverse diffusion. Across simulated and real spatial transcriptomics datasets, SpaDiff consistently improves the recovery of spatial gene-expression distributions. In particle-level simulations with known ground truth, SpaDiff robustly restores gene-level spatial patterns across diverse contamination regimes. In real tissues, SpaDiff relocalizes misplaced transcripts in human-mouse chimeric samples, improves spatial-domain recovery in human dorsolateral prefrontal cortex, and preserves local tumor heterogeneity while sharpening regional structure in colorectal cancer. These results show that SpaDiff improves the spatial accuracy of gene expression and supports more accurate downstream analyses such as clustering and spatial domain identification.

Keywords: sequence-based spatial transcriptomics, spatial transcriptomics, data denoising, diffusion process, score-based diffusion, spot swapping

Graphical abstract

graphic file with name ga1.webp

Highlights

  • •

    SpaDiff denoises spatial transcriptomics via mass-conserving reverse diffusion

  • •

    Score-based ODE corrects spot-swapping while preserving total UMI counts exactly

  • •

    Outperforms five state-of-the-art denoisers on simulated and three real datasets

  • •

    Sharpens spatial domains without erasing within-region tumor heterogeneity

Motivation

Sequence-based spatial transcriptomics is affected by spot-swapping, in which RNA molecules diffuse from their original locations and are captured by neighboring spots, reducing spatial specificity and biasing downstream analyses. SpaDiff addresses this problem by formulating spot-swapping as a diffusion process and reversing it through a deterministic probability-flow ODE with a mass-conserving score-based transport mechanism.


Sequence-based spatial transcriptomics suffers from spot-swapping, where RNA molecules drift to neighboring spots and blur tissue patterns. Cai et al. introduce SpaDiff, a diffusion-based denoiser that reverses this spreading along a learned spatial gradient. It sharpens tissue domains, preserves total molecular counts exactly, and recovers within-region heterogeneity that other methods erase.

Introduction

Spatial transcriptomics has emerged as a pivotal technology for mapping gene expression within intact tissue architecture, revealing fundamental mechanisms in brain function, cancer progression, and cellular differentiation processes.1,2,3,4,5 Unlike single-cell RNA-seq, spatial transcriptomics preserves the spatial context, enabling direct analysis of cellular niches, tissue organization, and cell-cell communication.6 Commercialization through platforms has accelerated the widespread adoption of spatial transcriptomics, highlighting the need for high-quality data to maintain biological fidelity.7

However, there is a notable phenomenon associated with the sequencing-based spatial transcriptomics technology called spot-swapping,8 where RNA molecules diffuse from their original locations to adjacent spots on a tissue slide (Figure 1A). This phenomenon distorts spatial information, misinterpreting transcripts from neighboring cells as from the same cells, which, in turn, can cause significant errors in downstream analyses, such as cell-type annotation, co-localization analysis, and cell-cell interactions. A particularly compelling demonstration of spot-swapping was presented by Ni et al.,8 who used human-mouse chimeric tissue samples to reveal extensive cross-contamination between spatial spots. Their experiment showed that species-specific transcripts were detected in off-tissue or mismatched regions, providing clear evidence of RNA molecule diffusion across spot boundaries. As such, it is important to develop effective computational denoising strategies to alleviate the spot-swapping problem.

Figure 1.

Figure 1

Introduction to the spot-swapping phenomenon and SpaDiff algorithm

(A) Schematic of the spot-swapping phenomenon, in which RNA molecules originating from an expected capture region are captured not only by the spatially matched spot but also by neighboring spots.

(B) Schematic of the SpaDiff reverse-diffusion process, which transports observed spot-swapped counts toward a denoised spatial expression pattern.

Although several methods have been developed to denoise gene expression data, they exhibit important limitations. Earlier approaches were originally designed for single-cell RNA-seq data, which do not have spatial information,9,10,11,12,13 and therefore, are not suitable for spatial transcriptomics analysis. Recently, several methods have been developed specifically for spatial transcriptomics. Among these, SpotClean8 employs a probabilistic model to explicitly correct spot-to-spot contamination; SpotGF14 uses optimal transport to quantify spatial diffusion patterns and filter out highly diffused genes; MIST15 combines graph-based molecular region detection with region-specific low-rank matrix completion for imputation; Sprod16 uses latent graph learning based on spatial and imaging information to impute denoised expression; and MvDST17 leverages a deep autoencoder to learn a shared low-dimensional representation across modalities and reconstruct a stabilized expression matrix. These methods do not preserve total counts and primarily enhance spatial coherence or suppress diffuse signals without explicitly modeling the generative mechanism of RNA migration. Collectively, while some existing approaches are designed to address spot-swapping, they either fail to maintain quantitative integrity or do not model RNA diffusion as a physically grounded process.

Diffusion models have recently gained attention for their effectiveness in denoising complex, structured data.18,19 Unlike traditional smoothing methods that perform a one-shot kernel convolution, diffusion models iteratively invert a generative noise process by following a score field re-estimated from the current data distribution at each step, allowing them to recover structure rather than average it away.20,21,22 Motivated by these studies, we introduce SpaDiff, which models spot-swapping as a physical diffusion process by using a deterministic probability flow ordinary differential equation (ODE). SpaDiff represents the count matrix compactly as mass spots and estimates spatial density gradients through a two-level nonparametric score function that combines global and gene-specific information. The method strictly preserves total molecular counts throughout denoising, ensuring that no quantitative information is lost or amplified during the process. SpaDiff is illustrated in Figure 1B. We evaluate SpaDiff across four complementary settings. First, particle-level simulations calibrated to a 10× Xenium mouse brain dataset provide a controlled benchmark with known ground truth. Second, a human-mouse chimeric tissue, in which species-specific transcripts serve as an experimentally grounded reference, tests SpaDiff under extreme off-tissue contamination. Third, the 10× Visium human dorsolateral prefrontal cortex (DLPFC) dataset assesses whether denoising improves downstream clustering, spatial domain identification, and biomarker detection. Finally, a human colorectal cancer (CRC) Visium dataset examines whether SpaDiff preserves within-region biological heterogeneity that forward smoothers tend to erase, while conserving total molecular counts throughout. Across synthetic and real datasets, SpaDiff outperforms existing methods in spatial specificity, clustering accuracy, and biological signal preservation.

Results

SpaDiff models spot-swapping as mass-conserving reverse diffusion

SpaDiff addresses the spot-swapping artifact by casting denoising as a diffusion process that mirrors the underlying physical mechanism. The forward step models how the clean spatial expression of each gene is progressively corrupted by molecular diffusion until it resembles the observed noisy counts; the reverse step then runs this process backwards to recover the clean signal (Figure 1B). Figure 2 translates this schematic into a concrete algorithmic pipeline, which we walk through in the rest of this section.

Figure 2.

Figure 2

SpaDiff algorithm overview

Top: the input spot-by-gene count matrix is processed in parallel for each gene; a global score, computed once from the aggregate density of all genes, is combined with each gene-specific score to produce the denoised output per gene. Bottom (dashed box): detail of the per-gene processing path—the raw count field is converted to an estimated spatial density via kernel density estimation, from which the score function is computed; reverse diffusion along the score field yields the denoised count field.

The top part of Figure 2 shows SpaDiff’s parallel per-gene architecture. From the input spot-by-gene count matrix, a single global score is computed once from the aggregate density of all genes and serves as a shared physical context. In parallel, for each gene, a gene-specific score is computed from that gene’s own spatial distribution; the two are combined and used to drive a reverse-diffusion update that produces a denoised expression field for that gene. The per-gene outputs are then assembled into the final denoised count matrix. This two-level design reflects the physics of spot-swapping: because RNA diffusion depends on the local molecular density field rather than on gene-gene regulatory interactions, the shared physical context is naturally captured by the global score, while the gene-specific score adds focal specificity for abundantly expressed genes. An adaptive per-spot mixing weight (detailed in STAR Methods) interpolates between the two, deferring to the global score where a gene is locally sparse and to the gene-specific score where it is locally dense.

The dashed inset in the bottom part of Figure 2 details the per-gene denoising path. Starting from the raw count field, SpaDiff estimates the spatial probability density by kernel density estimation; the gradient of the log-density defines the score function, which points from low-density regions toward high-density ones. Reverse diffusion along this score field transports mass from contaminated spots back to their high-density origins, yielding the denoised count field. Intuitively, the score function acts as a restoring force that pulls each observed spot’s expression back toward where it most likely originated, reversing the stochastic drift introduced by spot-swapping during the forward process.

Unlike standard generative diffusion models, which start from pure white noise and reverse the full stochastic differential equation (SDE) to generate new samples, SpaDiff uses only the forward-reverse structure to relate the observed data to its clean counterpart and implements the reverse step as the deterministic probability-flow ODE22 (σ = 0 in the update). This design makes the output fully reproducible across runs, contracts mass monotonically toward high-density regions, and requires no paired training data or a large neural network.

SpaDiff restores gene-level spatial distributions under controlled contamination

To evaluate SpaDiff under controlled conditions in which the clean signal is known, we built a particle-level simulation framework calibrated against a public 10× Xenium mouse brain dataset.23 Unlike earlier benchmarks that model spot-level contamination as a convolution on a pre-defined spot grid, we operate at the level of individual transcripts (Figure 3A). Every molecule in the Xenium slide carries a two-dimensional coordinate; aggregating these coordinates onto a hexagonal Visium-like lattice yields the spot-by-gene count matrix we treat as the ground truth. To emulate the diffusive cross-spot contamination that is characteristic of sequencing-based spatial assays, we then displace each transcript by an independent two-dimensional offset drawn from a symmetric zero-mean noise distribution with scale parameter σ, and re-aggregate the displaced particles onto the same lattice to produce the contaminated observation. Because the ground-truth counts are obtained by the same aggregation operator, any residual discrepancy after denoising is attributable solely to the injected contamination rather than to systematic differences in how ground truth and observation are constructed.

Figure 3.

Figure 3

Particle-level simulation and benchmarking of spot-level denoising methods

(A) Particle-level simulation workflow: ground-truth spot-level expression obtained by aggregating Xenium transcripts onto a hexagonal Visium-like grid.

(B) Median per-gene Jensen-Shannon divergence (JSD) between recovered and ground-truth expression as a function of σ, for Gaussian, Laplace, and Cauchy contamination. Lower JSD indicates better recovery of the ground-truth spatial expression pattern.

(C) Sensitivity of SpaDiff to the number of reverse-diffusion steps T at three representative Gaussian noise levels (σ = 110, 300, and 500).

See also Figures S1 and S2 and Table S1.

This particle-level formulation lets us vary two orthogonal axes of the noise model independently. The first axis is the magnitude of spatial blur, controlled by σ∈ {50, 110, 200, 300, 400, 500} μm, calibrated to the 10× Visium V1 spot geometry24 (100 μm center-to-center spot pitch, 55 μm spot diameter). The range spans from mild contamination, σ = 50 μm, about half a spot pitch, in which most transcripts remain within their source spot, to severe contamination, σ = 500 μm, roughly five spot pitches, in which transcripts routinely escape their source spot and reach second- or third-ring neighbors. The second axis is the tail behavior of the blur kernel: we consider a Gaussian (light-tailed), Laplace (intermediate), and Cauchy (heavy-tailed) displacement distribution, reflecting the spectrum of physical and chemical processes thought to drive spot-swapping in practice. The resulting 6 σ × 3 distributions = 18 benchmark cells jointly cover mild, moderate, and extreme contamination under both well-behaved and outlier-prone noise. We acknowledge that this design does not perfectly mimic real-world spot-swapping. As characterized in the original SpotClean study,8 real spot-swapping arises from a combination of biophysical processes, RNA diffusion during permeabilization, capture chemistry, and section geometry, and its displacement distribution is not fully characterized. The three kernels we use cover a physically meaningful range: Gaussian corresponds to pure Brownian diffusion, Laplace to heterogeneous diffusion with heavier tails, and Cauchy to rare, long-range leakage events at tissue boundaries. The real-data experiments in subsequent sections provide complementary evidence of robustness, since the contamination mechanism in those settings is not constrained to any analytic kernel.

We benchmarked SpaDiff against four published methods designed for spot-level denoising or deconvolution, including SpotClean,8 Sprod,16 MvDST,17 and MIST.15 SpotGF14 is excluded here because it acts as a per-gene filter, where its output coincides with the raw input on retained genes, making it uninformative under per-gene Jensen-Shannon divergence (JSD)25. We include SpotGF in the chimeric and CRC benchmarks below, where metrics integrate across genes. We used median per-gene JSD25 to the ground truth as the primary metric, restricted to the 145 genes with at least ten total counts. Across the 18 benchmark samples, SpaDiff attains the lowest JSD on 16/18 (Figure 3B); the two exceptions arise at the highest Cauchy noise level, where Sprod narrowly edges SpaDiff and both methods approach a shared performance floor dictated by the heavy-tailed contamination itself. MIST and MvDST, which rely on region-specific low-rank imputation and multiview autoencoder-based reconstruction, respectively, rather than an explicit RNA diffusion model, fail to improve on the raw input at moderate σ and only marginally reduce JSD at the extreme σ. SpotClean is competitive in the Gaussian regime, the noise family for which it was originally developed, but degrades sharply under heavier-tailed contamination (Laplace, and especially Cauchy), because its fixed-bandwidth spot-swapping likelihood cannot accommodate the long-range outlier transfers that dominate those regimes. Sprod tracks SpaDiff most closely, but remains within 5%–15% of SpaDiff’s JSD at low and moderate σ and only matches or narrowly beats it when contamination is so severe that the remaining recoverable signal is small for every method; as we show in the following section, this apparent parity does not carry over to real Visium tissue.

A practical concern with any iterative reverse-diffusion procedure is whether the recovered expression depends sensitively on the number of integration steps T. Figure 3C shows that SpaDiff does not. With the default exponentially decaying step-size schedule, the per-step drift collapses geometrically, so the mass-spot distribution approaches a well-defined fixed point within a handful of iterations regardless of the noise level, and additional steps neither overshoot the ground truth nor degrade it. The normalized distance to plateau drops below 0.1 by T ≈ 3 for all three sigmas tested and is indistinguishable from zero by T = 5. In all subsequent analyses, we, therefore, use T = 5 as the default, which trades a negligible amount of residual drift for a substantial reduction in runtime relative to the T = 15 plateau. Robustness extends to other hyperparameters (Figure S2).

Together, these results establish that SpaDiff matches or outperforms state-of-the-art spot-level denoising methods across a wide range of contamination magnitudes and kernel shapes and that its recovered expression is robust to the choice of the integration depth T. These controlled benchmarks establish how SpaDiff behaves under quantifiable contamination. The subsequent real-tissue experiments test whether these properties extend to settings in which the contamination mechanism is more complex and ground truth is unavailable.

SpaDiff relocalizes misplaced transcripts in human-mouse chimeric tissue

To evaluate the effectiveness of SpaDiff in correcting spatial transcriptomics noise under controlled conditions, we tested the model on human-mouse chimeric tissue samples from the study by Ni et al.8 This dataset presents a unique experimental setup where human and mouse tissues are intentionally mixed within the same spatial transcriptomics slide. As shown in Figure 4A, the dataset provides experimentally derived ground truth annotations, clearly delineating human-only, mouse-only, and mixed tissue regions. Unlike most spatial transcriptomics datasets, which rely on indirect or manual annotation based on histology and marker gene expression, this dataset enables direct and objective validation of denoising performance. It is particularly valuable for assessing spot-swapping artifacts, as UMI molecules originating in one species that are captured in the other provide clear indicators of cross-contamination.

Figure 4.

Figure 4

Performance of SpaDiff on the human-mouse chimeric tissue

(A) Ground-truth annotation of tissue regions: mouse-only (blue), human-only (red), and mixture spots.

(B) Spatial distribution of total human-specific (top, red) and mouse-specific (bottom, blue) transcripts per spot in the raw data (left) and after SpaDiff denoising (right).

(C) Per-gene fraction of reads falling on in-tissue spots, before (gray) and after (red) SpaDiff denoising, shown for all genes (left), human genes (middle), and mouse genes (right).

See also Figure S3 and Tables S2 and S6.

In conventional preprocessing pipelines, UMI counts detected outside the tissue-covered regions are often excluded under the assumption that they represent noise. However, recent work8 has shown that a non-negligible portion of off-tissue UMI counts may originate from the tissue itself, likely due to spot-swapping or diffusion effects. Discarding these signals risks losing genuine biological information and can introduce systematic bias, especially if spot-swapping affects marker gene localization. By explicitly modeling and correcting for this diffusion, SpaDiff preserves signal integrity across the full slide, improving downstream accuracy.

Figure 4B visualizes the aggregate spatial distribution of all human- and mouse-specific transcripts before and after SpaDiff denoising. In the raw data, substantial cross-compartment contamination is evident: human-specific transcripts appear throughout mouse tissue and in off-tissue regions, and vice versa, with 25.4% of total counts falling outside annotated tissue. After SpaDiff denoising, off-tissue counts drop to 9.7%, a 62% reduction, and each species’ transcripts become sharply confined to their correct tissue compartment. Crucially, because SpaDiff’s mass-transport dynamics strictly conserve total molecular counts, off-tissue reads are not discarded but are actively repositioned to biologically consistent tissue locations, a capability unique to our physics-based formulation. A small fraction of non-conforming spots persists after denoising. SpaDiff is designed to invert the diffusive component of contamination; noise sources outside this forward model, such as read mis-mapping between homologous human and mouse sequences, sequencing or barcode artifacts, and local imperfections in the tissue annotation, are non-diffusive in origin and, therefore, lie beyond the scope of a spot-swapping correction. Their persistence after denoising is consistent with SpaDiff acting specifically on the diffusive part of the noise budget, leaving non-diffusive contributions unchanged.

To evaluate performance quantitatively, we computed for each gene the fraction of total reads falling on in-tissue spots (Figure 4C). Across all 9,686 genes with ≥10 total counts, the median in-tissue fraction increased from 0.74 in the raw data to 0.91 after SpaDiff (paired Wilcoxon signed-rank, p < 1 × 10-4). Stratifying by species, human genes (n = 2,373) improved from 0.92 to 0.98 and mouse genes (n = 7,313) from 0.73 to 0.89, with both shifts statistically significant. The larger gain observed for mouse genes reflects their greater baseline off-tissue scatter in the raw data and demonstrates that SpaDiff’s denoising effect scales with the severity of spot-swapping rather than being dominated by any particular subset of genes.

To benchmark SpaDiff against existing denoising methods, we restricted the comparison to in-tissue spots, where all methods operate, and evaluated five alternatives: MIST,15 MvDST,17 Sprod,16 SpotClean,8 and SpotGF.14 Three metrics are reported: per-gene purity, the mean fraction of a gene’s reads localized to the correct species tissue averaged across genes; cross-species contamination rate (CSCR), the fraction of total reads assigned to the wrong species tissue; and classification accuracy against the ground-truth species label of each spot. As summarized in Table S6, SpaDiff achieved the highest per-gene purity (0.820), while the next-best score was 0.711 from SpotGF, demonstrating a 15.3 percentage-point absolute gain and the lowest cross-species contamination rate (CSCR = 0.039), which was a 69% reduction relative to raw data at 0.125 and 46% below the next-best method MvDST at 0.073. Classification accuracy was competitive (0.878), trailing only MvDST (0.894) by 1.6 percentage points. By contrast, Sprod and SpotClean showed little to no classification improvement over the raw data. SpotGF requires a separate note: unlike the other four methods, it performs gene-level filtering rather than per-gene reconstruction, retaining raw counts on every gene that passes its filter and removing the rest entirely. Its purity (0.711), therefore, reflects gene selection rather than denoising on a per-gene basis, and the metric is computed on a different effective gene set than for the other methods; its elevated human-spot sensitivity correspondingly arose from a biased tendency to predict human rather than a genuine per-gene denoising gain. These results demonstrate that SpaDiff uniquely achieves both high spatial purity and genuine cross-species decontamination, while other methods produce at best modest improvements on either axis alone.

In summary, the human-mouse chimeric dataset offers a rare opportunity to validate spatial denoising against a known ground truth. SpaDiff’s mass-conserving score-based formulation addresses both axes of the spot-swapping problem at once: the algorithm actively relocates off-tissue contamination back into the correct tissue compartment, a 62% reduction in off-tissue counts relative to raw data, while simultaneously attaining the highest per-gene purity (0.820) and the lowest cross-species contamination rate (0.039) among six methods benchmarked. These results show that SpaDiff can jointly achieve quantitative in-tissue fidelity and the spatial redistribution of off-tissue mass, with the total molecular count strictly preserved throughout, which establishes it as a principled tool for preprocessing spatial transcriptomics data in complex, artifact-prone tissue settings.

SpaDiff improves spatial-domain identification in human DLPFC tissue

To evaluate SpaDiff’s performance in a complex real-world setting, we applied it to a widely used sequence-based spatial transcriptomics dataset: the 10× Genomics Visium human DLPFC dataset from the Liber Institute for Brain Development (LIBD) study.26 This dataset consists of 12 tissue sections collected from three neurotypical adult donors. Each section was manually annotated into seven cytoarchitecturally defined regions, including six cortical layers (layers 1 through 6) and white matter (WM), on the basis of histological features and known gene expression markers. One annotated slice is shown in Figure 5A.

Figure 5.

Figure 5

Evaluation of SpaDiff on DLPFC datasets

(A) Manual annotation of one DLPFC tissue.

(B) Boxplot of adjusted Rand index (ARI) values for SpaGCN and Leiden clustering results across DLPFC tissue sections.

(C) SpaGCN domain-detection results on the original and SpaDiff- and SpotClean-denoised data for a representative tissue.

(D) Log fold change between white matter and layer 6 for selected biomarker genes.

(E) Negative log10 p values for the same genes.

See also Figure S4.

We assessed denoising effectiveness using two clustering strategies: Leiden27 and SpaGCN.28 Leiden, a widely used graph-based clustering algorithm, does not incorporate spatial information and thus, serves as a lower-bound benchmark. In contrast, SpaGCN is a spatially aware method that integrates gene expression with spatial context. We select SpaGCN as one representative example of existing spatial methods. This allows us to test whether SpaDiff can enhance downstream analyses regardless of the specific algorithm used. By including both a non-spatial baseline (Leiden) and a spatially informed approach (SpaGCN), we show that SpaDiff can improve results in both settings.

SpotClean is the only published method we compare against in this benchmark, because it is the only one whose design objective specifically targets the correction of spot-swapping noise. The other spatial denoising methods we evaluate elsewhere in this study (MIST, MvDST, Sprod, and SpotGF) are smoothing or imputation methods that primarily target improvements in clustering or other downstream analyses rather than spot-swapping correction. A head-to-head adjusted Rand index (ARI) comparison against those methods would, therefore, conflate two distinct objectives, generic spatial smoothing and spot-swapping correction, and would not measure what we wish to measure here. By restricting the comparison to SpotClean and SpaDiff, both of which share the same target objective, we obtain a clean test of whether explicit spot-swapping correction translates into improved clustering performance.

For each clustering method, we compared results from the original data, SpaDiff-denoised data, and SpotClean-denoised data against manual annotations using the ARI. As shown in Figure 5B, SpaDiff consistently achieved higher ARI scores than both the raw and SpotClean-denoised datasets under both Leiden and SpaGCN. For Leiden, the improvement from SpaDiff was substantial and highly significant. For SpaGCN, SpaDiff still outperformed the other two inputs, but the improvement compared with Leiden was smaller than the other two. This is because SpaDiff-denoised data already exhibited a relatively clear and well-defined spatial pattern, allowing even Leiden, which does not incorporate any spatial information, to achieve performance approaching that of SpaGCN. Silhouette, percentage of abnormal spots (PAS), and spatial CHAOS score (CHAOS), which evaluate clustering quality and spatial continuity, corroborate this pattern across all 12 sections (Figure S4).

Interestingly, SpotClean sometimes performed not as well as the raw data, particularly in tissues with higher technical noise. This may be attributed to its reliance on a parametric probabilistic model, which can be sensitive to model misspecification or data quality. In contrast, SpaDiff’s nonparametric diffusion-based framework imposes fewer assumptions on the data-generating process, allowing it to perform robustly across diverse conditions, including noisy or low-quality tissue sections such as those found in the DLPFC dataset.

To further evaluate biological interpretability, we examined domain detection using SpaGCN on a representative tissue section (Figure 5C). In SpaDiff-denoised data, spatial domains appeared more distinct and coherent, aligning more closely with manual annotations than either raw or SpotClean-denoised data.

We also quantified the ability to distinguish spatial regions by comparing the log fold change and statistical significance of known biomarker genes between WM and layer 626 on one representative tissue (Figure 5D and 5E). SpaDiff-denoised data exhibited larger log fold changes and smaller p values than both raw and SpotClean-denoised data, demonstrating its ability to amplify biologically meaningful differences between regions.

Overall, these results indicate that SpaDiff improves the quality of spatial transcriptomics data in a way that benefits a range of downstream analyses, from basic clustering without spatial information to spatially aware methods, while also producing data so well-structured that even non-spatial approaches can approach the performance of spatially informed methods.

SpaDiff preserves local tumor heterogeneity while sharpening regional structure

The chimeric and DLPFC datasets validated SpaDiff in regimes where the underlying biology is either species-resolved or aligned with manually annotated cortical layers. To evaluate SpaDiff in a tissue context where the relevant biology lives at finer resolution, below the regional compartment, and in the heterogeneity of cells within each region, we applied SpaDiff to a human colorectal cancer Visium dataset from Ni et al.8 The slide contains 4,992 spots with 3,138 in-tissue spots and 2,353 measured genes, annotated into five histological regions: normal periphery (NP, n = 1,503), normal core (NC, n = 863), tumor adjacent (TA, n = 362), tumor periphery (TP, n = 155), and tumor core (TC, n = 255) (Figure 6A). TC spots carry, on average, 1.73× the per-spot UMI of NC, reflecting the increased cellular density characteristic of tumor tissue. This cellularity differential creates a per-spot density gradient that any density-driven denoising algorithm, including SpaDiff, must navigate.

Figure 6.

Figure 6

Performance of SpaDiff on a human colorectal cancer Visium dataset

(A) Spot-level annotation of the five histological regions (normal periphery, normal core, tumor adjacent, tumor periphery, and tumor core).

(B) Spatial expression of MKI67 in tumor-region spots for the raw data and three denoised outputs (SpaDiff, Sprod, and SpotClean).

(C) SpaDiff iterative dynamics for MKI67 from step 0 to step T = 15.

(D) Mean log1p MKI67 expression across the five regions for raw data and denoised outputs.

See also Figures S5–S7 and Tables S3–S5.

Tumor microenvironments differ from the chimeric and layered settings in one critical way: each annotated region contains a spatial mix of biologically distinct cell states, proliferating and quiescent tumor cells coexisting within TC, invasive-front and interior cells coexisting within TP, and immune-infiltration patches interspersed throughout TA. Forward-smoothing methods can improve coarse regional classification by averaging within compartments, but in doing so, they erase precisely the within-region structure that defines tumor biology. We therefore evaluated SpaDiff against five baselines, MIST,15 MvDST,17 Sprod,16 SpotGF,14 and SpotClean,8 on a metric panel spanning three complementary axes: per-gene physics signature, including mass concentration via Gini coefficient and spatial autocorrelation via Moran’s I, on all 2,353 genes, between-region biology via tumor-marker AUROC for TC vs. NC, and within-region biology via sub-region AUROC for TC vs. TP+TA, and within-TC variance preservation.

Across the panel of methods, SpaDiff produces a uniquely uniform per-gene physics signature. On 95% of all 2,353 genes, the per-gene Gini coefficient increases, reflecting more concentrated mass in fewer spots; on 100%, Moran’s I increases, reflecting closer resemblance between neighboring spots; and on 92%, the inter-region/intra-region F-statistic increases, reflecting cleaner separation of the five anatomical regions. No competing method exceeds 60% on more than two of these three axes simultaneously. MIST achieves 100% Gini gain but only 24% F-ratio gain, an artifact of low-rank imputation that creates synthetic spike patterns rather than recovering biological structure, which is confirmed by its 1.7×105 within-TC variance ratio. Sprod and MvDST achieve high Moran’s I improvements (∼99% and ∼100%, respectively), but Sprod’s Gini drops to 0% positive and MvDST’s to 39%, the signature of forward smoothers that homogenize within compartments. An extended scorecard including sub-region metrics is reported in Table S3.

The biological consequence of these algorithmic differences is most visible at the within-TC scale. Figure 6B maps the proliferation marker MKI67 across tumor-region spots for the raw data and three denoising methods. Within TC, SpaDiff preserves and sharpens a patchy distribution of MKI67-high spots that mark actively proliferating subzones, whereas Sprod averages neighboring values into a near-uniform field. This contrast is captured quantitatively by two columns of Table 1. The sub-region AUROC (TC vs. TP+TA), which tests whether within-tumor heterogeneity is preserved, is 0.581 for SpaDiff, a gain over both the raw data (0.513) and the next-best methods Sprod (0.528) and SpotClean (0.527). The within-TC variance ratio, defined as the variance after denoising divided by the variance in raw data on tumor-marker genes, is 2.47 for SpaDiff, indicating that within-region heterogeneity is preserved and sharpened; for Sprod, it is 0.38, meaning that 62% of within-region variance, precisely the patchy structure visible in Figure 6B, is destroyed. AUROC stratified by marker category shows improvement on tumor markers (+0.046) (Figure S5).

Table 1.

Performance on human colorectal cancer tissue

Method Gini%+a Moran%+a F-ratio%+a AUROC (TC vs. NC)b AUROC (TC vs. TP+TA)c VarRatio TCd
Original – – – 0.783 0.513 1.00
MIST 100% 78% 24% 0.799 0.511 1.7×105
MvDST 39% 100% 63% 0.658 0.409 0.13
Sprod 0% 99% 99% 0.899 0.528 0.38
SpotClean 38% 60% 56% 0.867 0.527 5.78
SpotGF 50% 49% 51% 0.673 0.502 0.75
SpaDiff 95% 100% 92% 0.829 0.581 2.47

TC, tumor core; NC, normal core; TP, tumor periphery; TA, tumor adjacent. Bold indicates the best-performing method for each metric.

a

Gini%+, Moran%+, and F-ratio%+: percentage of genes for which the corresponding per-gene metric increased relative to the raw data.

b

AUROC (TC vs. NC): classification AUROC for tumor core vs. normal core across 16 tumor-marker genes.

c

AUROC (TC vs. TP+TA): within-tumor sub-region classification AUROC for tumor core vs. tumor periphery plus tumor adjacent.

d

VarRatio TC: mean within-tumor core variance after denoising divided by that in the raw data for tumor-marker genes. See also Table S3.

Figure 6C traces SpaDiff’s iterative reverse-diffusion dynamics for MKI67 from step 0 (raw) to step T = 15. Across these iterations, mass progressively concentrates into TC spots while low-density normal regions are emptied, indicating mass is transported rather than smoothed or added. The resulting regional distribution is summarized in Figure 6D: among the compared methods, SpaDiff produces the steepest normal-to-tumor gradient, consistent with mass concentration into the biologically high-density source. This redistribution modestly improves the conventional binary TC vs. NC AUROC (+0.046, Table 1). Sprod achieves a larger gain on the same coarse task (+0.116) only by homogenizing within-region expression, which is the same operation that collapses the patchy MKI67 pattern in Figure 6B and drives the within-TC variance ratio to 0.38. Table 1 summarizes the full comparison.

In summary, the colorectal cancer dataset reveals a structural distinction between SpaDiff and existing spatial denoising methods that the chimeric and DLPFC benchmarks do not expose. SpaDiff is the only method whose per-gene physics signature is uniformly applied across the transcriptome (95%–100% of genes positive on three concentration metrics simultaneously), and the only method that improves within-tumor sub-region biological resolution (sub-region AUROC +0.068; the next-best method achieves +0.015). Forward smoothers such as Sprod can attain higher absolute AUROC on coarse tumor vs. normal classification, but only by destroying 60% of the within-TC variance that distinguishes proliferating, invasive, and quiescent tumor subpopulations. SpotClean, the closest conceptual competitor, an explicit spillover-correction model, achieves competitive between-region biology by recovering counts from off-tissue spots, a 38% increase in in-tissue total mass, but applies its corrections selectively (Gini increases on only 38% of genes), in contrast to SpaDiff’s uniform per-gene action. Together with the chimeric benchmark, these results establish SpaDiff as a denoising tool that simultaneously improves regional structure and preserves the within-region cellular heterogeneity that defines tumor biology, supporting downstream analyses, such as sub-region clustering, intra-tumor proliferation mapping, and niche detection, that forward-smoothing methods foreclose. On the within-tumor sub-region task, SpaDiff achieves an AUROC of 0.581 (95% CI [0.539, 0.620])—the only method whose CI lower bound exceeds every comparator’s point estimate (Figure S7; Tables S4; S5).

Discussion

Sequence-based spatial transcriptomics is pivotal for comprehensive gene profiling, leveraging high-throughput sequencing technologies to detect gene expression with genome-wide coverage and high molecular specificity. However, these techniques are often limited by technical artifacts, most notably the spot-swapping phenomenon, in which mRNA molecules diffuse and are captured by neighboring barcoded spots. This artifact introduces substantial noise, distorts the true spatial distribution of gene expression, and negatively impacts downstream analyses such as clustering, spatial domain identification, and biomarker detection.

Empirically, SpaDiff delivers measurable improvements across synthetic benchmarks and three independent real-tissue settings. On the human-mouse chimeric benchmark, SpaDiff achieves the highest per-gene purity and the lowest cross-species contamination rate among six methods tested. On a human colorectal cancer Visium dataset, SpaDiff is the only method that simultaneously sharpens between-region structure and preserves within-region cellular heterogeneity, improving the sub-region AUROC for tumor sub-compartments from 0.513 to 0.581, while forward smoothers degrade it. Notably, SpaDiff is also the only method that natively denoises off-tissue regions, physically transporting contaminating mass back to its correct tissue location rather than discarding it, which is a direct consequence of its mass-conserving, physics-based formulation.

These improvements stem from four design choices in SpaDiff. First, SpaDiff implements the reverse process as the deterministic probability-flow ODE of Song et al.22 The two formulations are mathematically equivalent in marginal distribution at every time point, but the deterministic version is better suited to denoising: no additional noise is injected during the reverse step, so the trajectory contracts mass spots monotonically toward high-density regions, and the output is fully reproducible across runs. The score that drives this trajectory is estimated nonparametrically from the current expression field by kernel density estimation rather than learned by a time-conditioned neural network; this is justified because, for the moderate diffusion process typical of spot-swapping, the spatial density gradient changes slowly enough that a snapshot estimate is a sufficiently accurate approximation. To keep this snapshot estimator robust as the density field evolves across iterations, SpaDiff: (1) blends the per-gene KDE score with a global density score through an adaptive, density-weighted mixing that defers to the global score where a gene is locally sparse and (2) damps the score in regions where the local gene density has already saturated its biological dynamic range, preventing mass from collapsing into already-dense spots. Both design elements are detailed in STAR Methods. Empirically, the ODE is bit-level reproducible across seeds, whereas the SDE yields differences of ∼0.45–0.49.

A second design choice is the forward Brownian model, which provides a clean and tractable mathematical framework. To handle departures from this idealized assumption in practice, SpaDiff incorporates two specific safeguards: the ghost-spot boundary correction mechanism, which addresses the asymmetric diffusion field near slide edges by mirroring the density field across the boundary and the two-level score estimation architecture, which allows the denoising trajectory to adapt to local density structures that may not conform to a globally homogeneous diffusion assumption.

Third, SpaDiff estimates the score function independently for each gene, a design choice that is grounded in the physics of spot-swapping. Because spot-swapping is fundamentally a physical process, the passive diffusion of RNA molecules through the permeabilized tissue matrix, the displacement of any individual molecule depends on the local molecular density field rather than on gene-gene regulatory interactions. SpaDiff captures this shared physical context through the global score, which aggregates mass from all genes onto a common spot grid and provides every mass spot with a density gradient estimated from the total molecular landscape. The gene-specific score then refines this estimate for abundantly expressed genes whose spatial distributions carry enough statistical signal. A per-spot mixing weight mediates between these two levels: in regions where a gene is sparsely expressed, this weight is close to zero, and the mass spot relies predominantly on the global score, while in high-density regions, the weight approaches one and the gene-specific score takes precedence. A separate density-aware suppression factor then damps the mixed score in over-saturated regions to prevent mode collapse. Therefore, this architecture does not ignore shared spatial structure; rather, it channels intergene information through the global density field, which is the physically appropriate quantity governing molecular diffusion.

Finally, SpaDiff adheres to a strict mass-conservation constraint: the total mass in the denoised expression matrix is exactly equal to the total UMI count in the raw input. Because SpaDiff estimates a continuous spatial distribution rather than resampling integer counts, the per-spot output is real-valued; mass conservation, rather than integer-count conservation, is the appropriate physical invariant in this setting, and it guarantees that quantitative information is neither added nor lost during denoising. By retaining the full quantitative content of the raw observation, SpaDiff minimizes information loss during denoising and avoids the systematic biases that arise when methods inflate or deflate per-spot counts in the process of smoothing or imputation.

A natural concern with any score-based denoiser is that the reverse dynamics, which always push mass toward density peaks, may oversharpen domain boundaries or distort continuous biological gradients. To examine this directly, we revisited the colorectal cancer analysis introduced above through two complementary metrics. The within-TC variance ratio tests whether denoising destroys biological gradients within a single annotated region: SpaDiff preserves and moderately sharpens within-region heterogeneity (variance ratio 2.47), whereas forward smoothers such as Sprod destroy a substantial fraction of within-region variance (0.38, a 62% loss). The sub-region AUROC for TC vs. TP+TA tests, by construction, whether continuous gradients between adjacent regions are preserved: SpaDiff improves this AUROC from 0.513 to 0.581, while forward-smoothing methods, at most, marginally improve it, and MvDST degrades it to 0.409 by homogenizing across regions. Together, these results indicate that SpaDiff achieves regional sharpening without collapsing within-region structure, mitigating the oversharpening concern that applies to score-based denoisers in general. Quantitatively, the oversharpening index (OSI) ≤1 for SpaDiff across all simulation cells and the boundary-fidelity ratio B_fid <1 confirm that SpaDiff smooths rather than creates artificial edges (Figure S1).

Limitations of the study

Several limitations of the present work warrant explicit acknowledgment. First, the forward-noise model adopts the simplest case of isotropic Brownian diffusion; while the design elements described earlier and the real-data experiments suggest robustness to deviations from this assumption, real spot-swapping is influenced by tissue boundaries, section thickness, membrane permeability, and potential anisotropic leakage that the model does not explicitly capture. Second, the simulation benchmark, although broadened to include Laplace and Cauchy kernels, does not include directional drift or overlapping spatial domains; both would require more involved generative models to evaluate quantitatively. Third, in the most extreme Cauchy contamination regime, SpaDiff and Sprod converge to a shared performance floor (Figure 3B), indicating a fundamental limit on what any spot-swapping correction can recover when the contamination is dominated by long-range outlier transfers. Finally, all real-data benchmarks here use the Visium platform; while the algorithm is formulated to be platform-agnostic through the unit-square coordinate normalization, validation on Slide-seq, Stereo-seq, or other emerging platforms remains to be undertaken in future works.

These limitations also point to natural directions for future development. The reverse-diffusion formulation is general: when auxiliary information about the contamination process is available, a calibrated diffusion direction, a known anisotropy from tissue architecture, or a partial mapping from imaging modalities, it can be injected into the score field by replacing the isotropic Gaussian KDE with a more structured kernel, without altering the rest of the algorithm. Validation on Slide-seq, Stereo-seq, and other emerging platforms is straightforward because the algorithm operates in the standardized unit-box coordinate system, but a systematic cross-platform comparison remains a valuable next step.

Resource availability

Lead contact

Requests for further information and resources should be directed to and will be fulfilled by the lead contact, Ping Ma (pingma@uga.edu).

Materials availability

This study did not generate new unique reagents.

Data and code availability

Acknowledgments

The authors would like to acknowledge support from the US National Science Foundation (DMS-1925066, DMS-1903226, DMS-2124493, DMS-2311297, DMS-2319279, and DMS-2318809) and the National Institutes of Health (NIH R01GM152814 and NIH RF1MH133703).

Author contributions

Conceptualization, G.-C.Y., P.M., W.Z., J.C., and Y.C.; methodology, P.M., Y.C., and J.C.; coding, L.F., X.L., and J.C.; formal analysis, Y.C., X.L., J.C., L.F., G.-C.Y., and P.M.; writing – original draft, J.C.; writing – review & editing, J.C., G.-C.Y., X.L., L.F., P.M., Y.C., and W.Z.; supervision, G.-C.Y., P.M., and W.Z.; funding acquisition, G.-C.Y., P.M., and W.Z.

Declaration of interests

The authors declare no competing interests.

Declaration of generative AI and AI-assisted technologies in the writing process

During the preparation of this work, the authors used ChatGPT (OpenAI) and Claude (Anthropic) in order to assist with language editing and improving the readability of the manuscript. After using these tools, the authors reviewed and edited the content as needed and take full responsibility for the content of the publication.

STAR★Methods

Key resources table

REAGENT or RESOURCE SOURCE IDENTIFIER
Deposited data

High-resolution Xenium mouse brain data 10× Genomics https://www.10xgenomics.com/datasets/xenium-prime-fresh-frozen-mouse-brain
Human dorsolateral prefrontal cortex (DLPFC) Visium spatial transcriptomics data spatialLIBD project; Maynard et al.26 http://research.libd.org/spatialLIBD/
Human–mouse chimeric Visium tissue data Ni et al.8 GEO: GSE178221; https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE178221
Human colorectal cancer Visium data Ni et al.8 Zenodo: https://doi.org/10.5281/zenodo.6478458

Software and algorithms

SpaDiff This paper Zenodo: https://doi.org/10.5281/zenodo.20437584; https://github.com/JiazhangCai/SpaDiff
SpotClean Ni et al.8 https://github.com/zijianni/SpotClean
Sprod Wang et al.16 https://github.com/yunguan-wang/SPROD
MIST Wang et al.15 https://github.com/linhuawang/MIST
MvDST Wang et al.17 https://github.com/zilanjiuwan/MvDST
SpotGF Du et al.14 https://github.com/illuminate6060/SpotGF
Python (v3.10) Python Software Foundation https://www.python.org/
R (v4.3) R Core Team https://www.r-project.org/
scanpy Wolf et al., 2018 https://github.com/scverse/scanpy
SpaGCN Hu et al.28 https://github.com/jianhuupenn/SpaGCN
leidenalg Traag et al.27 https://github.com/vtraag/leidenalg
scikit-learn Pedregosa et al., 2011 https://scikit-learn.org/
NumPy/SciPy Harris et al., 2020; Virtanen et al., 2020 https://numpy.org/; https://scipy.org/

Experimental model and study participant details

This study analyzed publicly available spatial transcriptomics datasets and did not generate new human or animal samples. The analyzed datasets included high-resolution Xenium mouse brain data, human dorsolateral prefrontal cortex spatial transcriptomics data, human–mouse chimeric Visium tissue data, and human colorectal cancer Visium data. Dataset sources and identifiers are provided in the key resources table.

Method details

Overview

SpaDiff casts spatial transcriptomics denoising as a reverse-diffusion process on a set of mass spots: each unit of observed expression is transported along a kernel density score field that progressively sharpens the spatial pattern while exactly conserving total mass. The algorithm first converts the count matrix into a mass-spot representation and estimates a score field by kernel density estimation (KDE), and then iteratively transports mass along this score with a coarse-to-fine bandwidth schedule. To make the generic reverse-diffusion scheme effective on noisy, sparse, and spatially structured gene expression data, we introduce six problem-specific modifications: a three-phase decomposition that decouples global and gene-specific statistics for memory efficiency; ghost-spot boundary symmetrisation that removes the inward KDE bias at slide edges; a hybrid global–local score with an adaptive per-spot mixing weight ω; an optional low-mass gene gating that can bypass gene-specific scoring on extremely sparse genes; a density-aware suppression factor αφ that prevents mode collapse in dense regions; and joint coarse-to-fine bandwidth and step-size schedules that denoise large-scale structure first and refine local structure in later iterations.

Preprocessing: Mass-spot representation

Given an observed UMI count matrix C∈NM×G on M spots with coordinates {xm}m=1M and G genes, raw spot coordinates are first scaled per-dimension to the unit square [0,1]2,

x˜m=(xm−xmin)(xmax−xmin)+ε,

so that all bandwidth parameters are platform-invariant across Visium, Slide-seq, Stereo-seq, and other platforms. SpaDiff then converts the sparse count matrix into a set of mass spots: each nonzero entry (m,g,cmg) generates one mass spot, indexed by p, with initial position xp(0)=x˜m, gene label gp = g, and mass wp = cmg.

Core reverse denoising formulation

The observed count matrix is modeled, per gene, as a noisy realisation of an underlying spatial expression density ρ(g)(x) on [0,1]2. SpaDiff recovers this density by driving mass spots along the gradient of its log-KDE, the score function, via an Euler–Maruyama discretisation of the reverse-time diffusion

dx=s(x,t)dt+σdWt,

with the score s(x,t)=∇logρ(x,t) estimated from the current mass-spot cloud by a Gaussian KDE of bandwidth h,

ρ(x)=∑jwjκh(‖x−x˜j‖),κh(d)=exp(−d22h2)
s(x)=1h2(ρ(x)+λ)∑jwjκh(‖x−x˜j‖)(x˜j−x),

where wj is the density weight deposited at spot j, and λ is a small regulariser. In discrete form, each mass spot is advanced by the core Euler–Maruyama rule

xp(t+1)=xp(t)+ηt(s(xp(t))+σξp),ξp∼N(0,I2).

After T such steps, mass spots are softly deposited onto the spot grid to yield the denoised count matrix Cˆ. The step size ηt by default follows an independent exponential decay schedule from η0 to a small fraction ηmin over T steps. SpaDiff runs by default with σ=0 (deterministic drift), corresponding to the deterministic probability-flow ODE of Song et al.22 Although the underlying SDE in principle admits a time-varying noise scale σ(t), SpaDiff implements only a short segment of the reverse-time trajectory in which σ(t) does not vary appreciably, so we treat it as a constant within the discrete update; the residual time-dependence of the dynamics is carried through the step-size schedule η(t) defined below. Users who wish to run a stochastic variant of SpaDiff can do so by setting σ > 0.

Adaptations for the spatial-transcriptomics setting

The generic formulation above presents four practical difficulties on real ST data: (a) the particle (UMI) count is large (typically 106–108), making any particle-level denoising prohibitive; (b) slide boundaries create one-sided KNN neighbourhoods that bias the score inward; (c) a single KDE score cannot simultaneously handle abundant genes with focal patterns and sparse genes with low signal-to-noise; (d) a pure score-following update collapses mass into the densest spots (mode collapse). We address these via the following modifications.

(1) Three-phase decomposition

Rather than modeling the movement for every single particle, each denoising step is factored into three memory-safe phases at the spot level.

Phase A—Global deposition. For any spot p, SpaDiff distributes its mass softly across its Ka nearest spots using a Gaussian kernel of bandwidth ha,

πp,m=exp(−‖xp−x˜m‖22ha2)∑m′∈NKa(xp)exp(−‖xp−x˜m′‖22ha2),wglob(x˜m)=∑pwpπp,m.

Because ∑mπp,m=1 for every spot, deposition is mass-preserving by construction. Phase A is parallelised over contiguous spot chunks and reduced by summation.

Phase B—Global score on spots. The score of the deposited density is evaluated at spot locations,

ρglob(x˜m)=∑j∈NKb(m)wglob(x˜j)κhb(‖x˜m−x˜j‖),
sglob(x˜m)=1hb2(ρglob(x˜m)+λ)∑j∈NKb(m)wglob(x˜j)κhb(‖x˜m−x˜j‖)(x˜j−x˜m).

Operating on spots keeps peak memory at O(MKb) rather than O(PKb), reducing the Phase-B footprint by P/M (two to three orders of magnitude on typical datasets).

Phase C—Per-gene update. The global spot score is interpolated to each mass spot through its Kc nearest spots,

sglob(xp)=∑j∈NKc(p)w¯p,jsglob(x˜j),

where w¯p,j=exp(−‖xp−x˜j‖22hc2)∑j′exp(−‖xp−x˜j′‖22hc2). A gene-specific score s(g)(xp) is then computed only on the mass spots of gene g (see (3) below). Because mass spots are pre-sorted by gene, each worker in Phase C receives only the contiguous mass-spot slice for its gene block, so inter-process communication scales with Pblock rather than Ptotal.

(2) Ghost-spot boundary symmetrisation

At the slide boundary, i.e., the physical edge of the capture array where the spot lattice ends, not the boundary between tissue-covered and off-tissue regions on the chip, a spot’s KNN neighborhood is one-sided, which systematically biases sglob inward and pulls mass away from the edge. SpaDiff detects boundary spots by the centroid asymmetry of their Ke nearest neighbors: a spot is declared boundary if ‖mean(x˜N(m))−x˜m‖>θ·med(d1), where d1 is the nearest-neighbour distance and θ (default 0.3) a threshold factor. For each boundary spot, one or more mirror ghost spots are placed along the outward asymmetry direction, and their mass is mirrored from the source boundary spot at every step,

wm′ghost=wr(m′),

where r(m′) returns the source real spot of the ghost m′. Ghost spots participate only in Phases B and C’s KDE evaluation; they never receive deposited mass (Phase A) and never appear in the output.

(3) Hybrid global–local score with mixing weight ω

A single global score is too smooth for genes with focal expression; a single gene-specific score is too noisy for sparse genes. For each gene with total mass above a threshold τmass, SpaDiff computes a gene-specific deposition and score on the mass spots of that gene only,

w(g)(x˜m)=∑p:gp=gwpπp,m,
ρ(g)(xp)=∑j∈NKs(xp)w(g)(x˜j)κhs(‖xp−x˜j‖),
s(g)(xp)=1hs2(ρ(g)(xp)+λ)∑j∈NKs(xp)wj(g)κhs(‖xp−x˜j‖)(x˜j−xp),

and blends the two scores through a per-spot mixing weight

ω(xp)=ρ(g)(xp)ρ(g)(xp)+β+ε∈[0,1],
smix(xp)=ω(xp)s(g)(xp)+(1−ω(xp))sglob(xp).

Where the gene is locally dense, ω→ 1 and the gene-specific score dominates (focal specificity); where the gene is sparse, ω→ 0 and the global score dominates (noise robustness). The scalar β (default 0.02) controls the transition. Because ω is defined per mass spot, the transition is smooth and data-adaptive rather than a hard threshold.

(4) Low-mass gene gating

Genes whose total mass ∑pwp[gp=g] falls below τmass bypass the entire gene-specific branch (no w(g), no s(g), no ω) and use sglob alone. By default, the threshold is set to 0, in which case gating is disabled and all genes participate in gene-specific scoring; raising τmass to a positive value, both accelerates the computation, because low-mass genes often make up the majority of the gene list, and prevents amplification of sampling noise in genes whose KDE is itself dominated by noise.

(5) Density-aware suppression αφ

Following the score uncritically can create positive feedback: once a region becomes slightly denser, it attracts further mass, and mass spots may eventually collapse into the densest spot. To prevent this, SpaDiff scales the mixed score by a spot-level saturation factor derived from the gene-specific deposited mass,

αφ(x˜m)=clip(1−w(g)(x˜m)φq(g),0,1),φq(g)=Quantileq({w(g)(x˜m):w(g)(x˜m)>0,m=1,…,M}).

The reference level φq(g) is computed as the q-quantile of the positive per-gene deposited masses, with default q = 0.90. Excluding zero-mass spots prevents the reference level from degenerating to zero for sparse genes, and using a high quantile rather than the maximum makes the suppression less sensitive to isolated extreme spots. The spot-level factor αφ is then interpolated to mass spots using the same kernel as in the global-score interpolation. The factor αφ approaches 0 as the local gene density saturates, halting further inward flow, and remains close to 1 in sparse regions where additional sharpening is still desirable. The final density-suppressed score is

s⋆(xp)=αφ(xp)smix(xp),

and mass spots are advanced by the core Euler–Maruyama rule with s⋆ in place of s. The default value q = 0.90 is supported by an ablation on the chimeric tissue: disabling αφ triples the median top-1 mass concentration and reduces species classification accuracy by 13.4%, whereas q values in [0.70,0.95] yield comparable performance (Figure S3; Table S2).

(6) Coarse-to-fine bandwidth and step-size schedules

All kernel bandwidths are expressed relative to the unit-box coordinates and tied to neighborhood layer counts. For a hexagonal grid, the number of spots within L layers is K(L) = 1 + 3L(L+ 1) (and (2L+ 1)2 for a square grid); this mapping sets Ka,Kb,Kc,Ks from the layer parameters (La,Lb,Lc,Ls). The gene-score bandwidth follows an exponential coarse-to-fine annealing,

ht=hend+(hstart−hend)exp(−μt),

with the global-score bandwidth scaled proportionally, hb(t)=ht·(Lb/Ls). The step size decays jointly with bandwidth and time,

ηt=η0(ht/hstart)2γt,

In practice SpaDiff defaults to a simpler linear step-size schedule, ηt = η0· [1 - (1 -ηmin/η0) ·t/(T-1)], that is independent of the bandwidth and keeps the effective step size meaningful even after h has shrunk; the bandwidth-geometric schedule above is retained as a legacy option. With either schedule, early iterations denoise large-scale structure with a large step and a broad kernel, while later iterations refine local structure with proportionally smaller displacements. Default parameters are T = 5, η0 = 5 × 10-3, γ = 0.9, hstart = 0.20, hend = 0.10, μ = 0.10, β = 0.02, τmass = 0, λ = 10-3.

Final deposition and integerisation

After T iterations, mass spots are deposited once more with the Phase A soft-assignment to produce the denoised float expression matrix Cˆ∈R≥0M×G. By default, SpaDiff returns the unrounded float matrix, which preserves the exact spatial pattern produced by the mass-spot dynamics and is preferred for most downstream analyses. Two optional integer rounding strategies are also supported: (a) simple rounding with nonnegativity clipping, which preserves the spatial pattern of the float solution; and (b) per-spot multinomial sampling with probabilities proportional to the denoised float expression, which exactly preserves each spot’s integer total. Because soft assignment is row-normalised over the nearest spots and a tiny kernel fallback is added to capture mass spots that drift off the spot grid, total mass is conserved up to float rounding in either case.

Computational complexity

The per-step cost is dominated by KNN queries against a KD-tree built once on the (augmented) spot grid: O(PKalogM) for Phase A, O(MKb) for Phase B, and O(P(Kc+Ks)logM) for Phase C. Peak memory is O(MKb+PKs), i.e., never (PKb) simultaneously. Empirically, a dataset with M ≈ 5 · 103 spots, G ≈ 2 · 104 genes, and p ≈ 107 mass spots, runs end-to-end in under a minute on 4 CPU cores.

Parameter selection

All spatial computations in SpaDiff are performed in the standardised [0,1]2 coordinate system, making parameter values transferable across platforms without dataset-specific tuning. Neighborhood sizes are specified as layer counts L in the spot grid geometry: for a hexagonal grid the number of neighbors within L layers is K = 1 + 3L(L + 1), and for a square grid K= (2L+ 1)2. The default configuration uses La = 1 for soft assignment (7 neighbors in hexagonal grids), Lb = 5 for the global score (91 neighbors), Lc = 1 for interpolation (7 neighbors), and Ls = 3 for gene-specific scores (37 neighbors). Gaussian bandwidths are set proportional to the layer count via h = c × L with c = 0.04 in the [0,1]2 coordinate system. The density regularisation is λ = 10−3. The low-mass gene threshold τmass (default 0, i.e., gating disabled) controls when a gene bypasses gene-specific scoring and relies on the global score alone; raising it routes sparse genes to the global score only. The boundary detection asymmetry threshold factor is θ = 0.3. Default values and ranges for all hyperparameters are listed in Table S1.

Quantification and statistical analysis

All quantitative analyses were performed using Python and R. No statistical methods were used to predetermine sample size. No randomization or blinding was applied because this study analyzed publicly available spatial transcriptomics datasets and computationally generated simulation data.

For simulation benchmarks, Jensen–Shannon divergence (JSD) was used to compare recovered and ground-truth spatial expression distributions. For each gene, the recovered and ground-truth spot-level count vectors were normalized into probability distributions over spots before computing JSD. Median per-gene JSD was reported for each setting. Lower JSD indicates better recovery of the ground-truth expression pattern.

For the human–mouse chimeric tissue analysis, classification accuracy was computed as the proportion of annotated spots assigned to the correct species label. Per-gene purity was defined as the fraction of reads from a species-specific gene localized to the corresponding species-specific tissue region. Cross-species contamination rate (CSCR) was defined as the fraction of species-specific reads assigned to the opposite species-specific tissue region. Higher accuracy and purity and lower CSCR indicate better denoising performance.

For DLPFC spatial-domain analysis, agreement between inferred clustering labels and manual layer annotations was quantified using the adjusted Rand index (ARI). Higher ARI indicates stronger agreement. For marker-gene analysis, log fold change was computed between white matter and layer 6. Statistical significance was assessed using two-sided Wilcoxon rank-sum tests unless otherwise stated, and negative log10 p values were reported.

For the colorectal cancer Visium analysis, the Gini coefficient was used to quantify spatial concentration of gene expression, Moran’s I was used to quantify spatial autocorrelation, and the F-ratio was used to quantify between-region variation relative to within-region variation. Gini%+, Moran%+, and F-ratio%+ denote the percentage of genes for which the corresponding metric increased after denoising relative to the raw data. Tumor-marker separability was quantified using the area under the receiver operating characteristic curve (AUROC). VarRatio TC was defined as the within-Tumor Core variance after denoising divided by the corresponding variance in the raw data. MKI67 expression was log1p transformed before region-level averaging.

For boxplots, center lines indicate medians, boxes indicate interquartile ranges, whiskers indicate 1.5 times the interquartile range, and points indicate individual samples unless otherwise stated.

Additional resources

No additional resources are associated with this study.

Published: July 17, 2026

Footnotes

Supplemental information related to this article can be found online at https://doi.org/10.1016/j.crmeth.2026.101530.

Contributor Information

Wenxuan Zhong, Email: wenxuan@uga.edu.

Guo-Cheng Yuan, Email: guo-cheng.yuan@mssm.edu.

Ping Ma, Email: pingma@uga.edu.

Supplemental information

Document S1. Figures S1–S7 and Tables S1–S6
mmc1.pdf (2.7MB, pdf)
Document S2. Article plus supplemental information
mmc2.pdf (28.7MB, pdf)

References

  • 1.Moses L., Pachter L. Museum of spatial transcriptomics. Nat. Methods. 2022;19:534–546. doi: 10.1038/s41592-022-01409-2. [DOI] [PubMed] [Google Scholar]
  • 2.Du J., Yang Y.-C., An Z.-J., Zhang M.-H., Fu X.-H., Huang Z.-F., Yuan Y., Hou J. Advances in spatial transcriptomics and related data analysis strategies. J. Transl. Med. 2023;21:330. doi: 10.1186/s12967-023-04150-2. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 3.Rao A., Barkley D., França G.S., Yanai I. Exploring tissue architecture using spatial transcriptomics. Nature. 2021;596:211–220. doi: 10.1038/s41586-021-03634-9. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 4.Duan H., Cheng T., Cheng H. Spatially resolved transcriptomics: advances and applications. Blood Sci. 2023;5:1–14. doi: 10.1097/BS9.0000000000000141. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 5.Marx V. Method of the Year: spatially resolved transcriptomics. Nat. Methods. 2021;18:9–14. doi: 10.1038/s41592-020-01033-y. [DOI] [PubMed] [Google Scholar]
  • 6.Tian L., Chen F., Macosko E.Z. The expanding vistas of spatial transcriptomics. Nat. Biotechnol. 2023;41:773–782. doi: 10.1038/s41587-022-01448-2. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 7.Dries R., Chen J., Del Rossi N., Khan M.M., Sistig A., Yuan G.-C. Advances in spatial transcriptomic data analysis. Genome Res. 2021;31:1706–1718. doi: 10.1101/gr.275224.121. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 8.Ni Z., Prasad A., Chen S., Halberg R.B., Arkin L.M., Drolet B.A., Newton M.A., Kendziorski C. SpotClean adjusts for spot swapping in spatial transcriptomics data. Nat. Commun. 2022;13:2971. doi: 10.1038/s41467-022-30587-y. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 9.Wang J., Agarwal D., Huang M., Hu G., Zhou Z., Ye C., Zhang N.R. Data denoising with transfer learning in single-cell transcriptomics. Nat. Methods. 2019;16:875–878. doi: 10.1038/s41592-019-0537-1. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 10.Subramanian A., Alperovich M., Yang Y., Li B. Biology-inspired data-driven quality control for scientific discovery in single-cell transcriptomics. Genome Biol. 2022;23:267. doi: 10.1186/s13059-022-02820-w. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 11.Van Dijk D., Sharma R., Nainys J., Yim K., Kathail P., Carr A.J., Burdziak C., Moon K.R., Chaffer C.L., Pattabiraman D., et al. Recovering gene interactions from single-cell data using data diffusion. Cell. 2018;174:716–729.e27. doi: 10.1016/j.cell.2018.05.061. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 12.Huang M., Wang J., Torre E., Dueck H., Shaffer S., Bonasio R., Murray J.I., Raj A., Li M., Zhang N.R. SAVER: gene expression recovery for single-cell RNA sequencing. Nat. Methods. 2018;15:539–542. doi: 10.1038/s41592-018-0033-z. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 13.Li W.V., Li J.J. An accurate and robust imputation method scImpute for single-cell RNA-seq data. Nat. Commun. 2018;9:997. doi: 10.1038/s41467-018-03405-7. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 14.Du L., Kang J., Hou Y., Sun H.-X., Zhang B. SpotGF: Denoising spatially resolved transcriptomics data using an optimal transport-based gene filtering algorithm. Cell Syst. 2024;15:969–981.e6. doi: 10.1016/j.cels.2024.09.005. [DOI] [PubMed] [Google Scholar]
  • 15.Wang L., Maletic-Savatic M., Liu Z. Region-specific denoising identifies spatial co-expression patterns and intra-tissue heterogeneity in spatially resolved transcriptomics data. Nat. Commun. 2022;13:6912. doi: 10.1038/s41467-022-34567-0. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 16.Wang Y., Song B., Wang S., Chen M., Xie Y., Xiao G., Wang L., Wang T. Sprod for de-noising spatially resolved transcriptomics data based on position and image information. Nat. Methods. 2022;19:950–958. doi: 10.1038/s41592-022-01560-w. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 17.Wang H., Gao P., Feng S., Ma X. Denoising spatially resolved transcriptomics with consistency of heterogeneous spatial coordinates, transcription, and morphology. Briefings Bioinf. 2025;26 doi: 10.1093/bib/bbaf528. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 18.Eschweiler D., Yilmaz R., Baumann M., Laube I., Roy R., Jose A., Brückner D., Stegmaier J. Denoising diffusion probabilistic models for generation of realistic fully annotated microscopy image datasets. PLoS Comput. Biol. 2024;20 doi: 10.1371/journal.pcbi.1011890. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 19.Wang Y., Cheng J. HiCDiff: single-cell Hi-C data denoising with diffusion models. Brief. Bioinform. 2024;25:bbae279. doi: 10.1093/bib/bbae279. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 20.Song J., Meng C., Ermon S. Denoising diffusion implicit models. arXiv. 2022 doi: 10.48550/arXiv.2010.02502. Preprint at. [DOI] [Google Scholar]
  • 21.Ho J., Jain A., Abbeel P. Denoising diffusion probabilistic models. Proceedings of the 34th International Conference on Neural Information Processing Systems. 2020;34 [Google Scholar]
  • 22.Song Y., Sohl-Dickstein J., Kingma D.P., Kumar A., Ermon S., Poole B. Score-based generative modeling through stochastic differential equations. arXiv. 2021 doi: 10.48550/arXiv.2011.13456. Preprint at. [DOI] [Google Scholar]
  • 23.10x Genomics (2023). Release - Xenium_V1_FF_Mouse_Brain_Coronal_Subset_CTX+HP. https://cf.10xgenomics.com/samples/xenium/1.0.2/Xenium_V1_FF_Mouse_Brain_Coronal_Subset_CTX_HP/Xenium_V1_FF_Mouse_Brain_Coronal_Subset_CTX_HP_analysis_summary.html.
  • 24.10x Genomics (2025). What is the spatial resolution and configuration of the capture area of the Visium v1 Gene Expression Slide? https://kb.10xgenomics.com/hc/en-us/articles/360035487572-What-is-the-spatial-resolution-and-configuration-of-the-capture-area-of-the-Visium-v1-Gene-Expression-Slide.
  • 25.Menéndez M.L., Pardo J.A., Pardo L., Pardo M.C. The Jensen-Shannon divergence. J. Franklin Inst. 1997;334:307–318. doi: 10.1016/S0016-0032(96)00063-4. [DOI] [Google Scholar]
  • 26.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. doi: 10.1038/s41593-020-00787-0. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 27.Traag V.A., Waltman L., Van Eck N.J. From Louvain to Leiden: guaranteeing well-connected communities. Sci. Rep. 2019;9:5233. doi: 10.1038/s41598-019-41695-z. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 28.Hu J., Li X., Coleman K., Schroeder A., Ma N., Irwin D.J., Lee E.B., Shinohara R.T., Li M. SpaGCN: Integrating gene expression, spatial location and histology to identify spatial domains and spatially variable genes by graph convolutional network. Nat. Methods. 2021;18:1342–1351. doi: 10.1038/s41592-021-01255-8. [DOI] [PubMed] [Google Scholar]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Supplementary Materials

Document S1. Figures S1–S7 and Tables S1–S6
mmc1.pdf (2.7MB, pdf)
Document S2. Article plus supplemental information
mmc2.pdf (28.7MB, pdf)

Data Availability Statement


Articles from Cell Reports Methods are provided here courtesy of Elsevier

RESOURCES