Regularization of motif means
The mean activity $μ_m$ of a motif is estimated by generalized least squares. With many motifs, or with many similar ones, these estimates fit the levels of the training promoters too closely and predict the levels of other promoters poorly. The --motif-mean-prior option of fit shrinks them with a prior. The deviations of activities, the variances and their tests stay as they are.
Why do the means need it?
The model has the promoter mean $μ_p$ and the motif part $B μ_m$ of the level of a promoter, and only their sum is identified. MARADONER takes the promoter means orthogonal to the loadings, so the mean activities are a regression of the promoter levels on the loadings. A level has a part explained by the motifs and a baseline of the promoter, and the regression picks up some of the baselines as well. The more motifs there are for the number of promoters, the larger that share. For any other promoter it is noise.
A prior pulls the means towards a common value, and the data decide how strongly: $$μ_m ∼ N(μ_0 1_m, P).$$ Here, $μ_0$ is a common mean of all motifs, $1_m$ is a vector of ones, and $P$ is a covariance matrix with a few variances. The variances and $μ_0$ are estimated by REML, and $μ_m$ is replaced by its posterior mean.
Example
The effect shows when the motifs are many. Let's generate a dataset with 1500 motifs for its 2000 promoters and create a project from it:
> maradoner generate demo --m 1500 > maradoner create Wide demo/expression.tsv demo/loadings.tsv --sample-groups demo/groups.json --loading-transform none
The prior is about the prediction for other promoters, so we hold 400 promoters out, picked at random and listed in test_promoters.txt. First, the fit without a prior:
> maradoner fit Wide --test-promoters-filename test_promoters.txt > maradoner predict Wide > maradoner estimate-promoter-mean Wide > maradoner gof Wide
┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Set ┃ centering ┃ + mean motif activity ┃ + group-specific motif activity ┃ ┃ Y = ┃ mu_p 1_s^T + 1_p mu_s^T ┃ + B M X ┃ + B U ┃ ┡━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ train │ 0.058409 │ 0.730318 │ 0.988766 │ │ test │ 0.055645 │ 0.654376 │ 0.874084 │ └───────┴─────────────────────────┴───────────────────────┴─────────────────────────────────┘
The full model explains 99% of the variance of the training promoters and 87% of the held-out ones. Then the same with a prior:
> maradoner fit Wide --test-promoters-filename test_promoters.txt --motif-mean-prior covariance
The output of fit gets a line about the prior:
prior on the motif means (covariance): kappa_s^2 = 0.0881, kappa^2 = 0.498, mu_0 = 0.00235; the norm of the means is 32.8 (GLS: 36.7).
Here, kappa_s^2 and kappa^2 are the variances of the prior, and mu_0 is the common mean. The norm of the vector of mean activities went down from 36.7 to 32.8. After predict, estimate-promoter-mean and gof as above, the table is
┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Set ┃ centering ┃ + mean motif activity ┃ + group-specific motif activity ┃ ┃ Y = ┃ mu_p 1_s^T + 1_p mu_s^T ┃ + B M X ┃ + B U ┃ ┡━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ train │ 0.073475 │ 0.730318 │ 0.988766 │ │ test │ 0.055645 │ 0.703074 │ 0.922272 │ └───────┴─────────────────────────┴───────────────────────┴─────────────────────────────────┘
The FOV of the held-out promoters rose from 0.874 to 0.922, and from 0.654 to 0.703 for the mean activities alone. The last 2 columns of the training row did not change. The promoter means take back what the prior took from $B μ_m$, so the sum $μ_p + B μ_m$ of a training promoter stays the same, and only the first column moves. The means are closer to the true ones as well: their root mean squared error is 0.320 without the prior and 0.221 with it.
For the dataset of the Quickstart, with 500 independent motifs, the prior changes little: the FOV of 392 held-out promoters goes from 0.58895 to 0.58907 for the mean activities. That is fine, as the data pin down the means well there. On a muscle atlas of 36,120 CAGE promoters with 4 chromosomes held out, the covariance prior raised the FOV of the held-out promoters from 0.186 to 0.213.
Which prior?
The option takes one of the values below. The variances of $P$ are named as in the output of fit.
| Name | $P$ | Description |
|---|---|---|
none |
(Default) No prior: the estimates of generalized least squares | |
ridge |
$κ^2 I$ | All motifs are shrunk towards $μ_0$ alike. This is the ridge regression with a free common mean |
families |
$κ_f^2 F F^T + κ^2 I$ | On top of the ridge, the means of the motifs of a family share a part, with one variance $κ_f^2$ for all families. Needs --motif-families |
covariance |
$κ_s^2 S + κ^2 I$ | On top of the ridge, a multiple of the fitted covariance $S$ between motif activities: $Σ$ in the basic model, and with the families and factors when they are given. A motif whose activity varies much is allowed a mean further from $μ_0$, and correlated motifs get correlated means |
In the example above, the ridge prior raised the FOV of the held-out promoters to 0.920 and the covariance prior to 0.922. On the muscle atlas the covariance prior did best as well. The family prior came out the same as the ridge there: its $κ_f^2$ was estimated close to zero.
What changes in the results?
- The mean column of params/motif_means.tsv and of params/covariates/intercept.tsv holds the posterior means. The std column is the standard deviation of their prediction error, with the uncertainty of $μ_0$ included;
- The test of the sign of a motif uses the new means and standard errors;
- The promoter means change, and $μ_p + B μ_m$ of a training promoter does not;
- Only the mean activities are changed. With covariates, their effects on motifs stay as they are;
- The deviations of activities, the variances and their tests do not change. They are computed from the expression minus $μ_p + B M X$, and that stays the same.
The prior takes about a second on the examples above and 24 seconds with 4785 columns of loadings.
