Spatially-aware dimension reduction of transcriptomics data
Abstract Spatial sequencing technologies have allowed for studying the relationship between the physical organization of cells and their functional behavior. However, interpreting these data and deriving insights from them remains difﬁcult.
Here, we present a Bayesian statistical model that performs dimension reduction for these data in a spatially-aware manner. In particular, our proposed model captures the low-dimensional structure of gene expression while accounting for the spatial variability of expression. Our model also allows us to project dissociated scRNA-seq data onto a spatial grid, as well as use scRNA-seq impute and smooth the expression of spatial sequencing data. Through simulations and applications to spatial sequencing data, we show that our model captures joint structure of spatially-resolved and dissociated sequencing data.
Introduction
Spatial genomics technologies provide an opportunity to study the relationship between the molecular makeup of cells and their physical organization.
A variety of technologies have been developed in recent years [Ståhl et al., 2016, Rodriques et al., 2019, Stickels et al., 2021, Lee et al., 2021, Zhao et al., 2021], which have contributed to the understanding of cell types, disease, and responses to therapeutics.
While there are extensive applications of spatial genomics technologies, there remains a need for statistical methods that can distill these high-dimensional data into interpretable factors.
It is of particular interest to be able to decompose the variability of gene expression into a set of patterns that are driven by the cells’ spatial positions and another set of patterns that are driven solely by the cells’ expression behavior.
Previous methods for this task [Lopez et al., 2019, Zhu and Sabatti, 2020] have focused purely on imputation, while placing less emphasis on spatially-aware dimension reduction.
Moreover, it would be beneﬁcial to be able to leverage the vast collection of existing dissociated (non-spatially-resolved) single-cell RNA-sequencing data (scRNA-seq) to inform these factors.
Here, we build on recent work [Verma and Engelhardt, 2020a] by proposing a family of latent variable models that perform dimension reduction on spatial genomics data in a spatially-aware manner by decomposing the data variation into a set of spatial-related and non-spatial-related factors.
In particular, our proposed model captures the low-dimensional structure of gene expression while accounting for the spatial variability of expression.
Our model also allows us to project dissociated scRNA-seq data onto a spatial grid, as well as use scRNA-seq impute and smooth the expression of spatial sequencing data.
The probabilistic framing of our approach allows dissociated scRNA-seq data to be seamlessly incorporated into the model, and even opens the door for imputation of the dissociated cells’ spatial coordinates.
We demonstrate our model through a series of simulation studies and an application to two gene expression datasets.
Spatially-aware dimension reduction
Consider a set of n cells indexed by i = 1 , . .
. , n .
Denote cell
i ’s gene expression vector as
y i ∈
R p , where p is the number of genes measured, and denote y ij as the expression level of the j th gene in this cell.
Denote the cell’s spatial position as x i ∈ R d , where d is the dimension of the spatial domain (typically, d ∈ { 2 , 3 } in most applications).
For data collected from spatially-resolved sequencing technologies, x i is directly observed, but for data collected from dissociated cells using scRNA-seq, x i is unobserved.
Our modeling approach is built as an extension of the Gaussian process latent variable model (GPLVM)
[Lawrence, 2003, Titsias and Lawrence, 2010].
The GPLVM assumes that each feature of high-dimensional observations is generated from a GP projection of a lower-dimensional representation (latent variables) of the samples, plus noise.
The latent variables can then be investigated for inﬂuential patterns in the data.
We extend the GPLVM by augmenting the latent space to also include a set of ﬁxed covariates, which we specify as the spatial locations of the cells.
The high-dimensional outcome space is then a function of both unobserved latent variables and the spatial locations.
By placing a GP prior on this function, we obtain our model, which we call a semi-supervised Gaussian process latent variable model (ssGPLVM).
Speciﬁcally, let z i ∈ R d (cid:48) be the vector of unobserved latent variables for cell i , and let t i =
( x (cid:62) i , z (cid:62) i ) (cid:62) ∈ R
d + d (cid:48) be the concatenation of spatial coordinates and latent variables.
Then the ssGPLVM for cells
i = 1 , . .
. , n and genes j = 1 , . . .
p is given by
[Equation]
where π noise is the prior for the noise, and k ( · , · ) is a covariance function.
When cell i does not have observed spatial coordinates, x i is unobserved, and we place a Gaussian prior on it, x i ∼ N ( 0 d , I d ) .
In our work, we explore two choices for π noise : Gaussian noise π noise =
N (0 , σ 2 ) and Student’s t -distributed noise π noise
= T (0 , ν, σ 2 ) .
For the t -distributed noise, we optimize the noise variance σ 2 during inference, and we set the degrees of freedom ν = 4 based on prior work [Verma and
Engelhardt, 2020b].
Thus, the ssGPLVM allows for modeling gene expression from both spatially-resolved and dissociated cells under a single modeling framework.
Inference Our goal in inference for the ssGPLVM is to compute the posterior for the latent variables, p ( Z | X , Y ) .
When a subset of the spatial coordinates are unobserved, we also wish to compute the posterior for those spatial coordinates.
This posterior is intractable, so we use a variational inference approach using inducing points to approximate the posterior for the latent variables.
See Appendix
A.2 for details.
Results 3.1 ssGPLVM enables spatially-aware dimension reduction
We now show that the ssGPLVM can be used to perform spatially-aware dimension reduction.
We ﬁrst demonstrate this with synthetic data before applying it to spatially-resolved sequencing data.
Simulations We generated synthetic univariate gene expression data with a one-dimensional spatial coordinate.
We generated the data with a quadratic function, y = ax 2 + b .
We randomly sampled n = 200 spatial coordinates from the interval [ − 3 , 3] and sampled half of the outcomes with a = 1 , b = 0 and the other half with a = 1 , b = 4 .
We ﬁt both the GPLVM and the ssGPLVM on these data and visualized the latent variables.
Each parabola is colored by its spatial coordinates, and the latent coordinates are colored by which parabola they are from.
We ﬁnd that the GPLVM latent variables capture all variation, including the variation between the two parabolas and the spatial shape (Figure 1).
On the other hand, the SSPGLVM latent variables remove the variation due to the spatial coordinates, and we are better able to isolate the variation between the parabolas (Figure 1). [Figure]
Application to Visium data We next applied the ssGPLVM to a spatial transcriptomics dataset collected from the mouse cortex using the Visium platform [10x Genomics, 2020].
We ﬁt the model with d (cid:48)
= 2 latent variables and extracted the latent variables.
Visualizing the latent variables, we ﬁnd that there is some natural clustering of the cells in the latent space (Figure 2).
To more precisely deﬁne these clusters, we use the K -means algorithm to assign each point to one of K = 5 clusters in the latent space.
It is then possible to use this data to see what the latent variables capture in terms of biology (see Figure 6 in Appendix).
We next checked whether the ssGPLVM latent space captured any information about the spatial coordinates.
To check this, we again visualized the latent variables and colored each point by the ﬁrst spatial coordinate.
We ﬁnd that the spatial coordinates show only minor clustering on the latent variables, suggesting that the latent variables capture information apart from the spatial location (Figure 2).
3.2 ssGPLVM enables imputation of gene expression and spatial coordinates
We next sought to validate that our model can accurately impute partially missing data.
Simulations We ﬁrst generated non-spatial synthetic data with a two-dimensional outcome (Figure 3).
We then randomly dropped a single outcome variable for two samples and used the ssGPLVM to impute the dropped values.
Speciﬁcally, we ﬁt the ssGPLVM and computed the approximate posterior distribution over the missing values.
We ﬁnd that the model provides a reasonable estimate of both the mean and variance for the imputed values (Figure 3).
As a similar experiment, we next tested whether we could impute a missing spatial coordinate.
We ﬁnd that we are also able to impute the spatial coordinate within reasonable accuracy (Figure 3).
This suggests that our model is a feasible approach to jointly modeling partially-observed data in a semi-supervised manner.
Application to seqFISH+ data We then applied our model to a dataset from a mouse cortex collected using the seqFISH+ technology [Eng et al., 2019].
We ﬁrst impute missing gene expression of the seqFISH+ data set.
We ﬁnd that the imputed gene expression values lie reasonably within the range of what we expect to see (Figure 4).
Next, we impute spatial coordinates.
We randomly drop 10% of both of the spatial coordinates (x and y) in seqFISH+, and we use ssGPLVM to try to accurately impute them back.
In (Figure 4), we plot the imputed x and y spatial coordinates against the true x and y. If our imputation was perfect, the two plots would show a straight line since the imputed x
and y would be equal to the true x and y.
However, we do see a positive linear trend in both graphs that closely follow the identity line.
This result suggests that ssGPLVM is working properly, and is imputing within a reasonable accuracy.
Discussion
We propose a Bayesian statistical model, which we call the semi-supervised Gaussian process latent variable model (ssGPLVM) that captures low-dimensional structure of gene expression data while accounting for the spatial variability.
We demonstrate that the ssGPLVM can be used across modalities by jointly ﬁtting spatial spatially-resolved and dissociated gene expression data to learn the low-dimensional structure of expression, as well as impute partially missing gene expression and spatial coordinates from sequencing data.
With this knowledge, we can uncover genetic patterns and patterns across space that may not be accessible in one of the modalities separately.
As single cell technologies evolve, the ability to integrate data sets will become more vital part of any analysis pipeline.
The ssGPLVM offers a principled method for integrating single-cell data and potentially other types of multi-modal molecular data.
Future work includes ﬁtting the ssGPLVM on other existing data sets, such as from the Visium platform and comparing imputation results with related methods (such as PCA)
Checklist
For all authors... (a) Do the main claims made in the abstract and introduction accurately reﬂect the paper’s contributions and scope?
[Yes] (b) Did you describe the limitations of your work?
[Yes] (c) Did you discuss any potential negative societal impacts of your work?
[N/A] (d) Have you read the ethics review guidelines and ensured that your paper conforms to them?
[Yes] 2.
If you are including theoretical results... (a) Did you state the full set of assumptions of all theoretical results?
[N/A] (b) Did you include complete proofs of all theoretical results?
[N/A] 3.
If you ran experiments... (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)?
[N/A] (b) Did you specify all the training details (e
g., data splits, hyperparameters, how they were chosen)?
[Yes] (c) Did you report error bars (e g., with respect to the random seed after running experiments multiple times)?
[Yes] (d) Did you include the total amount of compute and the type of resources used (e
g., type of GPUs, internal cluster, or cloud provider)?
[N/A] 4.
If you are using existing assets (e
g., code, data, models) or curating/releasing new assets... (a) If your work uses existing assets, did you cite the creators?
[N/A] (b) Did you mention the license of the assets?
[N/A] (c) Did you include any new assets either in the supplemental material or as a URL?
[N/A] (d) Did you discuss whether
and how consent was obtained from people whose data you’re using/curating?
[N/A] (e) Did you discuss whether the data you are using/curating contains personally identiﬁable information or offensive content?
[N/A] 5.
If you used crowdsourcing or conducted research with human subjects... (a) Did you include the full text of instructions given to participants and screenshots, if applicable?
[N/A] (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable?
[N/A] (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation?
[N/A]
A Appendix A.1 Data A.1.1 seqFISH+
The seqFISH+ dataset we used was collected from the mouse visual cortex.
It measures the gene expression levels for a set of spatially-resolved cells (the "spatial" data set).
The full spatial data matrix is dimensions (913 cells, 9541 genes) and also includes spatial data for each cell.
Before imputing, we manipulate the data to be easier to work with, namely log transforming the gene expression data and normalizing the spatial data.
We use the manipulated data, and refer to it as the seqFISH+ data set.
A.1.2 Visium
This data set includes data on mouse brain slices generated using Visium v1 chemistry.
Tissue sections of 10 µm thickness from a sagittal slice of the posterior were placed on Visium Gene Expression
Slides.
Under the tissues, 3,355 spots were detected with approximately 4,772 genes per spot.
Visium spatial gene expression maintains spatial information, but the resolution of each spot can cover is limited as each spot can cover multiple cells.
We refer to this set as the Visium data set in this paper as we run our model on it.
A.2 Methods Variational inference for the tGPLVM
The joint probability model for the tGPLVM is given by
[Equation]
Noise model
[Equation]
GP
[Equation]
Latent
[Equation]
The posterior of interest is
[Equation]
We introduce a set of m auxiliary variables (inducing points) to facilitate variational inference.
Speciﬁcally, let B ∈ R m × d (cid:48) be a matrix of pseudo-inputs (inducing locations), and let U ∈ R m × p be a corresponding set of pseudo-outputs.
We attempt to conﬁgure these variables such that Y and F become conditionally independent given U in our posterior (Equation 2):
[Equation]
We approximate this posterior with a variational distribution of the form
[Equation]
We let q ( U ) and q ( Z ) be free-form multivariate Gaussians,
[Equation]
Our variational parameters are
[Equation]
To optimize this approximation [Equation] we maximize a lower bound on the log marginal likelihood (the evidence lower bound, or ELBO) with respect to the variational parameters:
[Equation]
We can simplify this expression as follows.
[Equation]
The ﬁnal two terms (the KL divergences) can be computed in closed-form given our Gaussian assumptions.
However, the ﬁrst term cannot be computed analytically.
Instead, we estimate this term with a Monte Carlo approximation,
[Equation]
[Table] (cid:96) = log p ( Y | (cid:98) F (cid:96)
[Table]
where we draw (cid:98) F (cid:96) from p ( F | Z , B ) , where U has been marginalized out.
This distribution is given by
[Equation]
) where
[Equation]
This ultimately becomes a two-step sampling procedure.
First, we sample (cid:98) Z ∼ q ( Z ) , and then we sample (cid:98) F ∼ p ( F | (cid:98) Z , B ) .
Variational inference for the ssGPLVM
In order to perform inference in the semisupervised version of the model, we make one minor change: we append the ﬁxed spatial dimensions to both the latent variables X and the inducing locations Z .
Denote the matrix of spatial coordinates as S ∈ R n × 2 , and let the augmented latent variables be given by
[Equation]
To incorporate the spatial coordinates into the inducing locations Z , we take one of two approaches.
First, similar to above, we can append a subset of the spatial locations to the inducing locations such that
[Equation]
where (cid:101) X ∈ R m × 2 is a subset of the spatial coordinates.
This subset can be chosen by, for example, k -means clustering of the spatial coordinates (where k = m ).
As a second approach, we can allow (cid:101) S to be an extra set of variational parameters, and optimize them as part of our approximate inference strategy.
A.3 Supplementary ﬁgures