Full presentation
MAGIC · 54 slides
Loading presentation…
This note follows my presentation on van Dijk et al., Recovering Gene Interactions from Single-Cell Data Using Data Diffusion (Cell, 2018). MAGIC stands for Markov Affinity-based Graph Imputation of Cells.
1. What sparsity hides
Single-cell expression matrices contain many zeros. An observed zero may reflect absence of expression or failure to capture an existing transcript. A count matrix alone does not generally identify the explanation for each zero.
The presentation motivates MAGIC with sparse marker-gene observations in mouse bone marrow data. If a known marker is detected in only a small fraction of its expected cell population, relationships between genes can be difficult to see.
MAGIC borrows information from cells with similar global expression patterns. Its assumption is that nearby cells on the underlying biological manifold tend to have similar expression. This makes it a smoothing method with a biological motivation, rather than an oracle for recovering every missing molecule.
2. From expression to distances
Write the expression matrix as $X\in\mathbb R^{n\times p}$, with cells in rows. A cell representation is obtained after appropriate preprocessing and dimensionality reduction. Distances are calculated in that representation.
For vectors $z_i$ and $z_j$, Euclidean distance is
\[d_{ij}=\sqrt{\sum_{\ell}(z_{i\ell}-z_{j\ell})^2}.\]The square root distinguishes Euclidean distance from squared distance. Dividing the sum of squared differences by the number of coordinates gives a mean squared difference instead.
Distance is not yet a smoothing weight: a more distant cell should usually contribute less, not more.
3. From distances to affinities
A decreasing kernel converts distance into affinity. A simple Gaussian example is
\[K_{ij}=\exp\left(-\frac{d_{ij}^{2}}{2\sigma_i^2}\right).\]This equation illustrates the idea, rather than specifying every detail of the implementation. MAGIC uses an adaptive neighborhood construction: the local scale varies with cell density, and the affinities are symmetrized before normalization.
A fixed bandwidth can behave differently in dense and sparse regions. A local scale makes the meaning of a neighborhood depend on the surrounding observations.
4. Markov normalization
Normalize the affinity matrix by row:
\[P_{ij}=\frac{K_{ij}}{\sum_j K_{ij}}, \qquad \sum_jP_{ij}=1.\]Each row now defines transition probabilities from one cell to other cells. This is a mathematical random walk on a similarity graph, not a claim that an observed cell physically changes into a neighboring cell.
For the affinity vector in the presentation,
\[(0.35,1,0,0.28),\]the sum is $1.63$, giving
\[(0.2147,\;0.6135,\;0,\;0.1718).\]This corrected normalization is useful because every row must sum to one before it can be interpreted as a weighted average.
5. Applying the diffusion operator
For one step of smoothing,
\[X^{(1)}=PX.\]Suppose the expression of one gene across the four cells is $(7,3,0,4)$. For the row above, the smoothed value is
\[\frac{0.35(7)+1(3)+0(0)+0.28(4)}{1.63} =\frac{6.57}{1.63} \approx4.03.\]The value is an average weighted by similarity, including the cell’s own contribution. It does not need to be an integer count.
After $t$ steps,
\[X^{(t)}=P^tX.\]Here, $P^t$ is a matrix power, not an elementwise power and not the matrix exponential $e^{tP}$. A multi-step transition can connect cells through paths even when their direct affinity is small.
What diffusion time controls
Small $t$ preserves more local variation. Larger $t$ averages information over broader neighborhoods. For an ergodic finite Markov chain, sufficiently many steps drive rows toward a stationary distribution, eventually erasing distinctions among starting cells.
This explains the tradeoff: diffusion can reveal a smooth trend while excessive diffusion can remove a real boundary or rare state.
6. Applications in the presentation
Marker genes and cell populations
The bone marrow examples compare marker-expression patterns before and after smoothing. The presentation also discusses agreement with protein-level measurements. Such external evidence is more informative than judging a result only by how smooth its scatter plot looks.
Neuronal data and simulated corruption
The neuronal examples ask whether MAGIC preserves distinct populations while recovering structure obscured by noise. Simulated corruption provides a controlled setting where the original structure is known.
Successful recovery in a benchmark is evidence about that benchmark. It does not establish that all relationships appearing after smoothing are real.
Epithelial-to-mesenchymal transition
The EMT application studies intermediate cellular states rather than only epithelial and mesenchymal endpoints. The data are cross-sectional snapshots; the trajectory is inferred from expression rather than observed by following the same cell through time.
The presentation uses VIM expression as a proxy for progression and discusses two related tools:
- DREVI: visualization of conditional relationships between variables.
- DREMI: a score for statistical dependence.
These tools help summarize nonlinear patterns. Neither dependence nor an inferred ordering establishes a causal gene-regulatory interaction.
7. What should be inferred from a smoothed matrix?
MAGIC modifies the whole expression matrix, including nonzero observations. It can alter variance and gene-gene correlation because neighboring cells contribute to each other’s values.
For exploratory visualization, this may make an underlying pattern easier to examine. For formal hypothesis tests, smoothed values should not simply be substituted for independent raw counts in a model that assumes the original sampling process.
A useful analysis checks how conclusions change with neighborhood size and diffusion time, compares results with the original data, and looks for independent biological support.
The relevant distinction is between a denoised representation and new experimental evidence. Smoothing creates the former.
For sample-aware differential analysis, see muscat. For normalization and embeddings in the full workflow, see Techniques of scRNA-seq.
References
- Presentation source:
03.MAGIC.pptx, slides 1–54. Arithmetic examples above use corrected normalization. - van Dijk et al. (2018). Recovering Gene Interactions from Single-Cell Data Using Data Diffusion. Cell.