Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Conditional Autoregressive Models on Spot Graphs

Spatial Transcriptomics · Tutorial 639 of 700

Conditional Autoregressive Models on Spot Graphs

Learn to build and interpret intrinsic and proper CAR precision matrices, identify the conditions that make them valid, and understand constraints and graph-edge effects.

Advanced 12 min read

What You'll Learn

  • Derive CAR precision matrices from conditional Gaussian specifications on a spot graph.
  • Distinguish a proper CAR prior from the singular intrinsic CAR prior.
  • State positive-definiteness conditions for the proper model.
  • Explain the component-wise constraints used to identify intrinsic effects.
  • Interpret how spot degree and boundary location affect conditional uncertainty.
  • Recognize isolated spots, disconnected components, and irregular degrees as important diagnostics.

Why Specify Spatial Effects Through a Graph?

A spatial random effect for each tissue spot can represent residual expression structure that is not explained by the measured covariates or the count model. A graph-based prior expresses a particular kind of local borrowing: effects at spots joined by graph edges are encouraged to be similar. The adjacency graph therefore does more than describe which spots are neighbors; through its precision matrix, it determines the pattern of dependence and the uncertainty assigned to each spot.

The earlier material on Gaussian processes describes spatial dependence through a covariance function. A conditional autoregressive (CAR) prior instead starts from conditional distributions given neighboring effects, then expresses the resulting joint Gaussian structure through a precision matrix. The distinction between a proper CAR prior and an intrinsic CAR prior is especially important: one has an ordinary nonsingular joint density, while the other has an unidentifiable constant level unless constraints are imposed.

Graph and Gaussian Setup

Suppose there are \(n\) spots. Let \(W=(w_{ij})\) be a fixed, symmetric adjacency-weight matrix, with \(w_{ij}\geq 0\), \(w_{ii}=0\), and \(w_{ij}>0\) when spots \(i\) and \(j\) are connected. For a binary graph, an edge has weight 1. Define the weighted degree of spot \(i\) as \(d_i=\sum_j w_{ij}\), and let \(D\) be the diagonal matrix with entries \(d_i\). Unless stated otherwise, assume every spot has positive degree. The spatial effects are \(u=(u_1,\ldots,u_n)^\mathsf{T}\).

The graph is treated as fixed, and the effects are assigned a Gaussian prior. The precision parameter \(\tau>0\) controls the overall strength of the prior: larger \(\tau\) penalizes graph-neighbor differences more strongly. These are assumptions about the latent spatial effects, not about the count likelihood used for observed expression.

Definition: In a proper CAR model, the conditional distribution of each effect given all the others is $$ u_i\mid u_{-i}\sim N\left(\rho\frac{\sum_j w_{ij}u_j}{d_i},\frac{1}{\tau d_i}\right), $$ where \(\tau>0\) and \(\rho\) is chosen so that the joint precision matrix is positive definite. Here \(u_{-i}\) denotes all effects other than \(u_i\). The resulting joint precision is \(Q=\tau(D-\rho W)\).

This specification requires a symmetric graph for the stated Gaussian joint model. If an adjacency construction gives directed or otherwise asymmetric weights, it cannot simply be inserted into this precision formula: the implied precision must be symmetric. In practice, one must first define a symmetric graph or use a different model. A spot with \(d_i=0\) also needs special treatment, because the conditional mean and variance above are undefined for that spot.

From Conditional Distributions to Precision

For a nonsingular multivariate normal vector with precision matrix \(Q\), the terms in its log density involving \(u_i\) are \(-\tfrac12 Q_{ii}u_i^2-u_i\sum_{j\ne i}Q_{ij}u_j\). Completing the square gives conditional variance \(1/Q_{ii}\) and conditional mean \(-\sum_{j\ne i}Q_{ij}u_j/Q_{ii}\). In a proper CAR model, the diagonal entries of \(Q=\tau(D-\rho W)\) are \(\tau d_i\), and its off-diagonal entries are \(-\tau\rho w_{ij}\). Substitution yields the conditional distribution in the definition.

$$ \operatorname{Var}(u_i\mid u_{-i})=\frac{1}{Q_{ii}}=\frac{1}{\tau d_i}, \qquad E(u_i\mid u_{-i})=-\frac{\sum_{j\ne i}Q_{ij}u_j}{Q_{ii}} =\rho\frac{\sum_j w_{ij}u_j}{d_i}. $$

The conditional mean is \(\rho\) times the weighted average of neighboring effects; it is not generally the unweighted average when edge weights differ. The parameter \(\rho\) controls how strongly that average enters the conditional mean. The matrix \(Q\), rather than a list of separate conditional distributions, is the compact description of the joint dependence.

To check that this joint Gaussian distribution exists, write \(S=D^{-1/2}WD^{-1/2}\). Then \(Q=\tau D^{1/2}(I-\rho S)D^{1/2}\). Because \(D\) is positive diagonal, \(Q\) is positive definite exactly when \(I-\rho S\) is positive definite. Equivalently, \(1-\rho\lambda_k>0\) for every eigenvalue \(\lambda_k\) of \(S\). For a nonnegative, undirected graph with no isolated spots, \(\rho\in[0,1)\) is a common sufficient choice; the full allowable range depends on the graph’s eigenvalues. At a boundary value such as \(\rho=1\) for a connected graph, positive definiteness fails.

Worked Example: A Proper CAR Prior on Three Spots

Consider three hypothetical spots arranged in a path, with edges \(1\)--\(2\) and \(2\)--\(3\), each of weight 1. Thus \(D=\operatorname{diag}(1,2,1)\). Set \(\tau=2\) and \(\rho=0.5\). The graph is symmetric and has no isolated spots, so the conditional specification is defined.

The precision matrix is

$$ Q=2(D-0.5W) = \begin{pmatrix} 2&-1&0\\ -1&4&-1\\ 0&-1&2 \end{pmatrix}. $$

Its leading principal minors are \(2\), \(2(4)-1=7\), and \(\det(Q)=2(8-1)-2=12\), all positive. By the positive-definiteness criterion for a symmetric matrix, \(Q\) is positive definite. The conditional distributions are

$$ u_1\mid u_{-1}\sim N(0.5u_2,0.5),\qquad u_2\mid u_{-2}\sim N(0.25(u_1+u_3),0.25),\qquad u_3\mid u_{-3}\sim N(0.5u_2,0.5). $$

For example, spot 2 has degree 2, so its conditional variance is \(1/(2\cdot2)=0.25\), and its conditional mean is \(0.5(u_1+u_3)/2\). Each endpoint has degree 1, giving variance \(1/(2\cdot1)=0.5\) and conditional mean \(0.5\) times its sole neighbor’s effect. These are conditional variances, not marginal variances.

Intrinsic CAR: Similarity Penalties and Constraints

The intrinsic CAR (ICAR) model sets \(\rho=1\), giving \(Q=\tau(D-W)\). Its quadratic form has a direct graph interpretation:

$$ u^\mathsf{T}Qu =\frac{\tau}{2}\sum_i\sum_j w_{ij}(u_i-u_j)^2 =\tau\sum_{\{i,j\}\text{ an edge}}w_{ij}(u_i-u_j)^2. $$

The last sum counts each undirected edge once. Thus the prior penalizes differences across graph edges and is unchanged if the same constant is added to every effect in a connected component. That invariance explains why \(Q\) is singular: the graph differences alone cannot identify a component’s overall level.

Definition: An intrinsic CAR prior has precision \(Q=\tau(D-W)\). If the graph has \(c\) connected components, the null space consists of vectors that are constant within each component, and \(Q\) has rank \(n-c\). To obtain a proper distribution on an identified parameter space, impose one constraint per component, commonly that the effects in that component sum to zero.

The unconstrained ICAR kernel is proportional to \(\exp(-u^\mathsf{T}Qu/2)\), but it does not integrate to a finite value over all of \(\mathbb{R}^n\). A component-wise sum-to-zero constraint removes the unpenalized constant direction for each component and defines a proper Gaussian distribution on the resulting lower-dimensional subspace. It does not turn \(Q\) into a positive-definite \(n\times n\) matrix; the precision remains singular in the full space.

The local conditional kernels conventionally associated with the ICAR precision have neighbor-average means and variances \(1/(\tau d_i)\), as in the formal CAR specification at \(\rho=1\). There is an important qualification: after imposing a global sum constraint, conditioning on all other coordinates determines the remaining coordinate exactly. Therefore those local kernels describe the unconstrained intrinsic specification, not ordinary full conditional distributions under the constrained, singular Gaussian measure.

Worked Example: Intrinsic Precision and the Constant-Level Constraint

Use the same three-spot path graph, now with \(\tau=1\) and \(\rho=1\). The intrinsic precision is

$$ Q=D-W= \begin{pmatrix} 1&-1&0\\ -1&2&-1\\ 0&-1&1 \end{pmatrix}. $$

The rows sum to zero, so \(Q(1,1,1)^\mathsf{T}=0\). Its rank is 2: the graph is connected, and its only unpenalized direction is a constant shift. An appropriate identifying constraint is \(u_1+u_2+u_3=0\). For the vector \(u=(1,0,-1)^\mathsf{T}\), the edge penalty is \((1-0)^2+(0-(-1))^2=2\), and direct multiplication gives \(u^\mathsf{T}Qu=2\), as required.

If the graph instead had two connected components, one constraint would not suffice. Each component could shift by its own constant without changing any edge difference, so a separate sum-to-zero constraint is needed within each component.

Degree, Boundaries, and Practical Diagnostics

The conditional variance \(1/(\tau d_i)\) makes degree differences consequential. In the proper CAR parameterization above, a spot with fewer neighbors has greater conditional variance, while a spot with more neighbors has less. The conditional mean also uses only that spot’s neighbors. Consequently, a spot at a tissue boundary, or one whose neighboring spots are missing, can receive a different amount of local information from an interior spot. These are graph-induced edge effects, not evidence that the boundary has a distinct biological expression pattern.

Conditional variance is not marginal variance: the latter depends on the entire inverse precision matrix \(Q^{-1}\) for a proper model, or on the constrained covariance for an ICAR model. Even in the three-spot proper example, the endpoint conditional variance is \(0.5\) and the middle conditional variance is \(0.25\); this comparison alone does not give their marginal variances. More generally, one global \(\tau\) does not guarantee equal marginal uncertainty across an irregular graph.

Before fitting either model, inspect the graph’s connected components, degree distribution, edge weights, and isolated spots. Confirm that edges represent the intended notion of spatial adjacency and that any asymmetry has been resolved. For a proper CAR model, verify the chosen \(\rho\) gives positive-definite \(Q\). For an intrinsic model, identify every component and impose constraints appropriate to the intended interpretation. Unusually low degrees, unexpectedly many components, or a result that changes substantially under reasonable graph adjustments are reasons to investigate the graph specification.

Worked Example: Boundary and Interior Conditionals on a Star Graph

Suppose four hypothetical spots form a star: spot 1 is connected to spots 2, 3, and 4, and the three leaves have no other edges. All edges have weight 1. Take \(\tau=1\) and \(\rho=0.6\). This graph is symmetric, has no isolated spots, and its normalized adjacency matrix has eigenvalues \(1,0,0,-1\). Therefore \(1-\rho\lambda\) is positive for each eigenvalue, so the proper precision is positive definite.

The center has degree 3, and each leaf has degree 1. The center’s conditional distribution is \(u_1\mid u_{-1}\sim N(0.2(u_2+u_3+u_4),1/3)\). Each leaf, for example spot 2, has \(u_2\mid u_{-2}\sim N(0.6u_1,1)\). The center is conditionally less variable because it has three neighbors; each leaf’s local conditional information comes from just one neighbor.

This calculation illustrates a graph effect, not a general claim that all boundary marginal variances equal 1 or all center marginal variances equal \(1/3\). Those numbers are conditional variances from the specified model. The graph geometry, \(\rho\), and the complete precision matrix determine marginal uncertainty.

Common Mistakes and Model Limits

  • Treating an intrinsic precision as nonsingular. A connected ICAR graph has a constant null direction. Use a constraint or an explicit treatment of the overall level; do not use the ordinary nonsingular Gaussian density formula with \(Q^{-1}\).
  • Using an asymmetric graph in a symmetric precision formula. The CAR joint Gaussian precision must be symmetric. Check the weights before constructing \(D-\rho W\).
  • Ignoring isolated spots or disconnected components. An isolated spot has degree zero, and each disconnected ICAR component has its own unidentified constant level. Handle isolated effects separately and constrain each nontrivial component as needed.
  • Calling conditional variance marginal uncertainty. \(1/(\tau d_i)\) is a conditional variance. Marginal uncertainty requires the joint covariance or its constrained counterpart.
  • Interpreting smoothing as biological truth. A CAR prior encodes a chosen graph-based dependence assumption. It does not establish that neighboring spots have the same underlying biology, and it may smooth across a real boundary if the graph includes such edges.

CAR priors are useful when local dependence on a spot graph is the intended structure and a sparse precision matrix is convenient. Their limitations follow from that same structure: results depend on graph choices, degree irregularity affects local uncertainty, and the Gaussian prior is an assumption about latent effects rather than the observed count distribution. An ICAR prior additionally requires careful identification; a proper CAR avoids that singularity only when its parameter satisfies the positive-definiteness condition.

Check Your Understanding

Try each question, then compare your reasoning with the solutions.

  1. For a symmetric graph with \(d_i>0\), what are the CAR conditional mean and variance implied by \(Q=\tau(D-\rho W)\)?
  2. A connected graph has an ICAR precision \(Q=\tau(D-W)\). What is its null direction, and what constraint commonly identifies the effects?
  3. On a spot with degree 4, let \(\tau=2\), \(\rho=0.5\), and let all four neighbors have effect 2. What are the conditional mean and variance?
  4. Why does an isolated spot require special treatment in the stated CAR specification?

Solutions. (1) The mean is \(\rho\sum_j w_{ij}u_j/d_i\), and the variance is \(1/(\tau d_i)\), by completing the square in the Gaussian density. (2) The constant vector is in the null space because \(D\mathbf{1}=W\mathbf{1}\); the common identifying constraint is \(\sum_i u_i=0\). (3) With unit weights for the four neighbors, the weighted neighbor average is 2, so the mean is \(0.5(2)=1\), and the variance is \(1/(2\cdot4)=0.125\). (4) Its degree is zero, so the conditional mean and variance formulas divide by zero; model that effect separately or revise the graph.

Clinical Biostats