Other models
This section covers what stands apart from the main workflow: a model for a single sample, the classic MARA, a choice between motif collections and the generator of synthetic data. All of them start from a project made with create, the generator excepted.
Single-sample data
MARADONER reads activities off the variation of expression across samples. With a single sample there is nothing to vary, and fit stops with an error. For such data there is the bayes_linreg command. It fits a different model, where the replication comes from the promoters:
$$y = μ 1_p + B u + e,\: e \,~\, N(0, σ^2 I_p),\: u \,~\, N(0, Σ).$$
Here, $y$ is the expression of one sample, $μ$ is a scalar mean, $σ^2$ is a scalar error variance and $Σ$ is a diagonal matrix of motif variances. The variances are estimated with REML, and the activities are the posterior mean of $u$. Some of the motif variances shrink to exactly zero on the way, and the motifs with a non-zero variance are the relevant ones (the approach is known as automatic relevance determination).
Unlike the usual chain of commands, this one goes straight from a project to the result files:
> maradoner bayes_linreg MyProject results
If the project has several samples, each one is fitted independently. The folder gets 2 tables:
| File | Content |
|---|---|
| motifs.tsv | A row per motif per sample: activity, its posterior standard deviation std, the z-score z, p_value, fdr_bh, the variance of the motif and the fraction of variance lost when the motif alone is removed (fov) |
| samples.tsv | A row per sample: the mean, the error variance, the fraction of variance explained, the number of motifs with a non-zero variance and the number of significant ones |
The --alpha option sets the FDR level for the count of significant motifs (0.05 by default), and --promoters adds a table of the fitted expression.
Classic MARA
The classic model is available under the mara command. It has 4 subcommands of the familiar names, and they work with the same project:
> maradoner mara fit MyProject > maradoner mara predict MyProject > maradoner mara gof MyProject > maradoner mara export MyProject results_mara
The files of the 2 models do not interfere, so both can be fitted to one project and compared. It is a reimplementation made as a baseline for the tests of MARADONER.
The options of mara fit specific to the classic model are:
| Name | Description | Default value |
|---|---|---|
--tau-mode <str> |
The model: mara or ismara |
mara |
--tau-estimation <str> |
The variance of motif activities is either fixed or estimated with maximum likelihood (mle) |
fixed |
--tau-fix <float> |
The value of the variance when it is fixed | 0.1 |
The exported folder has activities per sample (activities_raw.tsv), their z-scores (activities.tsv and z_scores.tsv) and the variances per sample (params.tsv).
Choosing between motif collections
The same transcription factor may have a motif in several collections, and the loadings obtained with them differ. When a project is created from several loading matrices with postfixes, the select-motifs command picks the best variant of each motif:
> maradoner create Both expression.tsv hocomoco.tsv jaspar.tsv -p hoc -p jas > maradoner fit Both > maradoner predict Both > maradoner select-motifs Both best_motifs.txt > maradoner create MyProject expression.tsv hocomoco.tsv jaspar.tsv -p hoc -p jas --motif-filename best_motifs.txt
Here, the first 3 commands fit a model with all variants at once. The fourth one writes the names of the winners, one per line and with the postfixes, to best_motifs.txt. The last one creates the final project with the winners alone.
The variants of a motif are compared by a score on the z-scale. It combines the z-score of the mean activity of a variant with the z-scores of its deviations in the groups, and the variant of the highest score wins.
A model with all variants at once has many nearly collinear motifs, and fit may warn about a singular Fisher information. That's fine for the purpose of selection, as the standard errors of the variances take no part in the score.
Synthetic data
The generate command draws a dataset from the model with random parameters and saves both the data and the parameters:
> maradoner generate folder_name
The folder gets the input files for create (expression.tsv, loadings.tsv, groups.json) and the truth: activities.tsv, motif_means.tsv, Sigma.tsv with the motif variances, sigma.tsv and nu.tsv with the variances of groups, promoter_means.tsv and sample_means.tsv. The loadings are uniform random numbers, so a project is better created from them with --loading-transform none.
| Name | Description | Default value |
|---|---|---|
--p <int> |
Number of promoters | 2000 |
--m <int> |
Number of motifs | 500 |
--g <int> |
Number of groups | 10 |
--min-samples <int>, --max-samples <int> |
The size of each group is drawn between these 2 numbers | 5, 6 |
--non-significant-motifs-fraction <float> |
The share of motifs with an activity of zero. Their names start with inactive_ | 0.2 |
--sigma-rel <float> |
The ratio of $ν$ to $σ$. The higher it is, the more variance the motifs explain | 0.1 |
--no-means |
Promoter-wise and sample-wise means are set to zero | --means |
--n-covariates <int> |
Number of sample covariates. A covariates.tsv file is written, and the true effects go to M_gt.tsv | 0 |
--error-lowrank <int>, --activity-lowrank <int> |
Ranks of the low-rank corrections injected into the covariance of the noise and of the activities | 0, 0 |
--families <int>, --family-scale <float> |
The number of motif families among which the active motifs are split at random, and their variances $ω$ relative to the mean $τ$. The families are written to families.txt and their variances to family_variances_gt.tsv | 0, 1 |
--motif-lowrank <int>, --motif-lowrank-scale <float> |
The rank of a covariance between families, or between motifs without families, and the size of the entries of $L$ relative to the square root of the mean $τ$. $L$ is written to L_motif_gt.tsv | 0, 1 |
--windows <names> |
Comma-separated names of windows around the TSS, e.g. core,up,down. Each motif gets a column of loadings per window, the windows of a motif form a family, and an active motif acts through all its windows together, through one of them or both. With --families the motifs form families of a second level, listed in families.txt by the families of windows of their motifs. Both levels go to families.txt and the truth per motif to windows_gt.tsv, see Motif families and windows |
None |
--seed <int> |
Random seed | 1 |
