Skip to contents

In geostatistical data, an underlying spatial process is sampled at known locations. Kriging uses a Gaussian process model to interpolate the values between the sample locations, and the semivariogram is used to model the spatial dependency between the locations as the covariance of the Gaussian process. When not kriging, the semivariogram can be used as an exploratory data analysis tool to find the length scale and anisotropy of spatial autocorrelation. The semivariogram is defined as

γ(t)=12Var(XtX0), \gamma(t) = \frac 1 2 \mathrm{Var}(X_t - X_0),

where XX is the value such as gene expression, and tt is a spatial vector. X0X_0 is the value at a location of interest, and XtX_t is the value lagged by tt. With positive spatial autocorrelation, the variance would be smaller among nearby values, so the variogram would increase with distance, eventually leveling off when the distance is beyond the length scale of spatial autocorrelation. The “semi” comes from the 1/2, which comes from the assumption that the Gaussian process is weakly stationary, i.e. the covariance between two locations only depends on the spatial lag between them:

Var(Xt2Xt1)=Var(Xt2)+Var(Xt1)2Cov(Xt2,Xt1)=2ρ(0)2ρ(t2t1),\begin{align} \mathrm{Var}(X_{t_2} - X_{t_1}) &= \mathrm{Var}(X_{t_2}) + \mathrm{Var}(X_{t_1}) - 2\mathrm{Cov}(X_{t_2}, X_{t_1}) \\ &= 2\rho(0) - 2\rho(t_2 - t_1), \end{align}

where ρ\rho is a covariance function and t1t_1 and t2t_2 are spatial locations. A model can be fitted to the empirical semivariogram, to model this ρ\rho. That the variance of differences between the value across locations only depends on the spatial lag means intrinsically stationary, which is even weaker and more generalizable than weakly stationary. The weaker assumption is used in kriging.

Below is a list of vignettes that use the variogram. The links point to the sections that use the variogram. The corresponding Google Colab notebooks are also linked to. The list is sorted by technology.

Vignette Colab Notebook Description
MERFISH mouse liver analysis Colab Notebook Compute variogram, variogram map, and anisotropic variogram on spatially binned total transcript counts
Variogram demo Colab Notebook Demonstrate variogram on melanoma metastasis Slide-seq data