scHINT (single-cell gene expression Heritability with gene-by-cell-context INTeractions) estimates, for one gene at a time, how the variance of expression divides into
- a main genetic component that is the same in every cell,
- a genotype-by-context (G×C) component whose size changes with the cell’s state or type,
- an individual component shared by all cells of a donor but not genetic,
- context and covariate components, and
- cell-level residual noise.
The same Haseman-Elston (HE) machinery is used in three settings, which differ only in what “context” is and in what links observations:
| setting | function | unit of observation | genetic kernel | context |
|---|---|---|---|---|
| cell-level | schint_cell() |
cell | cis-GRM between donors | continuous cell state (PCs, pseudotime, …) and/or categorical |
| sample-level | schint_sample() |
donor × cell type (pseudobulk) | cis-GRM between donors | cell type |
| perturbation | schint_pert() |
cell | “same perturbation” | cell state or cell type (one at a time) |
1. Generative model (cell-level, G×Cell-State)
Let \(y_{im}\) be the normalized expression of the gene in cell \(m\) of individual \(i\) (\(i=1,\dots,n\); \(m=1,\dots,M_i\)), \(g_i\in\mathbb{R}^p\) the standardized cis-genotypes (by default all SNPs within ±500 kb of the gene), \(c_{im}\in\mathbb{R}^K\) the cell-state features (for example the leading within-cell-type principal components) and \(o_{im}\in\mathbb{R}^L\) further covariates. Then
\[ y_{im}= g_i^\top\beta + (g_i\otimes c_{im})^\top\gamma + c_{im}^\top\alpha + o_{im}^\top\eta + e_i + \varepsilon_{im}, \]
with independent random effects
\[ \beta\sim N\!\left(0,\tfrac{\sigma_G^2}{p}I_p\right),\quad \gamma_k\sim N\!\left(0,\tfrac{\sigma_{G\times C,k}^2}{p}I_p\right),\quad e_i\sim N(0,\sigma_I^2),\quad \varepsilon_{im}\sim N(0,\sigma_\varepsilon^2). \]
\(\beta\) is the main cis-genetic effect, \(\gamma_k\) is how that effect is modulated along cell-state axis \(k\), \(\alpha\) and \(\eta\) are the non-genetic effects of state and covariates, \(e_i\) is the donor effect shared across cells and \(\varepsilon_{im}\) is cell-level noise. In the package \(\sigma_C^2\) and \(\sigma_o^2\) denote the variance contributed by \(c^\top\alpha\) and \(o^\top\eta\) (treated as random).
2. Haseman-Elston regression on pairs of cells
Define the cis-genetic relatedness (GRM)
\[K^G_{ij}=\frac{g_i^\top g_j}{p}.\]
For two different cells \((i,m)\neq(j,n)\),
\[ \mathbb{E}(y_{im}y_{jn})=\sigma_G^2K^G_{ij} +\sum_{k=1}^{K_\text{int}}\sigma_{G\times C,k}^2K^G_{ij}c_{imk}c_{jnk} +\sigma_I^2\mathbf 1(i=j) +\sum_{k=1}^{K}\sigma_{C,k}^2c_{imk}c_{jnk} +\sum_{l=1}^{L}\sigma_{O,l}^2o_{iml}o_{jnl}. \]
The residual term \(\sigma_\varepsilon^2\mathbf 1(i=j,m=n)\) vanishes for distinct cells. Because every term is a known kernel times an unknown variance, the variances are estimated by ordinary least squares of the cross-product \(y_{im}y_{jn}\) on the kernels over all pairs:
\[ y_{im}y_{jn}\sim 1 + K^G_{ij} + \mathbf 1(i=j) + \sum_k c_{imk}c_{jnk} + \sum_l o_{iml}o_{jnl} + \sum_{k=1}^{K_\text{int}} K^G_{ij}\,c_{imk}c_{jnk}. \]
The coefficients are the variance components \(\hat\sigma^2\) (the leading 1
absorbs the mean). The estimator is moment based: no likelihood, no
iteration, and it remains valid without Gaussian errors (the variances
may come out slightly negative; see Troubleshooting).
Mapping to package output
(fit$coefficients$component):
| symbol | component name | group |
|---|---|---|
| \(\sigma_G^2\) |
G (or G1, G2, … with several
GRMs) |
G |
| \(\sigma_{G\times C,k}^2\) | G:<context variable> |
GxC |
| \(\sigma_I^2\) | I |
I |
| \(\sigma_{C,k}^2\) | <context variable> |
context |
| \(\sigma_{O,l}^2\) | <covariate> |
covariate |
| \(\sigma_{G\times C}^2=\sum_k\sigma_{G\times C,k}^2\) | summary row GxC
|
Variables are standardized (mean 0, variance 1) by default, so each estimate is directly a variance contribution on the scale of standardized expression.
Several GRMs
Passing a list of GRMs in grm (e.g. built from SNPs
split by MAF bin or annotation with split_snps() and
make_grm()) replaces \(K^G\) by \(K^{G,1},\dots,K^{G,M}\), each with its own
main component \(\sigma^2_{G,m}\) and
its own interaction \(\sigma^2_{G\times
C,m,k}\). Components of different GRMs enter the normal equations
through the element-wise products \(K^{G,m}\circ K^{G,m'}\).
Categorical contexts
For a categorical context with levels \(t\), the pair product \(c_{imk}c_{jnk}\) is replaced by \(\mathbf 1(t_{im}=t_{jn})\): the G×C kernel
becomes \(K^G_{ij}\mathbf
1(t_{im}=t_{jn})\) (genetic variance specific to pairs from the
same level) and the main-effect kernel becomes \(\mathbf 1(t_{im}=t_{jn})\). With
cat_mode = "per_level" each level gets its own component,
giving a variance per level.
3. Sample-level G×Cell-Type model
For pseudobulk expression \(y_{it}\) of individual \(i\) in cell type \(t=1,\dots,T\),
\[ y_{it}=g_i^\top\beta+g_i^\top\gamma_t+\alpha_t+o_{it}^\top\eta+e_i+\varepsilon_{it}, \]
where \(\beta\) is the genetic effect shared across cell types, \(\gamma_t\) the cell-type-specific deviation (\(\gamma_t\sim N(0,\sigma^2_{G\times CT}p^{-1}I_p)\)), \(\alpha_t\sim N(0,\sigma_T^2)\) the cell-type mean and \(e_i\) a donor effect shared across cell types. For two observations \((i,s)\ne(j,t)\)
\[ \mathbb{E}(y_{is}y_{jt})=\sigma_G^2K^G_{ij}+\sigma^2_{G\times CT}K^G_{ij}\mathbf 1(s=t) +\sigma_{CT}^2\mathbf 1(s=t)+\sigma_I^2\mathbf 1(i=j). \]
schint_sample() regresses \(y_{is}y_{jt}\) on these four kernels (plus
covariate kernels). \(\sigma_G^2\) is
the cross-cell-type shared genetic variance and \(\sigma^2_{G\times CT}\) the
cell-type-specific genetic variance. With gxc = FALSE only
the shared-genetics model is fitted.
4. Perturbation model
For a perturbation screen the unit that links cells is the perturbation rather than the donor. With \(p_m\) the perturbation of cell \(m\) and \(c_m\in\mathbb{R}^K\) the (standardized) cell state,
\[ y_m=b_{p_m}+\sum_k c_{mk}\alpha_k+\sum_k c_{mk}u_{p_mk}+\varepsilon_m, \]
\[ b_p\sim N(0,\sigma_P^2),\quad \alpha_k\sim N(0,\sigma_{C,k}^2),\quad u_{pk}\sim N(0,\sigma_{P\times C,k}^2), \]
so \(\sigma^2_P\) is the perturbation-associated variance shared across states and \(\sigma^2_{P\times C,k}\) the variance of the perturbation response along axis \(k\). For two cells \(m\neq n\)
\[ y_my_n\sim 1+\mathbf 1(p_m=p_n)+\sum_k c_{mk}c_{nk}+\mathbf 1(p_m=p_n)\sum_k c_{mk}c_{nk}, \]
i.e. the genetic kernel is replaced by “same perturbation”. With a
categorical context (cell type) the last two terms use \(\mathbf 1(t_m=t_n)\). The context is one
variable per fit: a cell state or a cell type. All genes measured in the
same cells share the same pair kernels, so schint_pert()
builds \(X^\top X\) once and re-uses it
for every gene.
5. Scalable estimation from sufficient statistics
Forming all cell pairs costs \(O(M^2K^2)\) time and \(O(M^2)\) memory for \(M\) cells, which is impossible for millions of cells. Every regressor in the models above has the form
\[ X_r[(i,m),(j,n)] = \kappa_r(i,j)\,\sum_q u_{rq}(i,m)\,u_{rq}(j,n), \]
a donor kernel \(\kappa_r\) (all-ones, \(\mathbf 1(i=j)\), a GRM, or “same perturbation”) times a pair product of cell-level features \(u_r\) (a column of ones, a standardized covariate, or a one-hot encoding). The normal equations need only
\[ (X^\top X)_{rs}=\sum_{a<b}X_r[a,b]X_s[a,b],\qquad (X^\top y)_r=\sum_{a<b}X_r[a,b]\,y_ay_b . \]
Write \(z_a=u_r(a)\odot u_s(a)\) and let \(W_i=\sum_{a\in i}z_a\) be its sum over the cells of donor \(i\). Then
\[ (X^\top X)_{rs}=\tfrac12\Big[\sum_{i,j}(\kappa_r\circ\kappa_s)_{ij}\,W_i^\top W_j -\sum_a(\kappa_r\circ\kappa_s)_{i(a)i(a)}\,\lVert z_a\rVert^2\Big], \]
and \((X^\top y)_r\) is the same expression with \(z_a=u_r(a)\,y_a\) and kernel \(\kappa_r\). Only the donor-level sums \(W_i\) are needed, so the cost is \(O(N^2K^2)\) time and \(O(N^2)\) memory for \(N\) donors, independent of the number of cells except for one linear pass. Solving the small normal equations gives the variance components. This is exactly equivalent to regressing over all pairs (the package tests this against an explicit pairwise OLS).
6. Standard errors: donor-block jackknife
Because \(X^\top X\) and \(X^\top y\) are sums over donor pairs, dropping a block \(B\) of donors only removes terms with \(i\in B\) or \(j\in B\) from the same quadratic forms. All leave-block-out versions are therefore obtained from the already computed \(W_i\) at almost no extra cost; no re-fitting or bootstrapping is required. With \(B\) blocks and leave-one-block-out estimates \(\hat\theta_{(b)}\),
\[ \widehat{\mathrm{SE}}(\hat\theta)=\sqrt{\tfrac{B-1}{B}\sum_b\big(\hat\theta_{(b)}-\bar\theta_{(\cdot)}\big)^2}. \]
By default every donor is a block (n_blocks = NULL); in
schint_pert() blocks are perturbations. Standard errors are
also returned for derived quantities (sums of components,
heritabilities), because they are computed from the leave-block-out
component vectors.
7. Heritability
fit$summary reports each component’s variance
(variance, on the standardized-expression scale, so it is
also the fraction of the variance of expression). Single-cell variance
contains a large cell-specific part that averaging over cells removes.
To make the estimates comparable to population-level heritability,
h2 (cell-level models only; pseudobulk variances are
already population-level) removes the cell-level residual \(\sigma_\varepsilon^2\) from the
denominator:
\[ h^2_G=\frac{\sigma_G^2}{\sigma_G^2+\sigma^2_{G\times C}+\sigma_C^2+\sigma_o^2+\sigma_I^2},\qquad h^2_{G\times C}=\frac{\sigma_{G\times C}^2}{\sigma_G^2+\sigma^2_{G\times C}+\sigma_C^2+\sigma_o^2+\sigma_I^2}. \]
This is the variance that would be explained if every cell were
measured without stochastic noise. The aggregate context-dependent
component is GxC; G_total is
G + GxC. For the perturbation model the summary gives the
variance of each component (P, PxC,
P_total, per-context and per-group splits).
8. Practical notes
- Genotypes are standardized by allele frequency, \(\operatorname{GRM}=XX^\top/p\).
- The response is centred and scaled; context and covariates are
standardized (
scale_xfor the latter). - A covariate also listed in
contextis not duplicated: context variables always carry a main-effect and an interaction term. - The model is Gaussian; it does not model count sparsity. Use normalized, log-transformed (and residualized if desired) expression.
Reference. Wang L., Fadil C., Wang L., Van Dyke K., Gusev A. Single-cell gene expression heritability informed by gene × cell-context interactions (manuscript).