## Abstract

Spatial transcriptomics and messenger RNA splicing encode extensive spatiotemporal information for cell states and transitions. The current lineage-inference methods either lack spatial dynamics for state transition or cannot capture different dynamics associated with multiple cell states and transition paths. Here we present spatial transition tensor (STT), a method that uses messenger RNA splicing and spatial transcriptomes through a multiscale dynamical model to characterize multistability in space. By learning a four-dimensional transition tensor and spatial-constrained random walk, STT reconstructs cell-state-specific dynamics and spatial state transitions via both short-time local tensor streamlines between cells and long-time transition paths among attractors. Benchmarking and applications of STT on several transcriptome datasets via multiple technologies on epithelial–mesenchymal transitions, blood development, spatially resolved mouse brain and chicken heart development, indicate STT’s capability in recovering cell-state-specific dynamics and their associated genes not seen using existing methods. Overall, STT provides a consistent multiscale description of single-cell transcriptome data across multiple spatiotemporal scales.

### Similar content being viewed by others

## Main

The advances of single-cell gene expression profile techniques have provided an unprecedented resolution to dissect cell-fate decisions. Metrics such as similarity or distance on a low-dimensional manifold are applied to single-cell RNA sequencing (scRNA-seq) data to infer dynamic properties such as pseudotime ordering^{1,2}, network abstraction^{3} or cellular random walk analysis^{4,5}. Leveraging both unspliced and spliced counts, the RNA velocity methods^{6,7} explicitly model the dynamics of messenger RNA (mRNA), projecting the future spliced states of cells onto scRNA-seq data to reveal the directionality of cell-fate determination^{8}, and also to improve trajectory inference^{9,10,11}, low-dimensional embedding^{12,13} and gene regulatory network inference^{14,15}.

Spatial transcriptomics measures additional spatial information at individual cells or spots of a small group of cells, allowing analysis of heterogenous cell states in space^{16,17}. To infer temporal dynamics within spatial transcriptomics, SpaceFlow^{18} uses proximity information to constrain the cell embedding and pseudotime ordering for spatial consistency. SIRV^{19} develops a spatially resolved RNA velocity approach, by improving estimation of unspliced and spliced mRNA using reference scRNA-seq counterparts to enrich the spatial transcriptomics gene expression matrices.

While RNA velocity has been widely used, fundamental challenges remain for reconstructing robust spatiotemporal dynamics^{20}. For example, multilineages or multiple meta-stable states^{21,22,23} in complex spatial tissues cannot be captured by the current models, as spliced and unspliced transcript levels may diverge due to nonlinear gene regulation or multicellular signaling. In addition, the time scale of mRNA splicing is within minutes or hours^{24,25}, during which the current RNA velocity model converges to one global equilibrium, however, cell-state transitions may span from days to weeks, (for example, in hematopoiesis^{8,20,25}). While cell-specific gene expression rates may be used to accommodate a continuous cell-fate commitment process^{25,26}, additional measurements, such as metabolic labeling^{27,28,29}, are needed^{25} and difficult to obtain, for example, in spatial transcriptomics. Last, the current major RNA velocity methods are only focused on the velocity of spliced counts, omitting the velocity of unspliced counts that are closely linked to gene regulation^{15}, which could provide further information about ‘attraction force’ into certain cell state.

The multiscale cell attractor theory^{30,31,32,33,34,35} provides a natural tool to model dynamics across different time scales and resolutions, as well as account for the multistable states. In such a theory, the temporal change of gene expression and their mutual regulations are modeled as dynamical system composed of a set of differential equations. The stable cell types correspond to multiple locally stable fixed point of dynamical system under mild perturbation of gene regulation (that is, multistable states) where the cell states of expression are ‘trapped’, and the highly plastic transitional cells are modeled as ‘saddle point’ of the system, such that the cell could make state transitions through certain direction. Using such an approach, MuTrans^{5} coarse-grains scRNA-seq data at different scales to identify attractors and saddle points, allowing description of short-time fluctuations of cells around attractors locally while capturing long-time scale transitions of cells among multiple attractors with saddle points in between. The Gaussian-like kernel in MuTrans confines its scope to equilibrium and ergodic systems^{4,5}. For nonequilibrium systems, using RNA velocity as input, CellRank^{8} constructs a cellular random walk using a velocity kernel followed by coarse-graining analysis and Dynamo^{25} fits the discrete RNA velocities using continuous functions for attractor geometry and transition analysis. However, in these methods, the linear RNA velocity model is incompatible with the presence of multistable attractors inherited in the data, leading to inconsistency between the transition velocity and downstream analysis. In addition, such approaches cannot be used directly for spatial transcriptome data.

Here we present a spatial transition tensor (STT) approach to reconstruct cell attractors in spatial transcriptome data using unspliced and spliced mRNA counts, to allow quantification of transition paths between spatial attractors as well as analysis of individual transitional cells. Unlike the linear RNA velocity model with one global equilibrium (Fig. 1a), STT assumes the coexistence of multiple attractors in the joint unspliced (U)–spliced (S) counts space, with cells making transitions between attractor basins (Fig. 1a,b). A four-dimensional transition tensor across cells, genes, splicing states and attractors is constructed, with attractor-specific quantities associated with each attractor basin (Fig. 1b). By iteratively refining the tensor estimation and decomposing the tensor-induced and spatial-constrained cellular random walk (Fig. 1c–e,g), STT connects the scales between local gene expression and splicing dynamics as well as the global state transitions among attractors. Furthermore, STT ranks genes that are mostly relevant to the multistable expression patterns, and categorizes pathways with similar STT properties (Fig. 1g). By studying both nonspatial and spatial datasets, we demonstrate STT’s unique capability to uncover multistable attractors of cells and transition properties occurring at different spatiotemporal scales.

## Results

### Overview of STT

The inputs to STT are the single-cell gene expression matrices of both S and U counts (Fig. 1c), and the cell annotations (or membership) that serve as initial guess on what cell state they belong to. In addition, the spatial coordinates of each cell (or spot) are also required for spatial transcriptomic data. Through an iteration between parameter estimation and dynamics decomposition, STT constructs an attractor-wise velocity tensor named transition tensor of shape \({{\mathbb{R}}}^{{N}_{\mathrm{C}}\times 2\times K\times {N}_{\mathrm{G}}}\), where *N*_{C} denotes the number of cells, *N*_{G} the number of genes and *K* the number of attractors. Other quantities of tensor-based dynamics, including the memberships of cells in the attractors, transition probabilities and transition paths, are subsequently obtained in this construction (Methods).

STT uses the following stochastic model of gene expression and splicing dynamics

where *U*_{i} and *S*_{i} are the unspliced and spiced counts for gene *i*. The nonlinear function *f*_{i}\(\left(t,{S}_{1},{\ldots},{S}_{{N}_{\mathrm{G}}}\right)\) models how other genes regulate the production rate of gene *i*. The system can possess multiple fixed points or attractors representing the different cell states. The parameter *β*_{i} represents the mRNA splicing rate and *γ*_{i} is the spliced mRNA degradation rate. The independent Wiener process terms \({W}_{i,t}\) and \({Z}_{i,t}\) represent the noise in gene expression. Such stochasticity may induce the noise-induced cell-state transitions among multistable attractors at a longer time scale than splicing dynamics.

When most cells are located within the multiple attractor basins that correspond to the different cell states, with a small fraction of cells making transitions across the saddle points^{5} (a natural assumption on the cell distribution), the unspliced mRNA production term can be expanded and approximated to its linear expansion, thus introducing the attractor-dependent mRNA transcription rate (Fig. 1d and Methods). Such expansion allows robust estimate of the parameters, and initializes assignment of the attractor-wise velocities for each cell, which we call transition tensors (Fig. 1d and Methods).

By constructing an inner-product velocity kernel (Fig. 1d, Methods and Supplementary Note 1), the tensors provide a cellular random walk description that is asymptotically consistent with continuous stochastic differential equation (SDE) (that is, equation (1)). Combining with the Gaussian kernel of gene expression similarity and cell spatial coordinates (Fig. 1g and Methods), the constructed cellular random walk equips cells in each attractor with consistent velocity, transition direction and similar gene expression. In addition, the constructed random walk encourages cells to be more likely to make transitions to other spatially adjacent cells in the physical space. Through coarse-graining and decomposing the random walk on attractor levels, the cells’ membership functions for different attractors are then obtained (Fig. 1e and Methods). In each iteration between the tensor model construction and the random walk decomposition, the updated membership function improves the parameter estimation in equation (1) by incorporating attractor uncertainty (Methods). The genes, whose dynamics are most consistent with the attractor property in the *U*–*S* space, are then identified during iteration (Methods). A monitor module is included, with regularization and early stopping strategies that can improve the robustness of iteration through the user’s control (Methods). Finally, the tensor streamlines to describe the attractor details, as well as the coarse-grained transition paths to depict long-time transitions, are projected on a low-dimensional dynamical manifold to show the cell-state transitions (Fig. 1f and Methods).

### Benchmarking STT in recovering multistable cell states

We first applied STT to analyze two synthetic datasets based on simulating multistable systems. In the bistable toggle-switch circuit, the streamlines of averaged velocities over attractors in STT demonstrate clearer structures of the two attractors than the streamlines of RNA velocity and other methods (Fig. 2a and Supplementary Fig. 1). While RNA velocity streamlines computed by scVelo^{7} and UniTVelo^{36} tend to diverge from the attractor locations, STT streamlines converge toward the attractors, thus providing a more interpretable representation of the toggle-switch landscape (Fig. 2a and Supplementary Fig. 1). Moreover, STT computes an entropy value to distinguish between stable cells near fixed point and transitional cells across saddle points (Supplementary Fig. 1). As shown in both components of transition tensors with streamlines (Supplementary Fig. 1), only when the unspliced and spliced quantities are considered together can both attractor basins be revealed. Although the spliced tensors are consistent with the standard RNA velocity (Fig. 2a), which depicts transitions between the attractors, the unspliced tensors naturally introduce an ‘attraction force’ that ‘pulls’ cells toward the center of each attractor, as compared to the streamlines of cellDancer^{37} where the cells are attracted to the ‘ends’ within attractor (Supplementary Fig. 1). The unspliced counts provide a measurement on the level of ‘attraction’ in STT for an attractor of cell state. To further benchmark the accuracy of STT, we compared the cosine similarity between STT unspliced or spliced tensor components and the ground-truth velocities from the model, and found that STT ranked top in estimating both spliced and unspliced velocities (Fig. 2b). In addition, the performance of STT shows a good level of robustness when subsampling the dataset (Supplementary Fig. 1).

Next, we analyzed the simulated gene regulation circuits during epithelial–mesenchymal transition (EMT), where three attractors, denoted as epithelial (E), mesenchymal (M) and intermediate cell state (ICS), may coexist, in some parameter ranges (Methods). Compared to the RNA velocity calculated by scVelo (Fig. 2), the STT average velocities (Fig. 2c) clearly recover these three attractors. Overall, STT is able to reconstruct the complex multistable details in single-cell gene expression datasets.

### STT highlights ICSs in fate decision

We next analyzed the scRNA-seq data in the EMT induction experiment of human lung A549 cell lines, including a temporal series of snapshots collected from the first 7 days after TGFB1 treatment^{38}. STT identifies three attractors, namely E, ICS and M, consistent with the order of timepoints in data collection (Fig. 3a,b and Supplementary Fig. 2). Moreover, cells nearby the ICS attractor, mainly collected at 8 h or 1 day after induction (Fig. 3b), have higher entropy values (Fig. 3c), thus indicating that this state is more plastic than epithelial (day 0 and 8 h) and mesenchymal (after day 3) states. This is in good agreement with the proposed phenotypic plasticity of intermediate epithelial and/or mesenchymal states in cancer^{39}.

Using the transition vector to predict the transition paths connecting attractors in the epithelial–mesenchymal landscape, we find that the transition probability flux from E to M always goes through the ICS (Fig. 3a). In other words, epithelial cells undergoing EMT never directly switch to a mesenchymal state, but rather acquire intermediate traits first. The unspliced and spliced counts often exhibit multistability of the attractors (Fig. 3e and Supplementary Figs. 2 and 3). The genes with high multistability scores possess varying expression levels in both unspliced and spliced counts within various attractors, and show a gradual change during E–ICS–M transitions. While the highly ranked multistable genes such as ITGA11, are not significantly detected by differential gene expression analysis as top-scored marker genes for attractors (Supplementary Fig. 3), they are found important in promoting EMT transitions and tumor progression^{40}. While the tensor streamlines of splicing dynamics demonstrate the overall direction from E to M via ICS, which is also consistent with the UniTVelo results (Supplementary Fig. 2), the gene expression dynamics of unspliced counts as well as in the joint *U*–*S* space predicted by STT as well as cellDancer both suggest that cells are ‘attracted’ to the ICS basins during EMT (Fig. 3f and Supplementary Fig. 2). This is also consistent with the CellRank absorption probability analysis based on tensor-induced multistability kernel (Fig. 3d). Together, the tensor components along with the global transition paths analysis highlight the ICS as a distinct attractor basin, serving as the hub state during EMT.

In addition, we applied STT to blood^{41} and pancreas^{7} development datasets and found its capability to resolve complex state transitions, and its multistability tensor kernel is consistent with CellRank analysis (Supplementary Figs. 4 and 5).

### STT identifies spatial attractors and pathway similarities

We next applied STT to the HybISS spatial dataset of mouse brain development^{42}. To enrich the unspliced and spliced counts for better tensor estimation, we used the SIRV^{19} algorithm to impute one of the original spatial data slices at 40 μm at E10 and E11. Compared with clustering only based on cellular similarity (Supplementary Fig. 6), STT identifies attractors consistent with spatial locations of different cell states (Fig. 4a) and brain region annotations in original publication (Fig. 4b): the cells within the same attractor tend to have similar spatial coordinates and belong to the same regions. In addition, the cell assignment is found to be robust to the weight of spatial diffusion kernels (Supplementary Fig. 6), attractor initialization (Supplementary Fig. 7), multistability genes filtering (Supplementary Fig. 8) and number of attractors (Supplementary Fig. 9). The local transition tensors in the forebrain and hindbrain attractors (Fig. 4c) are consistent with UniTVelo analysis (Supplementary Fig. 6).

To evaluate the biological significance of the tensor streamlines, we performed pathway-specific analysis to evaluate functions associated with the cell-state transitions and pathway regulations (Fig. 4d). We used the Kyoto Encylopedia of Genes and Genomes (KEGG) knowledge database, and calculated the similarity among pathways based on tensor correlations of multistable genes for each pathway (Methods). Indeed, the pathway-specific tensor demonstrates distinct attractor dynamics. The latent embedding and clustering of pathways based on tensor correlation (Fig. 4d) reveal the functional similarity of spatial state transitions between pathways during developmental process. The TGF-beta and WNT pathways, known to exhibit cross-talk and cooperate during embryogenesis^{43}, are from distinct clusters in the latent embedding, and their tensor streamlines are in opposite directions, especially in midbrain and forebrain attractors (Fig. 4d). Two other important pathways in brain development, the Hippo and Thyroid hormone signaling pathways^{44,45}, are also from different clusters of pathway tensors, showing opposite streamlines in midbrain and forebrain regions (Fig. 4d). Overall, STT provides dynamical information for the spatial organizations of cell states and the relations between pathways regulating state transitions during development.

### STT reveals spatial attractors and lineage in chicken heart

We applied STT to the spatially resolved chicken heart data measured by 10X Visium technology^{46}. Our analysis is focused on the last temporal point at day 14 from the dataset when the four-chamber development has finalized with completed events of cardiogenesis and explicit spatial boundaries^{46}.

Using SIRV-imputed unspliced and spliced counts^{19}, STT identifies five spatially resolved attractors (Fig. 5a and Supplementary Fig. 10). Among them, attractor 2 coincides with the ‘valves’ region in the original study, and it mainly consists of fibroblast cells (Fig. 5a,b,d,e). Attractor 0 mainly consist of cells from the right ventricle region (Fig. 5e). Attractor 1 mainly localizes in the ‘atria’ region (Fig. 5e) and is composed of erythrocytes. While the remaining attractors (3, 4) are distributed across several connected regions, they all include the cells of annotated phenotype of cardiomyocytes (Fig. 5a,b,d,e). The dynamical manifold reveals those discrete attractors (Fig. 5c) relate to various cell lineages. The attractors 1 and 2, which contain spatially localized lineages of fibroblasts and erythrocytes, all exhibit the ‘attraction force’ as seen in the tensor streamlines (Fig. 5f). In comparison, the streamlines of tensors within attractors 3 and 4 (both containing cardiomyocytes) indicate their transience in space and show a tendency to transit into atrial regions, which is also observed in the ‘attraction’ between unspliced components. This could partly be explained by the existence of another group of myocytes in the atria (Fig. 5b,d). Overall, the observed consistency with spatial regions or cell type annotations indicates STT’s capability to dissect spatially resolved attractors.

### STT elucidates region-specific spatial attractors and stabilities

We next analyzed the high-resolution Stereo-seq mouse adult coronal hemibrain dataset^{47} processed with bin size 60, which revealed the complex domains of neuron cells with various biological functions. Direct application of STT shows several region-specific spatial attractors that are very consistent with the functional annotations of brain regions (Fig. 6a,b). The convergent streamlines of tensors (Fig. 6c) suggest that the multistability of gene expression dynamics is well maintained in regions such as the cortical subplot (attractor 4) and the striatum dorsal region (attractor 10). Streamlines flow outward (Fig. 6c) in thalamus regions (attractor 8) all tensor components, suggesting its relatively high plasticity. The pathway embedding based on their tensor dynamics showed that the previously known interacting pathways such as cGMP–PKG and the calcium signaling pathway^{48} share similar tensor dynamics (Fig. 6d). It also suggests that cGMP–PKG is different from the oxytocin pathway, in which the streamlines indicate the major differences occurring in the amygdalar nucleus region (Fig. 6d). Overall, the results indicated that STT can discover spatial regions and quantify their stabilities through attractor analysis, even in mature tissues.

## Discussion

Quantifying and modeling the relative abundance between unspliced and spliced counts has enabled an effective mechanistic approach to dissect cell-state transitions from scRNA-seq datasets. To connect the different time scales among gene expression, mRNA splicing and cell lineage dynamics, as well as to study the underlying attractors of these states, we have developed the STT for (1) constructing the attractor-wise transition tensor, (2) analyzing the probabilistic transition paths and transitional cells and (3) inferring the genes that account for the multistability of cell states. This was done through an iterative computation process between (1) parameter inference in transition tensor models and (2) multiscale analysis of tensor-induced stochastic dynamical systems.

Compared with the RNA velocity models, STT is unique in uncovering attractors underlying both the gene expression and the splicing dynamics, as well as quantifying the transitions among them. By assuming multistability, STT is robust to initial state specifications or hidden time correction^{7,26,36,49}. The cell-membership functions quantify transitional cells in estimating the transition tensors, naturally bridging the downstream multiscale dynamical analysis.

To identify transitional cells and infer transition paths, STT leverages the computed transition tensor, instead of direct usage of RNA velocity such as CellRank^{8} or Dynamo^{25}. The multistable transition tensor is found to be more compatible with the attractor assumption in downstream analysis. The iterative scheme of STT between tensor construction and dynamical dissection is found to better ensure such self-consistency. However, since the attractor assumption does not account for oscillation dynamics, STT needs to be improved to capture the nonequilibrium features of datasets with strong cell cycle effects.

The velocity kernel-based cellular random walk derived from the transition tensor is critical for connecting the modules of tensor inference and dynamical decomposition in STT, allowing better-connected dynamics at different scales. Theoretical analysis has revealed that different choices of velocity kernel lead to various continuum limits in forms of ordinary or SDEs^{49}. In STT, the inner-product kernel is used to construct the cellular random walk that was shown to be consistent with the stochastic chemical Langevin model of gene expression^{49,50}, while the cosine kernel, which correctly recovers the directionality of the velocity field^{49}, is adopted to visualize the local streamlines within attractors. In addition to the differential equation models, it may be interesting to formulate STT in the chemical master equation framework^{51} of RNA velocity in the future.

As a mechanistic model-based approach, STT may be improved in several aspects. Instead of using attractor-specific zeroth order approximation of nonlinear gene expression rate function in equation (1), higher-order gene interactions could be considered as proposed recently for gene regulatory network inference^{15}. Multimodal information including single-cell epigenomics^{52} or proteomics data^{53} can also be incorporated in the multistable dynamical system to enhance the transition tensor calculation. The automatic detection of root and target states in multistable models is always challenging, and the previous knowledge or knowing the properties related to cells’ differentiation potencies^{54,55} could be helpful.

Overall, STT provides a unified approach to extract spatiotemporal information from single-cell datasets by bridging the processes across different time scales and tissue regions. Our method allows for a multiscale description of tissue spatiotemporal structures, connecting microscopic dynamics of gene expression and splicing, and the macroscopic dynamics of cell-state transitions among emergent attractors.

## Methods

### Multistability in gene expression and splicing model

We use a simple dynamical model with different parameters around each steady-state to approximate the mRNA splicing dynamics for gene *i*:

Here, \({\alpha }_{{{c}},i}\) is the state-dependent unspliced mRNA transcription rate in attractor *c*, \({\beta }_{i}\) is the mRNA splicing rate and \({\gamma }_{i}\) is the mRNA degradation rate. Assuming that the system is close to steady-state, we have \({\epsilon }_{i}={\alpha }_{{{c}},i}-{\beta }_{i}{U}_{i},{\eta }_{i}={\beta }_{i}{U}_{i}-{\gamma }_{i}{S}_{i}\) where \({\epsilon }_{i}\) and \({\eta }_{i}\) are independent and identically distributed zero-mean Gaussian variables. Due to the invariance of scales in parameters^{56}, we set \({\gamma }_{i}=1\) and the maximum likelihood estimation could be expressed as

Since the parameters of different genes are estimated independently, for simplicity of notations, here we omit gene subscript *i* and introduce the subscript *k* to denote the cell index. The indicator function of attractors \({1}_{k\in {\Omega }_{{c}}}\) is initialized using user-provided cell labels or standard Leiden or Louvain clustering algorithm output, and it is updated using membership function in iterations (described below). The estimation yields the solution:

where \({m}_{c}=\frac{{\sum }_{k=1}^{{N}_{\mathrm{C}}}{U}_{k}{1}_{k\in {\Omega }_{c}}}{{N}_{c}}\). Compared with steady-steady parameter estimation in the standard RNA velocity model, the splicing rate parameter \(\beta\) in the multistable model is not only attractor-type specific, but also depends on both unspliced and spliced counts.

For each cell *k* with counts \(({U}_{k},{S}_{k})\), its velocity with respect to each attractor *c* is defined as \({v}_{k,u,c}={\alpha }_{c}^{(* )}-{\beta }^{\left(* \right)}{U}_{k},{v}_{k,s,c}={\beta }^{\left(* \right)}{U}_{k}-{S}_{k}\) where subscript *u* and *s* corresponds to unspliced and spliced counts, respectively. This estimation is repeated for each gene, therefore, leading to a four-dimensional transition tensor \({v}_{k,l,c,g}\in {{\mathbb{R}}}^{{N}_{\mathrm{C}}\times 2\times K\times {N}_{\mathrm{G}}}\).

### Tensor-based and spatial-constrained transition dynamics

Next, STT constructs the Markov chain transition probabilities among individual cells based on the calculated tensor, gene expression similarity and spatial coordinates if available (Fig. 1g). The transition probability is constructed from three components: \(P={w}_{1}{P}^{{\mathrm{v}}}+{w}_{2}{P}^{{\mathrm{c}}}+\left(1-{w}_{1}-{w}_{2}\right){P}^{{\mathrm{s}}}\), where *P*^{v}, *P*^{c} and *P*^{s} are transition probabilities induced by velocity, similarity and spatial kernels, respectively. Here \({w}_{1}\) and \({w}_{2}\) are the hyperparameters of the algorithm to balance the effects of different modalities of tensor dynamics, gene expression similarity and spatial closeness. Their effect on output has been tested in Supplementary Fig. 6.

To construct *P*^{v}, we first transform the attractor-specific tensor to the attractor-independent velocity *V* by averaging along the dimension of attractors:

Here \({\rho }_{k,c}\) denotes the membership function of cell *k* in attractor *c*. The stable cell *j* located around the fixed point of the attractor basin *d* yield \({\rho }_{j,d}=1\), while transitional cell *l* near saddle points has multiple positive components in \({\rho }_{l}\), pointing toward the attractors to which the cell can transition into.

Having calculated the tensor, we next construct the velocity-induced transition probability *P*^{v} using the inner-product kernel^{49} (Supplementary Note 1). The weight of transition propensity from cell *k* to *l* is \({w}_{{kl}}=\exp ({V}_{k,u}^{T}\Delta {U}_{{kl}}+{V}_{k,s}^{T}\Delta {S}_{{kl}})\) where \(\Delta {U}_{{kl}}={U}_{l}-{U}_{k}\) and \(\Delta {S}_{{kl}}={S}_{l}-{S}_{k}\). The random walk induced by such a kernel is consistent with the SDE model of equation (1) (ref. ^{49} and Supplementary Note 1). The cell similarity induced transition probability *P*^{c} is constructed from the Gaussian kernel of the diffusion map based on gene expression counts^{2}. Last, the spatially constrained transition probability *P*^{s} is constructed from the Gaussian kernel of spatial location coordinates, such that cells with similar spatial locations are more likely to make transitions between each other. As a result, such cells are more likely to be assigned into the same attractor basins.

To calculate the membership function in attractors, we use the GPPCA^{57} algorithm to decompose the constructed random walk transition probability matrix *P* and coarse-grain the nonequilibrium Markov chains and obtain \({\rho }_{k,c}\). This algorithm allows for the factoring and ‘coarse-graining’ of nonequilibrium transition probability matrices of cellular random walk, which holds true for most of the velocity-induced dynamics, to obtain the attractor within the data as well as cell’s relevant position (that is, membership) in each attractor. The coarse-grained (cg) transition probability matrix \({P}_{\mathrm{cg}}^{\,K\times K}\) on the attractor level (*K* is the total number of attractors) is obtained simultaneously using the GPPCA algorithm. Given the cell’s membership function, its transitional entropy can be defined as \({\varepsilon }_{i}=-\mathop{\sum }\nolimits_{c=1}^{K}{\rho }_{i,c}\mathrm{ln}{\rho }_{i,c}\). The larger entropy indicates the higher propensity of the cell to make transitions between attractors.

### Iterative scheme for parameter estimation and attractor membership quantification

After obtaining the membership function, the parameters of the tensor model are updated to incorporate the uncertainty of the cells’ positions in attractors. We define a loss function

where *λ* denotes the strength of regularization term of kinetic parameters. Intuitively, the ‘stable cells’ in attractor *c* have larger weight values in the regression loss function since the confidence level about steady-state is larger. We analytically solve the optimizer

where \({m}_{c}=\frac{{\sum }_{k=1}^{{N}_{\mathrm{C}}}{U}_{k}{\rho }_{k,c}}{{\sum }_{k=1}^{{N}_{\mathrm{C}}}{\rho }_{k,c}+\lambda }\).

In turn, the updated tensor with the newly optimized parameters leads to an updated membership function. In STT, we adopt an iterative scheme to update tensor parameters and attractor memberships jointly,

where the superscript *n* denotes the number of iterations, and DynamicalAnalysis denotes the described procedure to update membership function. The scheme stops once the membership function does not improve within certain threshold, or the iteration exceeds the allowed maximum number of iterations.

To dissect the multistable dynamics accurately, we also filter the genes in each iteration based on their goodness of fit to model that includes the genes showing multistability. The metric of goodness, or gene multistability score, is defined as \(1-\frac{J\left({\alpha }_{c},\beta,{\rho }_{k,c}\right)}{{{{N}}}_{{\rm{C}}}({\rm{Var}}\left(U\right)+{\rm{Var}}\left(S\right))}\) where *N*_{C} denotes the number of cells. Only the tensor of filtered genes, whose multistability scores are larger than certain threshold, are used to calculate velocity kernel and therefore update the membership function. The hyperparameters of STT and their values chosen in datasets analyzed are presented in Supplementary Tables 1 and 2.

To allow robust control of the iteration scheme, we incorporated a monitor module that outputs the multistability scores of genes in both training (by default 80% of all sample sizes) and test dataset (20% of all samples). The training dataset was used to fit kinetic parameters (\({\alpha }_{c},\beta\)), and the multistability scores of genes are calculated on test dataset. The monitor module outputs the multistability scores and number of genes pass the threshold. Given the output, the user may choose to interactively (1) modify the threshold set for filtering multistability genes, (2) adjust the weight of tensor-induced kernel against gene expression similarity or spatial kernels to encourage the high-quality transition matrices or (3) determine whether to stop the iteration, therefore facilitating the adaptive accuracy. The interface of monitor module is demonstrated in Supplementary Fig. 1f. We also demonstrate the efficiency and scalability of STT algorithm in Supplementary Table 3 and Supplementary Fig. 10.

### Initialization of iteration

To start the iteration, STT requests the input of existing clustering results to create attractor membership by one-hot encoding. The previous biological annotation of the dataset or spatial region segmentation results were recommended as the input. When such information is unavailable, users may adopt clustering algorithms such as Leiden or Louvain to cluster the cells based on expression counts (spliced only or spliced and unspliced jointly) or spatial location of the cells. The robustness to initialization of STT was investigated (Supplementary Fig. 7). Whenever the user prefers alternative clustering methods and/or more systematic analysis, STT provides an option to feed a user-generated clustering output as the input for the initializations of STT.

### Visualization of dynamical manifold and transition paths

To visualize the low-dimensional embeddings of cells, STT uses the join state \({x}_{k}=\left({U}_{k},{S}_{k}\right)\in {{\mathbb{R}}}^{2{N}_{\mathrm{G}}}\) for each cell *k* as the input of dimensionality reduction algorithms such as principal component analysis (PCA) or uniform manifold approximation and projection (UMAP). To visualize the dynamical manifold, we define the cell’s position in the two-dimensional (2D) plane as \({y}_{k}=\mathop{\sum} \nolimits_{c=1}^{K}{\rho }_{k,c}{\mu }_{c}\), where \({\mu }_{c}\) is the center of PCA or UMAP embeddings of each attractor and \(K\) is the number of attractors. Then, a Gaussian mixture density estimation \({\mathcal{P}}(y)\) is constructed for all \({y}_{k}\) using an expectation–maximization algorithm, where the initial weights for *K* components are the stationary distributions of attractor-level, coarse-grained random walk transition probability matrix *P* derived in the previous section. The surface of dynamical manifold was calculated as \(\phi \left(y\right)=-{\mathrm{ln}}{\mathcal{P}}(y)\). The streamlines of the velocity \({V}_{k}=\left({V}_{k,u},{V}_{k,s}\right)\in {{\mathbb{R}}}^{2{N}_{\mathrm{G}}}\) in the 2D plane are calculated using the linear (PCA) or nonlinear (UMAP) projection approach in scVelo with the cosine kernel. Given initial and final states, the transition paths and their proportion of the total transition probability flux are calculated using the transition path theory^{58} with the PyEMMA package^{59}.

### Synthetic datasets and benchmarking

The simulation data (*n* = 10,010 cells) for the toggle-switch system were generated by the SDE model of a mutually inhibited two-gene circuits with nonlinear gene regulation and/or splicing dynamics and stochastic noise (Supplementary Note 2). Two attractors are present in the system with a saddle point in between. The synthetic dataset (*n* = 5,000 cells) of EMTs was generated by the SDE model of a seven-gene core circuit during EMT adapted to include mRNA splicing^{15,60}. With different levels of extrinsic signal TGFB, the system has saddle-node bifurcations within a certain parameter range and three attractors may coexist, representing epithelial state, ICS and mesenchymal state (Supplementary Note 2). We simulated different levels of TGFB to model the EMT process. For both datasets, the Euler–Maruyama method was used to simulate the SDE trajectories, with negative gene expression values adjusted to zero during each time step of the trajectory simulation.

### Pathway analysis

To analyze the similarities between tensor dynamics in various pathways, we first downloaded the pathway databases, such as KEGG, using the GSEApy package^{61}. Next, for each pathway we identified the genes shared by the pathway databases and the STT multistability analysis. For any selected gene sets that contain a sufficient number of genes, we calculated their cosine-kernel velocity graph using the averaged tensor of both spliced counts and unspliced counts, and then computed the Pearson’s correlation coefficients between pathway-specific velocity graphs. The UMAP dimensionality reduction of pathways was then performed on the principal components of the correlation matrix, and clustering was performed on UMAP with *K*-means algorithm by silhouette score to choose the optimal number of clusters.

### Reporting summary

Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article.

## Data availability

All the datasets used in this paper are publicly available. The detailed preprocessing of datasets is described in Supplementary Notes. The simulation datasets of synthetic circuits are available at https://github.com/cliffzhou92/STT/tree/release/data. The EMT dataset of human lung A549 cell lines is available at GSE147405. The pancreas dataset (originally available at GSE132188) and adult human bone marrow datasets (originally available at https://data.humancellatlas.org/explore/projects/091cf39b-01bc-42e5-9437-f419a66c8a45) can be downloaded from the built-in datasets of the scvelo==0.2.4 package (https://scvelo.readthedocs.io/en/stable/api.html). The spatial datasets of mouse brain and chicken heart as well as scRNA-seq datasets used for imputation can be downloaded from https://doi.org/10.5281/zenodo.6798658 (ref. ^{62}). The Stereo-seq mouse brain dataset with unspliced and spliced counts was downloaded from the Spateo package (https://github.com/aristoteleo/spateo-tutorials, https://www.dropbox.com/s/c5tu4drxda01m0u/mousebrain_bin60.h5ad?dl=0). The KEGG database was originally available on the Enrichr webpage (https://maayanlab.cloud/Enrichr/#librariesdownloaded) and downloaded using gseapy==1.0.4. The processed datasets for analysis are also stored at https://disk.pku.edu.cn/link/AAD1681DAD531D47699D459BB46C4651D8.

## Code availability

STT is implemented as a Python package available at https://github.com/cliffzhou92/STT/tree/release. The source code for simulation and the notebook files to reproduce all analysis in the paper are also available at https://github.com/cliffzhou92/STT/tree/release/example_notebooks.

## References

Qiu, X. et al. Reversed graph embedding resolves complex single-cell trajectories.

*Nat. Methods***14**, 979–982 (2017).Haghverdi, L. et al. Diffusion pseudotime robustly reconstructs lineage branching.

*Nat. Methods***13**, 845–848 (2016).Wolf, F. A. et al. PAGA: graph abstraction reconciles clustering with trajectory inference through a topology preserving map of single cells.

*Genome Biol.***20**, 59 (2019).Weinreb, C. et al. Fundamental limits on dynamic inference from single-cell snapshots.

*Proc. Natl Acad. Sci. USA.***115**, E2467–E2476 (2018).Zhou, P. et al. Dissecting transition cells from single-cell transcriptome data through multiscale stochastic dynamics.

*Nat. Commun.***12**, 5609 (2021).La Manno, G. et al. RNA velocity of single cells.

*Nature***560**, 494–498 (2018).Bergen, V. et al. Generalizing RNA velocity to transient cell states through dynamical modeling.

*Nat. Biotechnol.***38**, 1408–1414 (2020).Lange, M. et al. CellRank for directed single-cell fate mapping.

*Nat. Methods***19**, 159–170 (2022).Weng, G., Kim, J. & Won, K. J. VeTra: a tool for trajectory inference based on RNA velocity.

*Bioinformatics***37**, 3509–3513 (2021).Zhang, Z. & Zhang, X. Inference of high-resolution trajectories in single-cell RNA-seq data by using RNA velocity.

*Cell Rep. Meth.***1**, 100095 (2021).Gupta, R. et al. Cytopath: simulation-based inference of differentiation trajectories from RNA velocity fields.

*Cell Rep. Meth.***2**, 100359 (2022).Atta, L., Sahoo, A. & Fan, J. VeloViz: RNA velocity-informed embeddings for visualizing cellular trajectories.

*Bioinformatics***38**, 391–396 (2022).Qiao, C. & Huang, Y. Representation learning of RNA velocity reveals robust cell transitions.

*Proc. Natl Acad. Sci. USA***118**, e2105859118 (2021).Liu, R. et al. Dynamical systems model of RNA velocity improves inference of single-cell trajectory, pseudo-time and gene regulation.

*J. Mol. Biol.***434**, 167606 (2022).Bocci, F., Zhou, P. & Nie, Q. spliceJAC: transition genes and state‐specific gene regulation from single‐cell transcriptome data.

*Mol. Syst. Biol.***18**, e11176 (2022).Longo, S. K. et al. Integrating single-cell and spatial transcriptomics to elucidate intercellular tissue dynamics.

*Nat. Rev. Genet.***22**, 627–644 (2021).Burgess, D. J. Spatial transcriptomics coming of age.

*Nat. Rev. Genet.***20**, 317–317 (2019).Ren, H. et al. Identifying multicellular spatiotemporal organization of cells with SpaceFlow.

*Nat. Commun.***13**, 4076 (2022).Abdelaal, T. et al. SIRV: spatial inference of RNA velocity at the single-cell resolution. Preprint at

*bioRxiv*https://doi.org/10.1101/2021.07.26.453774 (2021).Bergen, V. et al. RNA velocity—current challenges and future perspectives.

*Mol. Syst. Biol.***17**, e10282 (2021).Laurent, M. & Kellershohn, N. Multistability: a major means of differentiation and evolution in biological systems.

*Trends Biochem. Sci.***24**, 418–422 (1999).Ozbudak, E. M. et al. Multistability in the lactose utilization network of

*Escherichia coli*.*Nature***427**, 737–740 (2004).Zhu, R. et al. Synthetic multistability in mammalian cells.

*Science***375**, eabg9765 (2022).Shamir, M. et al. SnapShot: timescales in cell biology.

*Cell***164**, 1302–1302.e1 (2016).Qiu, X. et al. Mapping transcriptomic vector fields of single cells.

*Cell***185**, 690–711. e45 (2022).Gu, Y., Blaauw, D. & Welch, J. D. Bayesian inference of RNA velocity from multi-lineage single-cell data. Preprint at

*bioRxiv*https://doi.org/10.1101/2022.07.08.499381 (2022).Battich, N. et al. Sequencing metabolically labeled transcripts in single cells reveals mRNA turnover strategies.

*Science***367**, 1151–1156 (2020).Cao, J. et al. Sci-fate characterizes the dynamics of gene expression in single cells.

*Nat. Biotechnol.***38**, 980–988 (2020).Erhard, F. et al. scSLAM-seq reveals core features of transcription dynamics in single cells.

*Nature***571**, 419–423 (2019).Thom, R. Topological models in biology.

*Topology***8**, 313–335 (1969).Huang, S. et al. Cell fates as high-dimensional attractor states of a complex gene regulatory network.

*Phys. Rev. Lett.***94**, 128701 (2005).Zhou, J. X. et al. Quasi-potential landscape in complex multi-stable systems.

*J. R. Soc. Interface***9**, 3539–3553 (2012).Huang, S. et al. Processes on the emergent landscapes of biochemical reaction networks and heterogeneous cell population dynamics: differentiation in living matters.

*J. R. Soc. Interface***14**, 20170097 (2017).E, W., Li, T. & Vanden-Eijnden, E. Optimal partition and effective dynamics of complex networks.

*Proc. Natl Acad. Sci. USA***105**, 7907–7912 (2008).Bocci, F. et al. Theoretical and computational tools to model multistable gene regulatory networks.

*Rep. Prog. Phys.***86**, 106601 (2023).Gao, M., Qiao, C. & Huang, Y. UniTVelo: temporally unified RNA velocity reinforces single-cell trajectory inference.

*Nat. Commun.***13**, 6586 (2022).Li, S. et al. A relay velocity model infers cell-dependent RNA velocity.

*Nat. Biotechnol.***42**, 99–108 (2023).Cook, D. P. & Vanderhyden, B. C. Context specificity of the EMT transcriptional response.

*Nat. Commun.***11**, 2142 (2020).Jia, D. et al. Quantifying cancer epithelial–mesenchymal plasticity and its association with stemness and immune response.

*J. Clin. Med.***8**, 725 (2019).Ando, T. et al. Integrin α11 in non–small cell lung cancer is associated with tumor progression and postoperative recurrence.

*Cancer Sci.***111**, 200–208 (2020).Setty, M. et al. Characterization of cell fate probabilities in single-cell data with Palantir.

*Nat. Biotechnol.***37**, 451–460 (2019).La Manno, G. et al. Molecular architecture of the developing mouse brain.

*Nature***596**, 92–96 (2021).Attisano, L. & Labbé, E. TGFβ and Wnt pathway cross-talk.

*Cancer Metastasis Rev.***23**, 53–61 (2004).Ouyang, T. et al. Recent advances of the Hippo/YAP signaling pathway in brain development and glioma.

*Cell. Mol. Neurobiol.***40**, 495–510 (2020).Bernal, J. Thyroid hormones and brain development.

*Vitam. Horm.***71**, 95–122 (2005).Mantri, M. et al. Spatiotemporal single-cell RNA sequencing of developing chicken hearts identifies interplay between cellular differentiation and morphogenesis.

*Nat. Commun.***12**, 1771 (2021).Qiu, X. et al. Spateo: multidimensional spatiotemporal modeling of single-cell spatial transcriptomics. Preprint at

*bioRxiv*https://doi.org/10.1101/2022.12.07.519417 (2022).Jehle, A. & Garaschuk, O. The interplay between cGMP and calcium signaling in Alzheimer’s disease.

*Int. J. Mol. Sci.***23**, 7048 (2022).Li, T. et al. On the mathematics of RNA Velocity I: theoretical analysis.

*CSIAM Trans. Appl. Math.***2**, 1–55 (2021).Gillespie, D. T. The chemical Langevin equation.

*J. Chem. Phys.***113**, 297–306 (2000).Gorin, G. et al. RNA velocity unraveled.

*PLoS Comput. Biol.***18**, e1010492 (2022).Ma, S. et al. Chromatin potential identified by shared single-cell profiling of RNA and chromatin.

*Cell***183**, 1103–1116.e20 (2020).Gorin, G., Svensson, V. & Pachter, L. Protein velocity and acceleration from single-cell multiomics experiments.

*Genome Biol.***21**, 39 (2020).Shi, J. et al. Quantifying Waddington’s epigenetic landscape: a comparison of single-cell potency measures.

*Brief Bioinform.***21**, 248–261 (2020).Gulati, G. S. et al. Single-cell transcriptional diversity is a hallmark of developmental potential.

*Science***367**, 405–411 (2020).Marot-Lassauzaie, V. et al. Towards reliable quantification of cell state velocities.

*PLoS Comput. Biol.***18**, e1010031 (2022).Reuter, B., Fackeldey, K. & Weber, M. Generalized Markov modeling of nonreversible molecular kinetics.

*J. Chem. Phys.***150**, 174103 (2019).Metzner, P., Schutte, C. & Vanden-Eijnden, E. Illustration of transition path theory on a collection of simple examples.

*J. Chem. Phys.***125**, 084110 (2006).Scherer, M. K. et al. PyEMMA 2: a software package for estimation, validation, and analysis of Markov models.

*J. Chem. Theory Comput.***11**, 5525–5542 (2015).Tian, X.-J., Zhang, H. & Xing, J. Coupled reversible and irreversible bistable switches underlying TGFβ-induced epithelial to mesenchymal transition.

*Biophys. J.***105**, 1079–1089 (2013).Fang, Z., Liu, X. & Peltz, G. GSEApy: a comprehensive package for performing gene set enrichment analysis in Python.

*Bioinformatics***39**, btac757 (2023).Abdelaal, T. et al. SIRV: spatial inference of RNA velocity at the single-cell resolution.

*Zenodo*https://doi.org/10.5281/zenodo.6798658 (2022).

## Acknowledgements

This project was supported by National Institutes of Health grant nos. U01AR073159 and R01AR079150 (Q.N.), National Science Foundation grant nos. DMS1763272 (Q.N.) and MCB2028424 (Q.N.), The Simons Foundation (grant no. 594598 to Q.N.), NSFC grants no. 11825102 (T.L.), no. 12288101 (T.L. and P.Z.) and no. 8206100646 (P.Z.), National Key R&D Program of China grant no. 2021YFA1003300 (T.L.), Start-up grants of Peking University grant no. 7101303365 (P.Z.) and the High-performance Computing Platform of Peking University (P.Z.).

## Author information

### Authors and Affiliations

### Contributions

Q.N. and P.Z. conceived the project. P.Z. and T.L. designed the algorithm and implemented the code. P.Z. and F.B. performed the simulations, analyzed the data and interpreted the results. Q.N. and P.Z. wrote the paper. All authors revised and approved the paper. Q.N. supervised the project.

### Corresponding author

## Ethics declarations

### Competing interests

The authors declare no competing interests.

## Peer review

### Peer review information

*Nature Methods* thanks Jun Ding and Chen Qiao for their contribution to the peer review of this work. Peer reviewer reports are available. Primary Handling Editor: Madhura Mukhopadhyay, in collaboration with the *Nature Methods* team.

## Additional information

**Publisher’s note** Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Supplementary information

### Supplementary Information

Supplementary Notes 1 and 2, Tables 1–3 and Figs. 1–10.

## Rights and permissions

**Open Access** This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.

## About this article

### Cite this article

Zhou, P., Bocci, F., Li, T. *et al.* Spatial transition tensor of single cells.
*Nat Methods* **21**, 1053–1062 (2024). https://doi.org/10.1038/s41592-024-02266-x

Received:

Accepted:

Published:

Issue Date:

DOI: https://doi.org/10.1038/s41592-024-02266-x