Skip to main content
Advertisement
  • Loading metrics

StPedf: Cell trajectory inference of spatial transcriptomics via spatial proximity embedding and spatial density-adaptive fusion

  • Yuan Zhang,

    Roles Conceptualization, Data curation, Investigation, Methodology, Validation, Visualization, Writing – original draft, Writing – review & editing

    Affiliation School of Science, Jiangnan University, Wuxi, Jiangsu, China

  • Ziyan Sun,

    Roles Data curation, Investigation

    Affiliation School of Science, Jiangnan University, Wuxi, Jiangsu, China

  • Zhixin Shi,

    Roles Data curation, Investigation

    Affiliation School of Science, Jiangnan University, Wuxi, Jiangsu, China

  • Mengdi Nan,

    Roles Data curation, Investigation

    Affiliation School of Science, Jiangnan University, Wuxi, Jiangsu, China

  • Yuhan Fu,

    Roles Investigation, Visualization

    Affiliation School of Science, Jiangnan University, Wuxi, Jiangsu, China

  • Qing Ren,

    Roles Investigation, Visualization

    Affiliation School of Science, Jiangnan University, Wuxi, Jiangsu, China

  • Jie Gao

    Roles Supervision, Validation, Writing – review & editing

    gaojie@jiangnan.edu.cn

    Affiliation School of Science, Jiangnan University, Wuxi, Jiangsu, China

Abstract

Spatial transcriptomics is transforming our multidimensional understanding of cellular spatial organization and its functional mechanisms in processes such as development and disease by systematically resolving the spatial heterogeneity of gene expression within tissues. To delve deeper into the dynamic processes underlying spatial expression patterns, spatial trajectory inference integrates genetic and spatial information to reconstruct the spatial developmental trajectories of cells within tissues. This approach reveals the patterns of differentiation and dynamic changes as cellular states evolve continuously along spatial axes. However, existing methods often struggle to uniformly model the complex, nonlinear interactions between high-dimensional gene expression and spatial coordinates. Here, we introduce StPedf, whose core lies in employing a neural network with a masking mechanism to capture complex nonlinear interactions between high-dimensional genes and spatial positions. It further leverages spatial proximity information as a guiding cue, dynamically and adaptively adjusting the embedding of gene and spatial information and the weighting of spatial proximity information based on spatial density. This enables trajectory inference guided by spatial information. This enables optimal transport to derive intercellular transition matrices, reconstruct cellular differentiation trajectories, and construct pseudo-spatiotemporal maps. StPedf demonstrates superior performance over existing methods on five structurally distinct simulated datasets. Using StPedf, we successfully mapped distinct lineages in the spatial trajectories of telencephalon regeneration in the Ambystoma mexicanum, multiple malignant lineages expanding within primary tumors, and developmental spatial trajectories and pseudo-spatiotemporal maps in human dorsolateral prefrontal cortex (DLPFC). StPedf significantly enhances the accuracy and interpretability of spatial trajectory inference, providing critical technical support for revealing the dynamic patterns of cellular fate transitions within tissue microenvironments.

Author summary

The formation of tissue structure depends on the coordinated changes in cell states and their spatial arrangement during development, regeneration, and disease. Understanding these processes requires not only identifying gene activity but also determining the location of cells and how their spatial organization changes. Spatial transcriptomics allows us to study gene expression in its native tissue context, but reconstructing cellular trajectories remains challenging due to the complex, nonlinear coupling between gene expression patterns and spatial positions. To address this, we present StPedf, a spatial trajectory inference method that integrates gene expression, spatial location, and neighborhood information. Built on a neural network framework, StPedf captures the nonlinear relationships between molecular features and tissue structure, and adaptively balances gene and spatial information through cell density, improving trajectory reconstruction. Across simulated datasets and multiple real biological datasets, StPedf outperforms existing methods in recovering spatial trajectories. The method reveals regeneration-associated trajectories in axolotl telencephalon, diverse expansion lineages in intrahepatic cholangiocarcinoma (ICC) dataset, and developmental trajectories in DLPFC. StPedf provides an accurate and interpretable tool for studying dynamic cell-state transitions in complex tissue microenvironments.

1. Introduction

Trajectory inference aims to reconstruct continuous biological processes from discrete single-cell data, serving as a core technology for deciphering cellular differentiation dynamics. Traditional trajectory inference methods (e.g., Monocle [1], Slingshot [2], PAGA [3], TSCAN [4], destiny [5], and scVelo [6]) have been widely applied in single-cell RNA sequencing (scRNA-seq) but suffer from fundamental limitations. First, these methods lack a spatial dimension and cannot reflect actual cell migration paths or the role of the spatial microenvironment. Cellular interactions in complex tissues often exhibit multicellular cooperative characteristics [7], making it difficult for trajectory inference based solely on non-spatial single-cell data to fully reconstruct the true evolutionary process. Second, their topological structures are simplistic, most methods effectively handle only linear or simple branching structures, struggling to accurately depict processes with complex spatial dynamics like brain regeneration, tumor metastasis, or embryonic development. Third, trajectory directionality is ambiguous. Although dynamic models like RNA velocity attempt to infer direction, they often generate non-physical reverse trajectories due to splicing noise. Breakthroughs in spatial transcriptomics have introduced new dimensions to trajectory inference. Spatial transcriptomics (ST) technologies (e.g., Stereo-seq [8], Slide-seq [910]) simultaneously capture gene expression and cellular spatial coordinates, theoretically revealing spatial cellular fate transitions. By integrating multimodal approaches such as eMCI [11] to further characterize cellular composition and potential cell–cell interactions within spatial domains, richer contextual information can be provided for subsequent spatial trajectory reconstruction. This offers unprecedented opportunities to decipher spatial heterogeneity in cellular states within tissues and map dynamic migration trajectories during regeneration, disease, and development [10].

At present, various cell trajectory inference approaches based on spatial transcriptomics data have been developed. These approaches can be broadly classified into two main categories. The first category involves distance-weighted fusion strategies, which integrate gene expression profiles with spatial distance information to infer trajectories. For example, stLearn [12] employs a pseudo-spatiotemporal algorithm (PSTS) that combines pseudo-temporal distances derived from gene expression and physical distances based on spatial coordinates, constructing a fused distance matrix via weighted averaging for use in diffusion-based pseudo-time trajectory inference. Spatrack [13] also adopts a distance-weighted fusion strategy, effectively combining spatial proximity and gene similarity to infer spatial cellular developmental pathways. The second category comprises spatially-aware dimensionality reduction embedding strategies. These approaches reduce the dimensionality of cells or specific multicellular spatial regions to generate low-dimensional embeddings that preserve both spatial and expression features, providing a foundation for subsequent trajectory inference. Cell-level embedding approaches are widely used, such as SpaceFlow [14], which utilizes a dual graph convolutional network and deep information maximization to learn embeddings retaining transcriptional similarity and spatial neighborhood structure, then applies diffusion pseudo-time algorithms to construct spatial trajectories. SEDR [15] employs a graph autoencoder with spatial attention mechanisms to learn low-dimensional representations enhancing resolution of complex spatial patterns, also using diffusion pseudo-time algorithms on embeddings for pseudo-spatiotemporal graph construction. SpatialPCA [16] builds upon probabilistic principal component analysis by modeling spatial correlations through a kernel matrix to incorporate spatial constraints, generating embeddings that preserve neighborhood relationships and interface directly with Slingshot for spatial trajectory inference. Methods for dimensionality reduction and embedding of multicellular spatial regions (niches) are less common, with ONTraC [17] being a representative example. This method treats multicellular niches as analytical units, constructing a niche network integrating spatial and cell-type information, applying graph convolutional encoding to extract low-dimensional spatial features, using graph pooling to identify niche clusters and build cluster networks, generating niche trajectories (NT), and finally mapping cell–niche associations to yield cell-level NT scores characterizing continuous tissue microenvironment variations.

Although the aforementioned methods represent significant progress in integrating spatial information, they exhibit clear limitations when inferring dynamic trajectories across multiple time points. As noted by Heitz et al.[18], existing algorithms either rely on rigid coupling between gene expression and space while ignoring tissue deformation or process each time point independently while neglecting intertemporal cellular continuity. Specifically, distance-weighted strategies are sensitive to tissue deformation, and their fixed-weight design cannot flexibly adapt to the varying importance of gene expression versus spatial constraints across different biological contexts. While dimensionality reduction and embedding methods can learn more robust feature representations, most fail to explicitly model the dynamic interplay between the temporal evolution of cellular states and spatial structure. Recent studies have explored optimal transport theory for cross-temporal slice alignment and trajectory reconstruction. For instance, PASTE [19,20] uses a hybrid Gromov-Wasserstein distance for slice registration, stVCR [21] introduces dynamic and unbalanced optimal transport algorithms to model cell displacement, and Spateo [22] utilizes morphometric vector fields to characterize continuous spatial structural changes. Optimal transport enables cost-minimizing mappings, intuitively quantifying differences between two distributions. It flexibly integrates diverse data as matching constraints—such as gene expression and spatial location information—to yield precise and interpretable correspondences. This supports high-precision analyses like trajectory inference and cellular communication. However, these approaches still face significant technical challenges in the joint optimization of spatial alignment and trajectory continuity, including high computational complexity, sensitivity to data quality, and limited generalization across datasets. Therefore, developing trajectory inference algorithms that can adapt to complex multi-temporal dynamic scenarios while preserving both spatial structure and cellular state continuity remains a critical research direction in spatial transcriptomics.

To overcome the aforementioned bottlenecks, we propose StPedf, a framework that integrates spatial proximity embedding with a spatial density-adaptive fusion mechanism. First, StPedf generates latent variable representations that fuse gene expression with spatial coordinates through a graph neural network architecture, effectively addressing the issue of insufficient integration between gene and spatial information in spatial transcriptomics. Second, StPedf reuses spatial proximity information as a guide, dynamically and adaptively adjusting the weight distribution between embeddings and spatial proximity based on spatial density. This overcomes the limitation of traditional methods in complex tissue structures, where balancing contributions from multiple information sources is inflexible, enabling adaptive weighting of multi-source information. Furthermore, StPedf explicitly constructs a cell transport map across time points based on optimal transport theory, fundamentally resolving the issue of disrupted cellular connections between consecutive time points. Finally, leveraging a unified latent variable representation, StPedf generates a cell migration velocity field, enabling quantitative and synchronized characterization of cellular differentiation directions. This approach addresses the challenges of consistency and interpretability in dynamic process inference. Results demonstrate that across five simulated datasets with distinct structures, StPedf exhibits significant competitive advantage over six mainstream trajectory inference algorithms. Experiments spanning scenarios such as brain regeneration in Western newts, tumor microenvironment evolution, and human DLPFC development (S1 Table) confirm StPedf’s efficacy in supporting in-depth analyses in developmental biology and disease research.

2. Results

2.1. Overview

The workflow of StPedf is illustrated in Fig 1. First, spatial transcriptomic gene expression data are input into a masked self-supervised deep autoencoder [2324] to generate a latent representation . Spatial coordinates from the same assay are used to construct a spatial expression map based on the α-complex. In this graph, nodes represent cells with their expression profiles, and edges denote spatial adjacency relationships between cells. A variational graph convolutional autoencoder (VGAE) [25] is then employed to fuse gene expression and spatial information into a joint embedding . A density-adaptive strategy dynamically balances the weights between high-density regions, which are dominated by embedding features, and low-density regions, which are guided by spatial information, resulting in a merged representation . When the initial embedding shows trajectory tendencies, weighted spatial information enhances these patterns. When the embedding structure is disorganized, spatial information helps correct the distortion. By combining deep feature extraction with adaptive fusion, gene expression features and spatial constraints are integrated synergistically. Using optimal transport [26], a transition matrix is derived. We sort the cells based on the probability of their transfer from a reference cell, and then use the resulting sorting results to construct a cell velocity vector field. The path of least action [27] is used to identify the optimal path between initial and terminal cells, enabling end-to-end analysis from raw data to trajectory inference, lineage segmentation, and pseudotemporal gene identification. Technical details are provided in the Methods section.

thumbnail
Fig 1. StPedf workflow diagram.

StPedf takes the gene expression (GE) matrix and spatial coordinates (XY) as input. A masking strategy is first applied to the gene expression matrix, and the masked features are encoded to obtain the feature embedding . In parallel, spatial coordinates are used to construct the spatial expression graph (SEG) via Alpha Complex, from which the graph embedding is learned. The two embeddings are then integrated into a joint latent representation . Based on this representation, StPedf computes a fused transport cost matrix in which denotes the distance between spots/cells i and in the joint embedding space, and denotes their Euclidean distance in the original spatial coordinate space. The relative contribution of the explicit spatial distance term is adaptively adjusted according to the local spatial density , yielding the density-aware weight . Here, approaches in high-density regions and in low-density regions. The resulting fused cost is used to construct the adaptive transition matrix based on optimal transport. This transition matrix is then used to assign the root, generate the pseudo-spatiotemporal map, infer lineage dynamics, construct the cell-state velocity field, organize trajectories, and identify pseudotime-dependent genes.

https://doi.org/10.1371/journal.pcbi.1014346.g001

2.2. Performance on different structural simulation datasets

To systematically evaluate the performance of StPedf, we construct five simulated datasets by superimposing spatial mapping patterns onto the dyngen simulator [28], with each dataset containing unspliced counts, spliced counts, and ground-truth developmental time information. Detailed parameter settings and the data-generation procedure are provided in the Supplementary Materials (S2 Table). Among these, simulated datasets 1–4 correspond to a bifurcating structure, a trifurcating structure with a linear spatial pattern, a trifurcating structure with a nonlinear spatial pattern, and an independent dual-path structure, respectively, whereas simulated dataset 5 further represents a multi-section, multi-timepoint scenario. The ground truth of the five basic simulated datasets (Sim1–Sim5) reflects clear developmental ordering, and StPedf effectively recovers the differentiation directions in these different topologies, accurately infers trajectory directionality, and reconstructs the pseudo-spatiotemporal map (Figs 2c and S1) and state-transition trend map (Figs 2d and S1).

thumbnail
Fig 2. Benchmark analysis using four simulated datasets.

a. Spatial distribution of cell types in the four simulated datasets. b. Spatial distribution of true values for the four simulated datasets. c. Pseudo-temporal-spatial distribution predicted by StPedf. d. Trajectories inferred by StPedf. e. Different methods applied to the group of simulated datasets, with the performance of each method evaluated using Spearman’s correlation and Kendall’s correlation between true values and the rankings of predictions made by each method.

https://doi.org/10.1371/journal.pcbi.1014346.g002

Under the same experimental conditions, we further compare StPedf with DPT, Monocle3, TSCAN, SpaTrack, SpatialPCA, and SpaceFlow, and use Spearman and Kendall correlation coefficients to evaluate the consistency between inferred pseudotime and true developmental time. The results show that StPedf achieves the best correlation performance on Sim1–Sim4 (Fig 2e and S3 Table), indicating that it more accurately recovers the true developmental order under different topological structures. For the more challenging multi-section time-series simulated dataset Sim5, we further compare StPedf with SpaTrack. The results show that StPedf recovers a more continuous global pseudotime gradient and more coherent state-transition trends in the shared embedding space (S1 Fig), while the globally projected pseudotime distributions of different lineages also show clear separation (S2 Fig). Quantitative evaluation further shows that StPedf outperforms SpaTrack in both global ranking consistency and section-wise pseudotime recovery accuracy (S3 Fig), indicating that StPedf more accurately reconstructs cell ordering consistent with the true pseudotime in multi-section, multi-timepoint settings.

In addition, we perform stability analyses across different random seeds on all five simulated datasets. For each dataset, StPedf is run independently 30 times using different random seeds, and Spearman and Kendall correlation coefficients are calculated between the inferred pseudotime and the ground-truth time. The results show that, except for Sim1, the other datasets exhibit high consistency and relatively small variation across random seeds (S4 Fig), suggesting that StPedf has good robustness and reproducibility across different topological structures and multi-section scenarios.

To validate the advantages of the secondary utilization of spatial information, the spatial density adaptive module, and the joint embedding of gene and spatial information, this work constructs three variants of StPedf (S5 Fig): StPedf w/o Spatial Reuse that removes the secondary utilization of spatial information, StPedf w/o Adaptive Density that removes the spatial density adaptation mechanism, and StPedf w/o Embedding that uses only raw gene information without joint gene-space embedding. Ablation experiments are conducted on five simulated datasets. Compared with the three ablation variants, StPedf yields higher average Spearman correlation coefficients and average Kendall rank correlation coefficients in the comprehensive evaluation over the five datasets. These results clearly validate the advantages of the three components in StPedf.

We also compare StPedf with DPT on embedding and PAGA on embedding, both based on the same embeddings. Both comparison methods use features generated by the embedding module in our framework as input. Quantitative results (S6 Fig) show that StPedf achieves the highest Spearman correlation coefficients and Kendall’s tau-2 correlation coefficients, significantly outperforming the combinations of “DPT on embedding” and “PAGA on embedding” Qualitative analysis (S7 Fig) further corroborates this finding. Across four simulated datasets, the pseudo-time fields inferred by StPedf exhibit exceptionally high spatial continuity and smoothness, accurately reflecting developmental trajectories. In contrast, results from DPT or PAGA inference using the same embeddings display noticeable local irregular fluctuations and pseudo-time jumps. This intuitively demonstrates that OT inference within the StPedf framework more effectively leverages the fused features provided by the embedding module, transforming them into continuous trajectories that satisfy physical spatial constraints. Even starting from identical feature bases, the OT inferencer employed by StPedf significantly outperforms traditional inferencers like DPT and PAGA. This validates the unique advantages of OT as a spatial trajectory inferencer and demonstrates the effectiveness of the overall StPedf framework design.

2.3. Analysis of the trajectory and lineage dynamics of telencephalon regeneration in the Ambystoma mexicanum

We apply StPedf to an Ambystoma mexicanum telencephalon dataset, reconstructing the spatial trajectories of telencephalon regeneration following injury in Ambystoma mexicanum. Brain regeneration requires the coordinated activation of complex responses in a time- and region-specific manner. Spatial transcriptomics data highlight the spatial characteristics of cells in the telencephalon of Ambystoma mexicanum during developmental and injury-induced regeneration processes [29]. Further characterization of the activation and functional regulation of ependymal glial cells may provide new insights into enhancing brain regeneration in mammals. Based on previous studies, the regeneration process primarily occurs between 5 DPI and 20 DPI, so we select data from five time points (5, 10, 15, and 20 DPI) and use StPedf to construct detailed local trajectories of telencephalon regeneration in the Ambystoma mexicanum.

At 15 days post-injury (15 DPI) in the axolotl telencephalon regeneration sample, previous studies have shown that injury induces a continuous regenerative program involving reactive ependymoglial cells (reaEGCs), regeneration intermediate progenitor cells (rIPC1s), immature neurons (IMNs), and excitatory neuronal states including Nptx1-expressing excitatory neurons (nptxEXs) [29,30]. Based on this established biological background, we first illustrated the spatial expression patterns of several key regeneration-related marker genes in the tissue (Fig 3a), and further compared the dynamic expression of representative marker genes across different regeneration-related cell states (Fig 3b). A regeneration-specific transitional cell population was observed between reactive ependymoglial cells and immature neurons, corresponding to regeneration intermediate progenitor cells [3132]. As shown in Fig 3b, this transitional population co-expressed marker genes associated with reactive ependymoglial cells (such as VIM, NES, KRT18, and S100A10) and marker genes associated with immature neurons (such as ANKRD1, STMN4, and NPTX1). These marker genes exhibited dynamic changes, reflecting the progression of cell states from injury response through progenitor transition to neuronal differentiation and maturation. Among them, KRT18 expression gradually decreased, suggesting the loss of epithelial-like or progenitor features, whereas VIM expression also progressively declined, indicating the gradual attenuation of reactive glial and migration-related characteristics. Fig 3c shows the spatial distribution of different cell states in the tissue. On this basis, StPedf reconstructed the pseudo-spatiotemporal map of the 15 DPI regeneration sample (Fig 3d) as well as more detailed internal regenerative trajectories (Fig 3e). To further characterize the continuous transition paths of different regenerative branches, we applied the least action path (LAP) algorithm (S1 Note) to analyze three representative trajectories.

thumbnail
Fig 3. StPedf constructs the brain regeneration trajectory of Ambystoma mexicanum.

a. A spatial visualization heatmap shows the expression patterns of key markers associated with cell regeneration in the injured region of the slice. b. A bubble plot reflects the expression dynamics of the reegc, rIPC1, and IMN marker genes, which are the primary cell types involved in Ambystoma mexicanum telencephalon regeneration. c. Spatial distribution of cell types during the 15th day regeneration phase. d. Pseudo-spatiotemporal plot of the 15th day regeneration phase following telencephalon injury in Ambystoma mexicanum e. Spatial trajectory of the 15th day regeneration phase following telencephalon injury in Ambystoma mexicanum. f. Shortest paths of lineages 1, 2, and 3 expanding in space during the 15th day regeneration phase following telencephalon injury in Ambystoma mexicanum. g. Complete regeneration trajectories obtained by integrating four samples. The UMAP plot shows a total of 2,880 cells. h. Trends in the pseudo-temporal dependence genes SLC1A3, GFAP, VIM, SPARC, SYP, and SYN1 of lineage 1, selected by fitting a generalized additive model.

https://doi.org/10.1371/journal.pcbi.1014346.g003

Lineage 1 corresponds to the regenerative pathway from the wound center to the right margin of the telencephalon, enriched with injury response pathways (such as glial cell activation-related pathways), progenitor cell proliferation and differentiation pathways, and neuronal maturation-related pathways. Gene expression changes over pseudo-time (Fig 3h and S2 Note) show that during the injury response phase dominated by reaEGCs, genes associated with glial activation, such as SLC1A3 and GFAP, are highly expressed. During the progenitor cell transition phase, genes such as VIM and SPARC exhibit dynamic expression changes, aligning with the functional transition of rIPC1s from reaEGCs differentiation to neuronal maturation. During the neuronal maturation stage, synaptic-related genes such as SYP and SYN1 are significantly upregulated, indicating the maturation of nptxEXs. Along the cellular differentiation axis, reaEGCs initiate repair, rIPC1s bridge the injury zone and the neuronal maturation zone, IMNs initiates electrophysiological function initialization, and nptxEXs completes functional reconstruction, with a clear hierarchical structure. This lineage reveals the core pathway from injury response to neuronal regeneration and functional recovery in the brain of the Ambystoma mexicanum following injury. The changes in SLC1A3, VIM, GFAP, and SPARC over pseudo-time as demonstrated by ISORT tend to rise more prominently in the middle to late stages (S9 Fig). While it exhibits some ability to distinguish between internal states within lineages, its differentiation between early initiation states and terminal maturation states, as well as the degree of recovery, is less clear than that of StPedf.

Lineage 2 and lineage 3 also exhibit functional specificity during telencephalon regeneration in Ambystoma mexicanum. Each lineage demonstrates distinct mechanisms of action, regulatory orientations, and adaptive environments (Figs 3f, S8a, and S8b). Lineage 2 corresponds to the dorsal lesion zone of the telencephalon and is the key lineage for dorsal neural circuit regeneration. It involves multiple overlapping pathways related to progenitor cell differentiation and neuronal subtype specialization, ensuring that specialized neurons adapt to the structural and functional demands of the dorsal telencephalon and the complex regenerative microenvironment. Lineage 3 corresponds to the medial non-injured region of the telencephalon, serving as the foundational lineage for maintaining normal telencephalic neural homeostasis. It is enriched with pathways related to normal development (e.g., neural developmental stemness maintenance pathways) and functional maintenance of mature neurons. Lineage 1 and 2 originate from injury-responsive subpopulations like reaEGCs, guided by signals from the wound surface and dorsal injury microenvironment to differentiate into functionally specialized regenerative lineages. Lineage 3 originates from wntEGCs, guided by the developmental microenvironment of the medial non-injured zone to maintain normal developmental trajectories. Lineage 1 drives neural circuit regeneration in specific regions, Lineage 2 adapts to the regenerative demands of complex dorsal areas, and Lineage 3 maintains normal brain region function. These three lineages synergistically propel the regenerative process from injury to partial functional recovery and overall homeostasis maintenance in the telencephalon, collectively supporting the orderly progression of the axolotl’s telencephalon regeneration.

To overcome the limitations of single-time-point spatial transcriptomics data in analyzing continuous evolution, we conduct multi-time-point analysis to validate the findings from the spatial analysis. We select spatial transcriptomics data from four time points—D5, D10, D15, and D20—following telencephalon injury in axolotls, covering the entire progression from “early injury response” to “regeneration peak” to “repair and remodeling.” StPedf independently calculates cell transition probabilities at each time point, using reactive ependymal glial cells (reaEGCs) and regenerative intermediate progenitor cells (rIPC1s) as starting points. By integrating all probability matrices, it overcomes the single-time constraint, combining spatial transcriptomic data from multiple time points (D5–D20) to construct a complete trajectory of telencephalon regeneration (Fig 3g). StPedf captures numerous intermediate cells like rIPC1s and IMNs. Their lineage transitions along pseudo-time further validate the reaEGC–rIPC–IMN–nptxEX model, demonstrating trajectory continuity. Compared to single-time-point analysis, the multi-time-slice integration yields more continuous trajectories, revealing the dynamic linkage mechanisms between injury response, progenitor cell proliferation, and neuronal functional maturation. It also highlights the core process whereby reaEGCs repair the wound through proliferation and differentiate into mature neurons. [30,33]

To systematically evaluate the ability of different methods to characterize the dynamic process of telencephalon regeneration in newts, we further compare the pseudo-spatiotemporal reconstruction performance of StPedf with that of Monocle3, Slingshot, SpaceFlow, and ISORT on this dataset (S10 Fig). Monocle3 exhibits substantial noise, whereas Slingshot captures a global trend, although this trend remains weak. Both Monocle3 and Slingshot fail to clearly connect progenitor-like states at the injury center with the outwardly expanding intermediate and mature states. SpaceFlow fails to reconstruct an effective pseudo-spatiotemporal structure in Ambystoma mexicanum data, with a severely constrained pseudotemporal dynamic range. Most cells are compressed into early states, and only a few discrete regions display localized terminal signals, resulting in a lack of interpretable spatial gradients. ISORT shows a certain degree of spatial stratification, but its trajectory directions contradict the known regeneration sequence. Trajectory streamline plots further reveal that ISORT produces disordered flow patterns with local reverse convergence, and reaEGC-associated regions are incorrectly identified as terminal states. In contrast, StPedf reconstructs a continuous, smooth, and directionally coherent pseudo-temporal gradient. Its streamline map displays more natural and coherent flow patterns, clearly depicting the progressive dynamic process from the regeneration initiation zone to the differentiation termination zone.

In summary, StPedf’s reconstructed dynamic model of telencephalon regeneration in the Ambystoma mexicanum systematically reveals the cross-scale regulatory mechanisms of “injury response-cell transformation-functional reconstruction” in neural regeneration, from molecular characteristics and lineage differentiation to spatiotemporal trajectories.

2.4. Characterization of tumor lineage differentiation and spatiotemporal heterogeneity

The tumor microenvironment often contains more complex spatial structures and a higher degree of cellular heterogeneity. Tumor spatiotemporal heterogeneity profoundly affects tumor progression and therapeutic response, and represents a core challenge in precision medicine [34]. In this study, we use spatial transcriptomic data from primary ICC tumors and adopt the malignant subset classification identified by Wu et al. [35] based on expression profiles and spatial neighborhood information. Primary ICC tissue contains eight tumor subclones (P0–P7) with significant molecular differences (Fig 4a). These subclones show heterogeneous spatial distribution, among which boundary regions are enriched with features such as immunosuppressive signals and metabolic reprogramming, suggesting that clones undergo directional evolution along spatial directions. In the P0 subclone, multiple genes are coordinately highly expressed (Figs 4b and S11). For example, stemness markers (SOX9, EPCAM) cooperate with epithelial genes (CDH1) to maintain cellular stemness and epithelial structural properties. Meanwhile, active cell-cycle genes (CDK1, MKI67) in P0 drive rapid proliferation, indicating that the P0 subclone acts as tumor-initiating cells to drive heterogeneous evolution. We use StPedf to reconstruct cellular evolutionary trajectories starting from P0, identify three independent lineage origin patterns (Figs 4c, 4d, and S6a), and dissect the functional enrichment characteristics and spatial distribution rules of different tumor cell lineages, revealing the spatial differentiation logic of tumor progression.

thumbnail
Fig 4. StPedf constructs the trajectory of tumor lineage differentiation.

a. Spatial distribution of tumor subclones. b. Expression levels and proportions of target genes in each subclone. c. Pseudo-spatiotemporal map and spatial trajectory map of tumor expansion. d. The shortest paths of the three lineages in tumor spatial expansion, labeled in red, blue, and green, respectively. e. Functional annotation of pseudo-temporal dependent genes in the three lineages. f. Trends in gene expression changes.

https://doi.org/10.1371/journal.pcbi.1014346.g004

The key challenge in the ICC dataset is not merely to recover a smooth pseudo-spatiotemporal map, but to reconstruct a spatiotemporal organizational pattern that is consistent with the tumor-initiating clone, spatial branch expansion, and boundary invasion programs. Comparison of the pseudotime visualizations (S12a Fig) generated by different algorithms shows that Monocle produces a highly noisy pseudotime distribution, with pronounced local interleaving of high- and low-value regions. Although Slingshot yields a smoother pattern than Monocle, it primarily reflects large-scale regional differences and fails to adequately capture the gradual transitions among neighboring clones within the tumor. SpaceFlow shows a severely restricted pseudotime dynamic range, with the vast majority of locations compressed into the initial stage and only a very small number of regions displaying localized high values, thus failing to form a continuous gradient. Although ISORT captures some degree of regional heterogeneity, it does not correctly identify the initiating cluster. In the comparison of trajectory streamline patterns (S12b Fig), ISORT generates relatively rich streamlines, but exhibits obvious local convergence and directional perturbation overall, with some trajectories ultimately pointing toward the central region. By contrast, StPedf not only accurately captures the pseudotemporal sequence from the early tumor center to the late tumor periphery, but also preserves the natural continuous transitions within regions and recovers the processes of multidirectional clonal expansion and boundary invasion.

To clarify the biological differences between different lineages, we use the LAP algorithm for inference, screened out trajectory-dependent genes along the optimal differentiation path, and perform pathway enrichment analysis on each lineage (Figs 4e and S13). Lineage 1 (P0-P5-P6) corresponds to the tumor apical expansion zone, enriched for cell-substrate adhesion regulation, apoptosis and death regulation, and NF-κB stress response pathways. It achieves local colonization through adhesion regulation and stress adaptation, does not participate in distant metastasis processes, and serves a spatial filling function. Lineage 2 (P0-P1-P2-P7) corresponds to the tumor-liver parenchyma boundary invasion zone, enriched in mitogen-activated protein kinase (MAPK) pathway regulation (such as ERK1/ERK2 cascades, positive regulation of MAPK cascades), fibroblast proliferation regulation, and negative regulation of coagulation pathways, highly compatible with the invasive microenvironment at the tumor - liver parenchyma boundary invasion microenvironment, activating metastasis signals and remodeling the microenvironment, thereby becoming the core subgroup driving distant metastasis. Among the genes associated with lineage 2 (Fig 4f), EMT-related genes (e.g., FN1, VIM) exhibit synergistic fluctuations, aligning with the requirements of the tumor “breakthrough-colonization” stage and constituting the core molecular characteristics driving tumor boundary invasion. Immune suppression genes (such as SAA1, SAA2 [36]) are highly expressed locally in the later stages, dynamically reflecting the construction process of the immune-suppressive microenvironment. Gradiently upregulated genes (such as MMP7, CD74) show progressive increases in expression over pseudo-time, dynamically presenting a series of processes involving the degradation of extracellular matrix components and the antagonism of the immune response against tumors. Basal maintenance genes (such as RPS15A and NRG1) are stably highly expressed, providing continuous energy support for invasion. The expression trends of these genes all reflect the role of lineage 2 in breaking through the tumor boundary and initiating metastasis. The genes SAA1, SAA2, and CD74 recovered by ISORT primarily exhibited a decline with pseudo-time, while MMP7 and NRG1 showed weaker changes (S14 Fig). The gene expression patterns over pseudo-time reveal that ISORT is more sensitive to the transition from early-stage immune activity to late-stage attenuation within lineages. However, ISORT does not clearly reflect the late-stage enhancement of the tumor border invasion program as distinctly as StPedf. Lineage 3 (P0-P3-P4) corresponds to the metabolic zone at the bottom of the tumor, enriched with protein translation (such as cytoplasmic translation and gene expression), ribosomal biogenesis, and peptide/macromolecular biosynthesis pathways. By reinforcing anabolic metabolism to sustain core proliferation, it lacks active metastatic potential but provides metabolic support for tumor development.

All three lineages originate from tumor subclone P0, but diverge into functionally distinct subpopulations guided by microenvironmental signals including mechanical stress in the apical zone, immunosuppressive signals at the tumor margin, and metabolic stress in the basal zone. Lineage 1 fills the apical space to expand the tumor mass, Lineage 2 breaches the tumor boundary to initiate metastasis, and Lineage 3 enhances core metabolism to sustain proliferation. The synergistic evolution of these distinct lineages drives overall tumor expansion. Understanding the functions of each lineage facilitates targeted drug development to precisely strike different functional units within the tumor.

2.5. Reconstruction of the pseudo-spatiotemporal relationships and developmental trajectories of human DLPFC

In the human DLPFC sample 151673, we successfully reconstruct biologically plausible cortical developmental trajectories using StPedf. It is known that development begins in white matter (WM) and progresses through layers 6, 5, 4, 3, and 2 [14,37,38]. StPedf reveals pseudo-spatiotemporal relationships between cells, and the resulting pseudo-spatiotemporal map (pSM) differs significantly from traditional pseudo-temporal analysis, which focuses solely on intercellular expression similarity. The pSM integrates spatial positional relationships between cells with transcriptional expression patterns, overcoming the limitations of traditional methods that rely solely on transcriptional similarity. This provides a more comprehensive and biologically relevant analytical dimension for studying cortical developmental trajectories.

To investigate the biological functions associated with the pseudo-temporal developmental trajectories of the DLPFC, we further perform gene set enrichment analysis on genes showing significant changes along the pseudo-temporal sequence (S15 Fig). Multiple highly significant neurobiological functional enrichments are identified, including synaptic signaling, neurotransmitter transport, positive regulation of neuronal projection development, and regulation of NMDA receptor activity. The identified pseudotime-associated genes validate that our constructed pseudotime trajectories effectively capture key processes of neuronal functional maturation and synaptic assembly, while providing crucial molecular-level insights into cellular dynamics during cortical layer formation.

In the spatial visualization of pseudo-time generated by the traditional single-cell pseudo-time algorithms Monocle and Slingshot, we observe that the pseudo-spatiotemporal maps produced by Monocle and Slingshot lack hierarchical patterns and exhibit significant noise (Fig 5a). Furthermore, Monocle displays developmental trajectories from intermediate layers to WM layers and layer 1, which is inconsistent with the actual developmental sequence. In contrast, the three tested spatially-aware algorithms—SpaceFlow, ISORT [39], and StPedf—all produce layered pSM with clear, smooth color gradients (Fig 5a), indicating a pseudotemporal sequence from white matter (WM) to layer 1. This sequence reflects the correct in-to-out developmental order of the cortex, the layered spatial organization of the tissue, and underscores the importance of spatial information. Among these, SpaceFlow exhibits distinct and smooth color gradients, yet it has limitations in maintaining consistency of spatial structures both within and across cortical layers. ISORT gradients are less smooth and exhibit noticeable noise. StPedf more precisely corresponds to the layered spatial organization, better preserving spatial structures both within and across cortical layers. This enables clearer interpretation of the relationship between spatial structure and biological stratification. Compared to SpaceFlow and ISORT, StPedf offers superior advantages in reconstructing authentic tissue spatial stratification, developmental associations, and gradient smoothness. Regarding cell velocity comparisons (Fig 5b), both SpaRNA velocity from ISORT and StPedf permit visualization of detailed intra-layer growth. However, ISORT exhibits cross-layer reverse trajectories—specifically, arrows pointing from Layer 3 toward deeper regions like Layer 5/6—alongside disordered trajectories lacking stratification associations. manifested as arrows randomly traversing within Layer 4. In contrast, StPedf displayed correct growth trajectories from WM to sequence layers.

thumbnail
Fig 5. Comparison of StPedf with other DLPFC pseudo-spatiotemporal and trajectory analysis methods.

a. Pseudo-spatiotemporal maps inferred by Monocle, Slingshot, SpaceFlow, ISORT, and StPedf. b. Inferred spatial trajectories of sample ID151673 inferred by ISORT and StPedf in physical space.

https://doi.org/10.1371/journal.pcbi.1014346.g005

It is important to emphasize that only StPedf can more closely match the actual layering of the cortex, demonstrating a smooth progression between adjacent layers and a higher degree of color gradation that matches the spatial organization of cortical development. At the same time, the speed obtained reconstructs the correct growth trajectory from WM to the sequence layer, visualizing the detailed internal growth within the layer.

3. Discussion

In this work, we propose StPedf, which encodes spatial transcriptomic data into low-dimensional embeddings via deep learning. It adaptively fuses these embeddings with spatial information through density-based spatial integration, leveraging spatial guidance to derive cell-to-cell transition matrices through optimal transport for trajectory inference. By integrating graph neural networks with convolutional neural networks, the model naturally captures the complex nonlinear interactions between high-dimensional gene expression and spatial topology, reconstructing continuous evolutionary pathways of cellular states. Pseudo-spatiotemporal graphs reveal spatiotemporal relationships among cells or points within spatial transcriptomics data, while velocity visualization details internal growth dynamics. Cell trajectories across temporal samples can be directly tracked via OT mapping.

To evaluate the performance of StPedf, we test it on five simulated datasets (Figs 2 and S3). Sim1–Sim4 are used for benchmarking against other mainstream trajectory inference methods, including SpaTrack, DPT, Monocle3, TSCAN, SpatialPCA, and Spaceflow. Sim5 is used for a direct comparison with SpaTrack. The results demonstrate that StPedf achieves superior performance in all comparisons. Furthermore, we conduct ablation studies on all five simulated datasets using three variants: without Spatial Reuse, without Adaptive Density, and without Embedding. The results further confirm the advantages of StPedf. The results of these experiments (S5 Fig) show that incorporating spatial reuse, adaptive density utilization, and joint gene-space embedding improves the accuracy of trajectory inference while adaptively balancing the contributions of spatial and gene information, further confirming StPedf’s advantages. We further assess StPedf’s performance on three key spatial transcriptomics datasets from different species and biological contexts: brain regeneration in the Ambystoma mexicanum, tumor expansion and metastasis, and human DLPFC development. In Ambystoma mexicanum dataset, StPedf accurately reconstructs the regeneration dynamics model of the telencephalon at both single and multiple time points (Fig 3e and 3g). In the tumor dataset, StPedf successfully reconstructs cellular spatial trajectories starting from point P0 and identifies three distinct differentiation patterns with independent lineage origins (Fig 4c and 4d). In the DLPFC dataset, comparative analysis shows that mainstream methods such as Monocle, Slingshot, and Spaceflow fail to construct meaningful cell velocity fields. While ISORT produces trajectories, they appear disorganized and lack hierarchical relationships. Only StPedf generates trajectories that closely correspond to the actual cortical layering structure. It not only reveals smooth transitions between adjacent cortical layers but also shows strong alignment between trajectory color gradients and the spatial organization of cortical development (Fig 5a). Furthermore, StPedf accurately reconstructs developmental trajectories from white matter (WM) through successive cortical layers and visualizes detailed growth dynamics within each layer (Fig 5b). To further support the rationale of the original adaptive explicit spatial fusion module, we perform ablation experiments on both the Ambystoma mexicanum telencephalon regeneration dataset and the ICC tumor dataset, in which the adaptive explicit spatial fusion module is removed from the transition construction while the embedding term is kept unchanged. The results show that, after removing this module, the global state-transition trend plots display disordered local flow-field directions and reduced coherence (S17a and S17c Fig), while the pseudotime distributions become noticeably noisier, with fragmented local trajectories and reduced overall continuity (S17b and S17d Fig). In contrast, the full model recovers smoother and more coherent local flow fields and pseudotime gradients (Figs 3 and 4). These results indicate that the role of the adaptive explicit spatial fusion module is not to impose biological importance on high- or low-density regions, but rather to robustly balance spatial constraints and expression differences, thereby substantially improving the local continuity and overall robustness of trajectory inference in real tissues.

StPedf has demonstrated strong capability for spatial trajectory inference across complex biological contexts, providing a new computational framework for characterizing the spatial features of cell-state evolution. However, the current study still has several aspects that warrant further improvement. First, StPedf does not yet incorporate prior information such as cell–cell communication networks and dynamic regulatory cues into transition matrix construction, which limits its ability to characterize the relationship between microenvironmental signals and cell-state transitions. Second, although StPedf supports joint multi-slice analysis based on a shared embedding space, the current framework still relies on known temporal ordering or prior alignment information, and has not yet achieved automatic alignment of multiple slices or unified spatiotemporal trajectory inference. With the integration of more prior biological knowledge and further advances in multi-slice spatiotemporal modeling, StPedf is expected to enable more precise and systematic analysis of cell-fate dynamics in complex tissues.

4. Conclusion

In summary, StPedf effectively integrates high-dimensional gene expression with spatial topology information, fully leveraging spatial data to precisely reveal the continuous spatiotemporal evolution of cellular states. It demonstrates robust and unified analytical capabilities across diverse complex biological processes, including regeneration, development, and disease. It provides a powerful computational tool for understanding the spatial regulation of gene expression and cellular fate transitions, excels in cross-species and cross-scenario analyses, and offers critical technical support for theoretical life science research and clinical medical applications—such as tumor metastasis prediction, regeneration mechanism analysis, and brain development studies.

5. Methods

5.1. Spatial map construction based on Alpha Complex

In order to capture the spatial adjacency relationships between cells or spots, we construct a graph structure from the original spatial coordinate information:

(1)

where the node set represents all cells/spots, with each node accompanied by its corresponding gene expression vector, the edge set describes the spatial adjacency relationship between nodes. Next, we use the Alpha Complex method [40] to construct a Voronoi diagram and extract its one-dimensional skeleton as the adjacency edge set . For each position , its Voronoi cell is defined as:

(2)

where is the set of coordinates for all points, and denotes the Euclidean distance. Next, use the one-dimensional skeleton of Alpha Complex to determine the adjacency relationship:

(3)

where is a two-dimensional circular disk region with a center of and a radius of . Take the average distance of the k nearest neighbors for each point. Then, the final adjacency matrix is defined as follows:

(4)

Since most nodes are not adjacent to each other, the adjacency matrix is usually sparse. Therefore, we use sparse matrix storage to save memory and computing resources. Data preprocessing is described in S3 Note.

5.2 Mask input generation

We mask the original gene expression matrix. Let the original expression matrix be , where denotes the number of cells/spots and denotes the gene dimension. We randomly select nodes from V to form a subset and mask the expression vectors of these nodes, replacing them with learnable vectors . The masked expression matrix is defined as follows:

(5)

The definition mask reconstruction loss is as follows:

(6)

5.3 Joint encoding of feature embedding and graph embedding

Using a dual-path encoding framework, gene expression features and spatial topological structures are processed independently, and features are fused in the latent space. The feature embedding encoder consists of two fully connected layers, which map the masked expression matrix to a low-dimensional feature representation , i.e.,:

(7)(8)

where are learnable parameters, and the output is the feature embedding of gene expression. This design uses a low-dimensional representation learning () model to mine gene co-expression patterns, forcing the model to learn gene co-expression patterns, while ReLU activation ensures feature non-negativity.

The graph embedding encoder uses a two-layer graph convolutional network (GCN) with the spatial adjacency matrix and feature representation as inputs, and outputs a space-aware graph embedding . The normalization matrix is constructed as follows:

(9)(10)

where is the adjacency matrix after adding self-loops, is its degree matrix, and the probability parameters are generated after obtaining the normalized matrix:

(11)(12)(13)

where , specifically, the operation form of the first layer GCN is:

(14)

where is the activation function and is the learnable parameter. Next, mean field probability modeling is performed, assuming that the output of the last layer is a graph embedding , which follows an isotropic Gaussian distribution:

(15)

next, we perform differentiable sampling:

(16)

The output is a spatial perception embedding, and its variance term quantifies positional uncertainty. Finally, gene expression features and spatial topological information are fused through a concatenation operation:

(17)

where represents the gene feature embedding dimension, represents the spatial embedding dimension, and represents matrix row concatenation. This joint embedding retains both gene expression characteristics and spatial topological constraints, providing downstream tasks with information-rich representations. In the implementation of joint feature embedding and graph embedding, the random seed is fixed to 2025 to ensure the determinism of model weight initialization and subsequent training.

5.4. Multi-task training objectives

The training consists of two stages. The first stage is pre-training, where the model learns general embeddings by minimizing the following loss function:

(18)

where represents the fixed weighting for each type of loss.

The second stage optimizes the embedding space based on pretraining to enhance clustering performance. First, K-means initializes cluster centers on the pretrained embeddings, then minimizes the following loss:

(19)

where represents the fixed weighting for each type of loss. At this stage, the mask reconstruction loss was removed to avoid conflict with the clustering objective, and a depth clustering loss was introduced. The clustering loss serves as an auxiliary regularization term. It is used to further stabilize the local structure, improve the robustness of embedding representations, and enhance the stability of downstream trajectory inference based on the pre-trained embeddings. After removing the clustering loss (S18 Fig), both the Spearman correlation coefficients (S18a Fig) and Kendall correlation coefficients (S18b Fig) between the model predictions and the ground-truth time labels decreased across the simulated datasets. For detailed information on the two-stage loss function, please refer to S4 Note.

5.5. Cell density-aware adaptive weighting mechanism and low-confidence region protection

To quantify the local cell distribution density, spatial density is introduced, and a continuous density field is constructed using Gaussian kernel density estimation. For any cell , its density estimate is defined as:

(20)

where is the spatial coordinate of the cell (typically the two-dimensional position of the tissue section), standardized Gaussian kernel function, is the kernel function bandwidth parameter (default value), which controls the spatial resolution of density estimation. This equation performs a weighted sum of cells surrounding the cell using the Gaussian kernel, then generates the density value through an exponential transformation. This equation enhances the numerical contrast between high- and low-density regions while compressing the dynamic range of the original summation result to prevent numerical overflow. To eliminate the interference of global density differences between different tissue samples, is normalized using Min-Max normalization:

(21)

where is a smoothing parameter that ensures the denominator is not zero. After normalization, we obtain , where corresponds to the cell with the highest local density in the sample, and corresponds to the cell with the lowest density. While retaining the relative density ranking, the values are strictly constrained to a fixed interval, providing standardized input for subsequent weight mapping. To achieve adaptive correlation between density and weight, a reverse correlation function is designed to map normalized density to spatial weight :

(22)

the lower bound ensures that even in the highest-density regions , spatial information is not completely ignored, thereby preventing the joint embedding from becoming overly dominant. The upper bound , in turn, ensures that in low-density regions , spatial proximity can become the dominant factor. When , and thus , so the transition matrix is mainly governed by similarity in the joint embedding space. Conversely, when , , and the transition matrix is mainly governed by spatial proximity. This adaptive mechanism flexibly balances gene expression and spatial information according to the local cellular environment, while the dataset-specific choice of accounts for variations in tissue architecture, density distribution, and trajectory complexity across different experiments. In high-density regions, many cells are already geometrically close to each other, and the original Euclidean distance is often highly redundant. Reducing the contribution of at this stage avoids over‑strengthening local geometric proximity, thereby maintaining sensitivity to weak but potentially important expression differences. In low-density regions, spatial separation is more discriminative. Appropriately strengthening spatial constraints helps prevent unreasonable connections between cells that are transcriptionally similar but spatially disconnected. Detailed parameter descriptions can be found in S5 Note.

Low density does not always represent a biological signal, it can also arise from technical artifacts such as tissue edges, section tearing, hole-like sparse regions, or areas with poor local connectivity. To address this, we introduce a low-confidence region protection mechanism. We automatically identify spots potentially affected by technical factors using three types of local geometric and neighborhood statistical criteria: spots located at tissue edges, spots in hole-like sparse neighborhoods, and spots with unreliable local connectivity. For these low-confidence regions, we no longer apply the density-adaptive rule; instead, we directly assign a fixed conservative weight to prevent unreliable local density from dominating trajectory construction. For normal regions, spatial weights are still dynamically adjusted in the density-adaptive manner described above. The final weight is expressed as:

(23)

5.6. Adaptive fusion based on joint embedding and spatial prior knowledge

We separately compute the spatial distance between cells, denoted as , and the Euclidean distance derived from the joint embedding of gene expression and spatial information, denoted as . To ensure the comparability of these distance metrics, maximum normalization is applied to eliminate scale differences:

(24)(25)

where denotes the coordinate vector of cell in the original space, and denotes the joint embedding vector of cell .It should be emphasized that spatial information enters the model not only through the intercellular spatial distance, the upstream spatial graph construction and joint embedding learning term have already encoded the spatial structure. To effectively balance the spatial position constraints and the embedding information representation pattern, and to fully account for the non-uniformity of cell spatial distribution, we adjust the contribution of the explicit original spatial distance term and construct the comprehensive distance matrix :

(26)

this formula uses the local density weight of cells as a regulating factor to dynamically allocate the contributions of spatial distance and gene expression distance. In high-density regions : becomes the dominant factor, giving priority to retaining the joint embedding pattern; in low-density regions : becomes the dominant factor, giving priority to maintaining spatial topological consistency. In the comprehensive distance matrix , joint embedding provides advanced feature representation, while the original spatial coordinates provide key spatial structure a priori information for trajectory inference.

5.7. Generation of optimal transport transition probabilities based on entropy regularization

To quantify the possibility of cell-cell interactions, the Sinkhorn algorithm is used to solve the entropy-regularized optimal transport problem and construct the probability transition matrix , whose expression is:

(27)

constraints:

where is the Frobenius inner product, which measures the matching cost between transition probabilities and composite distances, (default value) is the entropy regularization coefficient, which controls the smoothness of the solution. The larger , the closer is to a uniform distribution. is the marginal distribution vector, here set to a uniform distribution , ensuring that the sum of the out-degree and in-degree of each cell is equal (consistent with the physical meaning that “the sum of transition probabilities from each cell to other cells is ”). In the generated matrix, the element represents the probability of functional association transition from cell to cell . High-probability transfer () corresponds to smaller cell pairs, i.e., cells with similar gene expression and spatial proximity; low-probability transfer ( ) corresponds to larger cell pairs, such as cell pairs with significant gene phenotype differences or spatially isolated cells.

To prevent cells from transferring all probability mass to themselves and to avoid the emergence of a trivial solution, we set the diagonal elements of the constructed fused distance matrix to a sufficiently large constant . Since both the spatial distance and gene expression distance have been normalized to the range , this value is significantly larger than all off-diagonal elements, effectively suppressing self-transition during the optimal transport solution and ensuring that the transition matrix reflects genuine intercellular relationships. Sensitivity analysis indicates that when , the transport matrix is insensitive to the specific value (S16 Fig).

5.8. Selection of starting cells

The StPedf method provides two strategies for defining initial cells based on prior knowledge: one is a selection method based on cell type, which specifies a specific cell type as the starting point for development.

(28)

where indicates the category label of cell , where is the target cell type. The second method is based on spatial coordinates and is suitable for cases where the location of the morphogenesis center is known. It uses the K-nearest neighbor algorithm to select neighboring cells:

(29)

where is the morphogenesis center coordinate, and k is the parameter for the number of neighboring cells. After determining the initial cell set , the algorithm constructs a transition probability matrix through an optimal transport model and calculates the cell development sequence using the probability accumulation method:

(30)

where represents the transfer probability from the starting cell to the target cell . Based on this probability distribution, the cells are sorted in ascending order.

(31)

where represents in ascending order among all cells. Finally, it is normalized to a pseudo-time parameter:

(32)

where is the total number of cells, . Biologically, corresponds to the initial stage of development (high differentiation potential), corresponds to the final stage of differentiation, and the intermediate value reflects the continuous transition stages of development.

5.9. Trajectory Inference strategy for multi-timepoint / section spatial transcriptomic data

Since a single timepoint or section is often insufficient to fully capture all cell states in a temporal biological process, joint analysis of multiple timepoints or sections can cover intermediate transitional states over a wider range and thus reconstruct continuous biological processes more completely. For this reason, we adopt an analytical strategy of “separate inference per sample, joint interpretation in a shared embedding space” for multi-timepoint and multi-section spatial transcriptomic data. First, cells from all timepoints or sections are concatenated row-wise to form a unified data object, while retaining the original spatial coordinates, time labels, and cell type annotations of each cell. On this basis, principal component analysis is performed using highly variable genes (with timepoints used as batch information during selection), followed by UMAP embedding to obtain a shared low-dimensional representation for all cells. This embedding space maps cells from different timepoints or sections into the same coordinate system, eliminating batch differences between samples while preserving the main biological continuity.

After the shared embedding space is constructed, the data is split into independent subsets by timepoint or section, and the corresponding coordinates of cells in the shared embedding space are extracted for each subset based on cell indices. For each subset, a starting cell state is first specified according to known biological background or prior knowledge, and StPedf is used within the subset to construct a cell–cell transition probability matrix to characterize local potential transition relationships. Pseudotime and velocity fields are then calculated based on this transition matrix. After trajectory inference is completed independently within each subset, the low-dimensional coordinates and velocity vectors inferred from different timepoints or sections are aggregated into the shared embedding space, and the overall trajectory trend is visualized through velocity field interpolation and streamline plotting on a unified grid.

5.10. Cell velocity calculation and trajectory construction methods

First, to accurately calculate cell migration speed, this study proposes a dual-modality neighbor selection strategy that integrates both spatial proximity and functional similarity. Specifically, for each cell , its neighbor set is defined as the union of spatial neighbors and embedded neighbors:

(33)

where represents the K-nearest neighbor set based on spatial coordinates (of size ), and represents the K-nearest neighbor set based on joint embedding (of size ). This mechanism emphasizes spatial continuity () in spatially sparse regions and functional similarity () in densely populated regions, effectively overcoming the computational challenges posed by tissue heterogeneity.

Secondly, cell velocity is defined as the probability-weighted displacement vector in the pseudo-time gradient direction. For cell , its velocity vector calculation model is:

(34)

where denotes the cell spatial coordinate, is the direction correction factor (when , take , otherwise take ), is the normalized transition probability, is the similarity weight between cells i and j, is the pseudotime value, and is the numerical stability constant. This model uses pseudo-time correction to ensure that the velocity direction aligns with developmental timing, while employing transition probabilities to quantify the strength of cell state transitions.

To visualize continuous trajectories, an adaptive Gaussian kernel is used to interpolate discrete velocities into a grid space:

(35)

where is the coordinate of the grid point, the Gaussian kernel function is , and the smoothing factor is dynamically adjusted to:

(36)

where represents the extreme value of the cell spatial coordinates, represents the base grid resolution (default 50), represents the density scaling factor (default 1.0), and represents the global smoothing coefficient (default 0.5). This adaptive mechanism maintains spatial continuity while adjusting the local resolution through the density parameter , enabling precise modeling of heterogeneous tissues. Finally, developmental trajectories are generated through the streamline integration of the grid velocity field.

Supporting information

S1 Note. LAP Extraction and Lineage Pseudotime Construction.

https://doi.org/10.1371/journal.pcbi.1014346.s001

(DOCX)

S2 Note. Generalized additive model fitting.

https://doi.org/10.1371/journal.pcbi.1014346.s002

(DOCX)

S4 Note. The two-stage training loss function comprises four primary loss terms.

https://doi.org/10.1371/journal.pcbi.1014346.s004

(DOCX)

S1 Table. Summary of the real-space transcriptomics RNA-seq datasets used in this study.

https://doi.org/10.1371/journal.pcbi.1014346.s006

(DOCX)

S2 Table. Summary of the simulated dataset used in this study.

https://doi.org/10.1371/journal.pcbi.1014346.s007

(DOCX)

S3 Table. Properties of Trajectory Inference Methods.

https://doi.org/10.1371/journal.pcbi.1014346.s008

(DOCX)

S1 Fig. Comparison of trajectory inference results between StPedf and SpaTrack on the multi-section simulated dataset (Sim5).

a. Visualization of StPedf on the shared UMAP embedding: from left to right, cells colored by time point, cells colored by ground-truth lineage, globally mapped pseudotime inferred by StPedf, and inferred spatial trajectories reconstructed by StPedf. b. Pseudotime coloring of StPedf in the original spatial coordinates of each time-point section (T1–T4), showing the continuous change of pseudotime along the differentiation path within each section. c. Inferred spatial trajectories of StPedf in the shared UMAP embedding for each time-point section (T1–T4). d. Visualization of SpaTrack on the shared UMAP embedding: from left to right, cells colored by time point, cells colored by ground-truth lineage, globally mapped pseudotime inferred by SpaTrack, and inferred spatial trajectories reconstructed by SpaTrack. e. Pseudotime coloring of SpaTrack in the original spatial coordinates of each time-point section (T1–T4). f. Inferred spatial trajectories of SpaTrack in the shared UMAP embedding for each time-point section (T1–T4).

https://doi.org/10.1371/journal.pcbi.1014346.s009

(DOCX)

S2 Fig. Global projected pseudotime distribution of different lineages in Sim5.

https://doi.org/10.1371/journal.pcbi.1014346.s010

(DOCX)

S3 Fig. Global pseudotime accuracy on Sim5.

https://doi.org/10.1371/journal.pcbi.1014346.s011

(DOCX)

S4 Fig. Stability analysis of StPedf on simulated datasets.

Effects of different random seeds on pseudotime inference results by StPedf. For each of the five simulated datasets, the method was run independently 30 times with distinct random seeds from 1 to 30. Spearman and Kendall correlation coefficients were calculated between the inferred pseudotime and the ground-truth time. Boxplots show the distribution of correlation coefficients across datasets, with overlaid scatter points representing results from each independent run.

https://doi.org/10.1371/journal.pcbi.1014346.s012

(DOCX)

S5 Fig. Stability analysis of StPedf on simulated datasets.

Effects of different random seeds on pseudotime inference results by StPedf. For each of the five simulated datasets, the method was run independently 30 times with distinct random seeds from 1 to 30. Spearman and Kendall correlation coefficients were calculated between the inferred pseudotime and the ground-truth time. Boxplots show the distribution of correlation coefficients across datasets, with overlaid scatter points representing results from each independent run.

https://doi.org/10.1371/journal.pcbi.1014346.s013

(DOCX)

S6 Fig. Comparison of StPedf with DPT on embedding and PAGA on embedding on Simulated Datasets.

Performance was evaluated by comparing Spearman correlations and Kendall’s rank correlation coefficients across three experiments: StPedf, DPT on embedding and PAGA on embedding.

https://doi.org/10.1371/journal.pcbi.1014346.s014

(DOCX)

S7 Fig. Comparison of StPedf with DPT on embedding and PAGA on embedding on Simulated Datasets.

Performance was evaluated by comparing Spearman correlations and Kendall’s rank correlation coefficients across three experiments: StPedf, DPT on embedding and PAGA on embedding.

https://doi.org/10.1371/journal.pcbi.1014346.s015

(DOCX)

S8 Fig. Content related to Ambystoma mexicanum regeneration trajectories.

a. Presents the spatial trajectories and corresponding optimal paths of three major lineage patterns (Lineage 1, Lineage 2, Lineage 3). Different colors and line styles indicate the spatial distribution and path characteristics of each lineage. b. Heatmaps of gene expression trajectories for each lineage (Lineage 1, Lineage 2, Lineage 3), illustrating trajectory changes at the gene expression level across lineages.

https://doi.org/10.1371/journal.pcbi.1014346.s016

(DOCX)

S9 Fig. Pseudotime-dependent genes in Ambystoma mexicanum lineage 1 (inferred by iSORT).

Expression trends of SLC1A3, VIM, GFAP, SPARC reveal via GAM fitting.

https://doi.org/10.1371/journal.pcbi.1014346.s017

(DOCX)

S10 Fig. Comparison of pseudo-spatiotemporal and trajectory analyses between StPedf and other methods on the Ambystoma mexicanum telencephalon regeneration dataset.

a. Pseudo-spatiotemporal maps inferred by Monocle, Slingshot, SpaceFlow, iSORT, and StPedf. b. Inferred spatial trajectories reconstructed by iSORT and StPedf.

https://doi.org/10.1371/journal.pcbi.1014346.s018

(DOCX)

S11 Fig. Spatial Expression Patterns of Target Genes.

Scatter plots showing the spatial expression of EPCAM, CDH1 and CD44 genes. Each plot uses distinct colors to represent gene expression levels, with the color bar on the right indicating the numerical range of expression quantities. These plots demonstrate the differences in expression distribution of the corresponding genes within the tissue space.

https://doi.org/10.1371/journal.pcbi.1014346.s019

(DOCX)

S12 Fig. Comparison of pseudo-spatiotemporal and trajectory analyses between StPedf and other methods on the ICC dataset.

a. Pseudo-spatiotemporal maps inferred by Monocle, Slingshot, SpaceFlow, iSORT, and StPedf. b. Comparison of inferred spatial trajectories reconstructed by iSORT and StPedf.

https://doi.org/10.1371/journal.pcbi.1014346.s020

(DOCX)

S13 Fig. Details of tumor regeneration trajectories.

a. Spatial trajectories and corresponding optimal paths for the three major lineage patterns (Lineage 1, Lineage 2, Lineage 3). b. Gene expression trajectory heatmaps for each lineage (Lineage 1, Lineage 2, Lineage 3), illustrating trajectory changes at the gene expression level across different lineages.

https://doi.org/10.1371/journal.pcbi.1014346.s021

(DOCX)

S14 Fig. Pseudotime-dependent genes of ICC lineage 2 inferred by ISORT.

Expression trends of pseudotime-dependent genes (SAA1, SAA2, MMP7, CD74, NRG1) in lineage 2 are identified by fitting a generalized additive model (GAM).

https://doi.org/10.1371/journal.pcbi.1014346.s022

(DOCX)

S15 Fig. Enrichment analysis results for gene sets of pseudo-temporally correlated genes in the DLPFC.

https://doi.org/10.1371/journal.pcbi.1014346.s023

(DOCX)

S16 Fig. Sensitivity analysis of hyperparameters in the model.

a. Sensitivity to the diagonal term parameter. The diagonal term parameter is varied from to , with set as the baseline. For each value, the corresponding optimal transport (OT) matrix is computed, and the Pearson correlation coefficient (PCC) is calculated between this matrix and the OT matrix obtained under the baseline parameter. b. Sensitivity to the regularization parameter reg. The regularization parameter reg is varied from 0.1 to 1 in steps of 0.1. For each reg value, the corresponding OT matrix is computed, and the PCC between this matrix and the OT matrix obtained with reg = 0.1 (used as the baseline) is calculated. c. Sensitivity to the alpha_range (min) parameter. The alpha_range (min) parameter is varied from 0.1 to 1, with 0.7 set as the baseline. For each value, the corresponding OT matrix is computed, and the PCC is calculated between this matrix and the OT matrix obtained under the baseline parameter.

https://doi.org/10.1371/journal.pcbi.1014346.s024

(DOCX)

S17 Fig. Ablation study of the adaptive explicit spatial fusion module in real datasets.

a. Inferred spatial trajectories obtained after removing the adaptive explicit spatial fusion module on the Ambystoma mexicanum telencephalon regeneration dataset. b. Pseudo-spatiotemporal map obtained after removing the adaptive explicit spatial fusion module on the Ambystoma mexicanum telencephalon regeneration dataset. c. Inferred spatial trajectories obtained after removing the adaptive explicit spatial fusion module on the ICC tumor dataset. d. Pseudo-spatiotemporal map obtained after removing the adaptive explicit spatial fusion module on the ICC tumor dataset.

https://doi.org/10.1371/journal.pcbi.1014346.s025

(DOCX)

S18 Fig. Ablation study of the clustering loss on simulated datasets.

a. Comparison of Spearman correlation coefficients between the full model (StPedf) and the variant without clustering loss across four simulated datasets. b. Comparison of Kendall correlation coefficients between the full model (StPedf) and the variant without clustering loss across four simulated datasets.

https://doi.org/10.1371/journal.pcbi.1014346.s026

(DOCX)

References

  1. 1. Cao J, Spielmann M, Qiu X, Huang X, Ibrahim DM, Hill AJ, et al. The single-cell transcriptional landscape of mammalian organogenesis. Nature. 2019;566(7745):496–502. pmid:30787437
  2. 2. Street K, Risso D, Fletcher RB, Das D, Ngai J, Yosef N, et al. Slingshot: cell lineage and pseudotime inference for single-cell transcriptomics. BMC Genomics. 2018;19(1):477. pmid:29914354
  3. 3. Wolf FA, Hamey FK, Plass M, Solana J, Dahlin JS, Göttgens B, et al. PAGA: graph abstraction reconciles clustering with trajectory inference through a topology preserving map of single cells. Genome Biol. 2019;20(1):59. pmid:30890159
  4. 4. Ji Z, Ji H. TSCAN: Pseudo-time reconstruction and evaluation in single-cell RNA-seq analysis. Nucleic Acids Res. 2016;44(13):e117. pmid:27179027
  5. 5. Angerer P, Haghverdi L, Büttner M, Theis FJ, Marr C, Buettner F. destiny: diffusion maps for large-scale single-cell data in R. Bioinformatics. 2016;32(8):1241–3. pmid:26668002
  6. 6. Bergen V, Lange M, Peidli S, Wolf FA, Theis FJ. Generalizing RNA velocity to transient cell states through dynamical modeling. Nat Biotechnol. 2020;38(12):1408–14. pmid:32747759
  7. 7. Tong Y, Hong R, Li M, Yang N, Deng W, Tang H, et al. Hi-C3: a statistical inference-based model for reconstructing higher-order cell-cell communication networks. Brief Bioinform. 2025;26(5):bbaf568. pmid:41159728
  8. 8. Chen A, Liao S, Cheng M, Ma K, Wu L, Lai Y, et al. Spatiotemporal transcriptomic atlas of mouse organogenesis using DNA nanoball-patterned arrays. Cell. 2022;185(10):1777-1792.e21. pmid:35512705
  9. 9. Rodriques SG, Stickels RR, Goeva A, Martin CA, Murray E, Vanderburg CR, et al. Slide-seq: A scalable technology for measuring genome-wide expression at high spatial resolution. Science. 2019;363(6434):1463–7. pmid:30923225
  10. 10. Stickels RR, Murray E, Kumar P, Li J, Marshall JL, Di Bella DJ, et al. Highly sensitive spatial transcriptomics at near-cellular resolution with Slide-seqV2. Nat Biotechnol. 2021;39(3):313–9. pmid:33288904
  11. 11. Hong R, Tong Y, Tang H, Zeng T, Liu R. eMCI: An Explainable Multimodal Correlation Integration Model for Unveiling Spatial Transcriptomics and Intercellular Signaling. Research (Wash D C). 2024;7:0522. pmid:39494219
  12. 12. Pham D, Tan X, Balderson B, Xu J, Grice LF, Yoon S, et al. Robust mapping of spatiotemporal trajectories and cell-cell interactions in healthy and diseased tissues. Nat Commun. 2023;14(1):7739. pmid:38007580
  13. 13. Shen X, Zuo L, Ye Z, Yuan Z, Huang K, Li Z, et al. Inferring cell trajectories of spatial transcriptomics via optimal transport analysis. Cell Syst. 2025;16(2):101194. pmid:39904341
  14. 14. Ren H, Walker BL, Cang Z, Nie Q. Identifying multicellular spatiotemporal organization of cells with SpaceFlow. Nat Commun. 2022;13(1):4076. pmid:35835774
  15. 15. Xu H, Fu H, Long Y, Ang KS, Sethi R, Chong K, et al. Unsupervised spatially embedded deep representation of spatial transcriptomics. Genome Med. 2024;16(1):12. pmid:38217035
  16. 16. Shang L, Zhou X. Spatially aware dimension reduction for spatial transcriptomics. Nat Commun. 2022;13(1):7203. pmid:36418351
  17. 17. Wang W, Zheng S, Shin SC, Chávez-Fuentes JC, Yuan G-C. ONTraC characterizes spatially continuous variations of tissue microenvironment through niche trajectory analysis. Genome Biol. 2025;26(1):117. pmid:40340854
  18. 18. Heitz M, Ma Y, Kubal S, Schiebinger G. Spatial Transcriptomics Brings New Challenges and Opportunities for Trajectory Inference. Annu Rev Biomed Data Sci. 2025;8(1):1–19. pmid:39541229
  19. 19. Zeira R, Land M, Strzalkowski A, Raphael BJ. Alignment and integration of spatial transcriptomics data. Nat Methods. 2022;19(5):567–75. pmid:35577957
  20. 20. Liu X, Zeira R, Raphael BJ. PASTE2: Partial Alignment of Multi-slice Spatially Resolved Transcriptomics Data. bioRxiv. 2023;:2023.01.08.523162. pmid:36711750
  21. 21. Peng Q, Zhou P, Li T. stVCR: spatiotemporal dynamics of single cells. Nat Methods. 2026;23(3):542–53. pmid:41820580
  22. 22. Qiu X, Zhu DY, Yao J, Jing Z, Zuo L, Wang M, et al. Spateo: multidimensional spatiotemporal modeling of single-cell spatial transcriptomics. bioRxiv. 2022. https://doi.org/10.1101/2022.12.07.519417
  23. 23. Hou Z, Liu X, Cen Y, Dong Y, Yang H, Wang C, et al. GraphMAE: Self-Supervised Masked Graph Autoencoders. In: Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, 2022. 594–604. https://doi.org/10.1145/3534678.3539321
  24. 24. Hou Z, He Y, Cen Y, Liu X, Dong Y, Kharlamov E, et al. GraphMAE2: A Decoding-Enhanced Masked Self-Supervised Graph Learner. In: Proceedings of the ACM Web Conference 2023, 2023. 737–46. https://doi.org/10.1145/3543507.3583379
  25. 25. Kipf TN, Welling M. Variational graph auto-encoders. arXiv. 2016. https://arxiv.org/abs/1611.07308
  26. 26. Villani C. Optimal Transport: Old and New. Berlin: Springer; 2009.
  27. 27. Qiu X, Zhang Y, Martin-Rufino JD, Weng C, Hosseinzadeh S, Yang D, et al. Mapping transcriptomic vector fields of single cells. Cell. 2022;185(4):690-711.e45. pmid:35108499
  28. 28. Cannoodt R, Saelens W, Deconinck L, Saeys Y. Spearheading future omics analyses using dyngen, a multi-modal simulator of single cells. Nat Commun. 2021;12(1):3942. pmid:34168133
  29. 29. Wei X, Fu S, Li H, Liu Y, Wang S, Feng W, et al. Single-cell Stereo-seq reveals induced progenitor cells involved in axolotl brain regeneration. Science. 2022;377(6610):eabp9444. pmid:36048929
  30. 30. Lust K, Maynard A, Gomes T, Fleck JS, Camp JG, Tanaka EM, et al. Single-cell analyses of axolotl telencephalon organization, neurogenesis, and regeneration. Science. 2022;377(6610):eabp9262. pmid:36048956
  31. 31. Amamoto R, Huerta VGL, Takahashi E, Dai G, Grant AK, Fu Z, et al. Adult axolotls can regenerate original neuronal diversity in response to brain injury. Elife. 2016;5:e13998. pmid:27156560
  32. 32. Kirkham M, Hameed LS, Berg DA, Wang H, Simon A. Progenitor cell dynamics in the Newt Telencephalon during homeostasis and neuronal regeneration. Stem Cell Reports. 2014;2(4):507–19. pmid:24749074
  33. 33. Berg DA, Kirkham M, Beljajeva A, Knapp D, Habermann B, Ryge J, et al. Efficient regeneration by activation of neurogenesis in homeostatically quiescent regions of the adult vertebrate brain. Development. 2010;137(24):4127–34. pmid:21068061
  34. 34. Hausser J, Alon U. Tumour heterogeneity and the evolutionary trade-offs of cancer. Nat Rev Cancer. 2020;20(4):247–57. pmid:32094544
  35. 35. Wu L, Yan J, Bai Y, Chen F, Zou X, Xu J, et al. An invasive zone in human liver cancer identified by Stereo-seq promotes hepatocyte-tumor cell crosstalk, local immunosuppression and tumor progression. Cell Res. 2023;33(8):585–603. pmid:37337030
  36. 36. Chen Y, Yang S, Tavormina J, Tampe D, Zeisberg M, Wang H, et al. Oncogenic collagen I homotrimers from cancer cells bind to α3β1 integrin and impact tumor microbiome and immunity to promote pancreatic cancer. Cancer Cell. 2022;40(8):818-834.e9. pmid:35868307
  37. 37. Maynard KR, Collado-Torres L, Weber LM, Uytingco C, Barry BK, Williams SR, et al. Transcriptome-scale spatial gene expression in the human dorsolateral prefrontal cortex. Nat Neurosci. 2021;24(3):425–36. pmid:33558695
  38. 38. Hoerder-Suabedissen A, Molnár Z. Development, evolution and pathology of neocortical subplate neurons. Nat Rev Neurosci. 2015;16(3):133–46. pmid:25697157
  39. 39. Tan Y, Wang A, Wang Z, Lin W, Yan Y, Nie Q, et al. Transfer learning of multicellular organization via single-cell and spatial transcriptomics. PLoS Comput Biol. 2025;21(4):e1012991. pmid:40258090
  40. 40. Delfinado CJA, Edelsbrunner H. An incremental algorithm for Betti numbers of simplicial complexes on the 3-sphere. Computer Aided Geometric Design. 1995;12(7):771–84.