Suppose part of a trait’s variation acts through gene expression: a few genes whose expression levels shift the phenotype, in addition to markers that act directly. If the expression itself is partly heritable, some of that expression-mediated variation traces back to the genome and some does not. This chapter builds such a phenotype on the maize genotypes, reads the causal genes from the usual tables, and checks how the package splits the mediated component into its genetic and environmental parts.
Assumptions and theory
The expression layer and its split are package definitions. The equation map records them as the package’s own design, mirroring the scaling of additive(), with the mediation split described as an analogue of the mediated-expression estimand used in the literature on expression-mediated heritability (recorded without a verified page, and not relied on here).
The expression component
For trait \(t\) with causal gene set \(S\), slopes \(b_g\), and expression \(E_g\),
\[
T_x = c \sum_{g \in S} w_g z_g, \qquad
w_g = \frac{b_g}{\max_{g' \in S} \lvert b_{g'} \rvert}, \qquad
z_g = \frac{E_g - \bar E_g}{s_{E_g}}, \qquad
c = \frac{\sqrt{\pi_x}}{s_{\sum_g w_g z_g}}.
\tag{19.1}\]
The bar is the sample mean over the scored individuals and \(s\) the sample standard deviation; \(\pi_x\) is the requested share prop. The component has sample variance \(\pi_x\) exactly. This is implemented in .tx_raw() and .transcriptome_matrix(); the chunk above reproduced it.
The split
Because each gene’s expression is its genetic part plus its residual, \(E_g = \mu_g + G_g + R_g\), standardizing both parts by the same denominator \(s_{E_g}\) decomposes the standardized expression additively, \(z_g = z_g^{\text{genetic}} + z_g^{\text{env}}\). Applying the same weights and the same scale \(c\) gives
\[
T_{x,g} = c \sum_{g \in S} w_g \frac{G_g - \bar G_g}{s_{E_g}}, \qquad
T_{x,e} = T_x - T_{x,g}.
\tag{19.2}\]
The reported shares are \(\operatorname{Var}(T_{x,g})/V_P\), \(\operatorname{Var}(T_{x,e})/V_P\), and \(2\operatorname{Cov}(T_{x,g}, T_{x,e})/V_P\), with \(V_P\) the sample variance of the phenotype. They sum to \(\operatorname{Var}(T_x)/V_P\) by the sample variance identity of Section A.2. The covariance term is close to zero because the generator draws the genetic and residual parts of expression independently, but it is reported rather than assumed. The split is computed in .tx_raw(which = "genetic") and .mediation_budget(), averaged over simulation replications.
The realized broad-sense ratio
With \(\text{Gen}\) the sum of the marker layers, the genetic value is \(\text{Gen} + T_{x,g}\) and the realized ratio is
\[
H^2_{\text{realized}} = \frac{\operatorname{Var}(\text{Gen} + T_{x,g})}{V_P}.
\tag{19.3}\]
For a real expression source, \(T_{x,g}\) is set to zero. The ratio is a sample diagnostic, not a population parameter, for the reasons given in the first chapter. Each gene’s var_explained is \((c\,w_g)^2 / V_P\), a marginal share that ignores covariance among the genes’ standardized expressions, so the shares need not sum to the component’s share.
Implementation and practical limits
The layer lives in transcriptome() (R/transcriptome_layer.R) and the scoring and split in the realization helpers of R/grammar_realize.R. The gene rows of qtn_table() are written by the same export code as marker rows, with coordinates and allele frequency left missing.
- The layer scores the latent normalized expression, never the counts produced by
observe_counts(). Count data are an observation layer only.
prop for the expression layer is outside the marker h2 budget; the sum of all layer shares is checked against one.
- With
reps, the residual is divided by the square root of the number of records, while the genetic value and the expression component are unchanged.
- A real expression matrix contributes no genetic variance by definition, even if its genes are in fact heritable. Use a derived transcriptome, possibly calibrated with
mimic, when the genetic content matters.
- Explicit
genes must name rows of the expression source without duplicates; explicit slopes must have one finite value per causal gene.
- Cross-population reuse follows
predict() from the previous chapter: a transcriptome predicted for new individuals can be passed to simulate_phenotype() for those individuals, but the phenotype’s residual and layer draws are new.