Abstract
The spatial context of single-cell gene expression data is crucial for many downstream analyses, yet often remains inaccessible due to practical and technical limitations, restricting the utility of such datasets. In this paper, we propose a generic representation learning and transfer learning framework dp-VAE, capable of reconstructing the spatial coordinates associated with the provided gene expression data. Central to our approach is a distance-preserving regularizer integrated into the loss function during training, ensuring the model effectively captures and utilizes spatial context signals from reference datasets. During the inference stage, the produced latent representation of the model can be used to reconstruct or impute the spatial context of the provided gene expression by solving a constrained optimization problem. We also explore the theoretical connections between distance-preserving loss, distortion, and the bi-Lipschitz condition within generative models. Finally, we demonstrate the effectiveness of dp-VAE in different tasks involving training robustness, out-of-sample evaluation, and transfer learning inference applications by testing it over 27 publicly available datasets. This underscores its applicability to a wide range of genomics studies that were previously hindered by the absence of spatial data.
Introduction
In modern genomics, researchers often face a trade-off between high-resolution genetic information and spatial context. Single-cell RNA sequencing (scRNA-seq) provides detailed transcriptomic profiles but typically requires tissue dissociation, which destroys the spatial organization of cells. Conversely, Spatial Transcriptomics (ST) technologies preserve the physical "map" of the tissue but can be limited by resolution, cost, or technical complexity.
The fundamental challenge addressed in this work is whether spatial locations can be accurately reconstructed from gene expression data alone. By learning the relationship between genetic markers and physical distances in reference datasets, the proposed dp-VAE (Distance-Preserving Variational Autoencoder) framework aims to bridge this gap, enabling the reconstruction of spatial context for datasets where such information is missing.
Methodology
The core of the dp-VAE framework is a Variational Autoencoder augmented with a novel distance-preserving regularizer ($\mathcal{L}_{DP}$). While a standard VAE learns to compress data into a latent space $Z$ for reconstruction, dp-VAE enforces a geometric constraint: distances in the latent space must reflect physical distances in the original tissue.
Training and Loss Function
The model is trained on datasets containing both gene expression ($X$) and spatial coordinates ($S$). The total loss function combines the standard VAE reconstruction loss (ensuring the model captures biological signals) with the $\mathcal{L}_{DP}$ term. This regularizer forces the model to identify "marker genes" that are spatially informative. Mathematically, this approach is linked to the bi-Lipschitz condition, ensuring the mapping between genetic and spatial spaces is smooth and preserves geometric structure.
Inference and Spatial Reconstruction
During inference, the model processes new gene expression data to produce latent representations. To obtain physical coordinates, a constrained optimization problem—similar to Multidimensional Scaling (MDS)—is solved to "unfold" the latent space back into a 2D or 3D spatial map ($\hat{S}$).
Experimental Setup and Datasets
The framework was evaluated using 27 publicly available Visium Spatial Gene Expression datasets from 10x Genomics, primarily focusing on mouse brain sections. For each dataset, the top 100 most variable genes were utilized to ensure the model prioritized the most informative biological signals. Statistical analysis confirmed that in 23 out of 27 datasets, there is a significant correlation between transcriptomic similarity and physical proximity, validating the premise that gene expression contains sufficient information for spatial reconstruction.
Results and Discussion
Reconstruction Performance and Visual Fidelity
In out-of-sample evaluations, dp-VAE consistently outperformed standard VAEs. Performance was measured using the Procrustes distance, which quantifies the similarity between the reconstructed and ground-truth point clouds. Qualitative results demonstrate that dp-VAE successfully recovers the global tissue shape and relative positions of cell clusters.
As shown in the figure above, while a vanilla VAE often produces collapsed or jumbled latent representations, the distance-preserving loss in dp-VAE guides the latent space to mirror the ground-truth spatial geometry as training progresses.
Transfer Learning and Stability
The model exhibited strong transfer learning capabilities, where a model trained on one tissue section could assist in reconstructing another. Furthermore, the training process remained stable across all tested datasets, with the $\mathcal{L}_{DP}$ term not hindering convergence or causing training instability.
Conclusion
The dp-VAE framework introduces a robust method for "virtual" spatial transcriptomics. By treating tissue geometry as a regularizer rather than just a target variable, the model achieves superior stability and accuracy in spatial reconstruction. While challenges remain in "zero-shot" generalization across highly distinct organs, dp-VAE provides a powerful tool for adding a spatial dimension to existing non-spatial genomic archives, potentially unlocking new insights into tissue organization and cellular function.
Summary updated