MARADONER

Gene regulatory network

Promoters against motifs

Motif activities tell what motifs are at work in a group of samples. The next question is what promoters each of them works on. The grn command tests each promoter against each motif in each group. Some people call the outcome a gene regulatory network (GRN), hence the name of the command. The method is a heuristic built on top of the fitted model.

> maradoner grn MyProject results

The command runs after predict. It writes a table of promoters by motifs for each group into the results/belief folder. A cell of a table is a belief: the posterior probability that the motif contributes to the expression of the promoter in that group.

How is a belief computed?

We take one promoter, one motif and one group. The model tells how much the motif contributes to the expression of the promoter in each sample of the group: it is the loading times the activity of the motif in the sample. With all the estimates plugged in, the expression of the promoter then has 2 explanations: the full model, and the same model with the contribution of the motif taken out.

Expression 1 promoter, 1 group Full model means + all motifs Model without the motif means + the other motifs likelihood L1 likelihood L0 Belief between 0 and 1

Both explanations are Gaussian with the error variance of the group (times the weight of the promoter, if the model was fitted with --promoter-variance), so each has a likelihood. If $L_1$ is the likelihood of the full model, $L_0$ is the likelihood of the model without the motif and $π$ is the prior probability that a motif has an effect on a promoter, then the belief is $${π L_1}/{π L_1 + (1 - π) L_0}.$$ By default, $π$ is a neutral 0.5.

A belief above $π$ says that the promoter is explained better with the motif than without it, and a belief below $π$ says the opposite. A pair with a zero loading has a belief of $π$ exactly, as the motif contributes nothing to such a promoter either way. So with a sparse loading matrix only the promoters carrying a motif can be linked to it.

Nothing is fitted anew at this step. The estimates are plugged in as if they were exact, hence the word "heuristic" above.

What exactly is taken out?

The picture above has 2 models, and they differ in one motif at one promoter. Let $b$ be the loading of the motif at the promoter. In a sample $n$, the full model holds the term $$b (μ + a x_n + u_n).$$ Here, $μ$ is the mean activity of the motif, $a$ is its effect of a covariate, $x_n$ is the covariate in the sample and $u_n$ is the deviation of the activity in the sample. The term with $a$ is there only in a project with covariates, and with several covariates it is a sum over them. The second model lacks a part of that term, and the part depends on the options:

activity of the motif in a sample default a table per group Mean taken out Effect × covariate taken out Deviation taken out + + --no-means a table per group Mean stays Effect × covariate stays Deviation taken out + + --covariate a table per covariate Mean stays Effect × covariate taken out Deviation stays + +

In the picture, a row is a mode of grn, and an orange part is absent from the second model. A grey part stays in both models and is not tested. Written out, the term of the second model is

Mode Full model Second model The question
Default $b (μ + a x_n + u_n)$ 0 Does the motif matter for the promoter in this group at all?
--no-means $b (μ + a x_n + u_n)$ $b (μ + a x_n)$ Does the deviation of the motif in this group matter for the promoter?
--covariate $b (μ + a x_n + u_n)$ $b (μ + u_n)$ Does the effect of the covariate on the motif matter for the promoter?

The terms of all the other motifs are the same in both models. In the first 2 modes the likelihoods are computed over the samples of a group. In the third one they are computed over all samples, as discussed below.

From beliefs to a network

A table of beliefs is not a network yet. For each group, MARADONER also finds a threshold: the pairs with a belief at or above it have a Bayesian false discovery rate of 0.05. The threshold is a single number saved next to the table, e.g. results/belief/group_1.txt. The pairs passing it are the links of the network of the group:

promoter 1 promoter 2 promoter 3 promoter 4 promoter 5 promoter 6 motifs 1 to 5 Beliefs, a table per group at or above the threshold 1 2 3 4 5 1 2 3 4 5 6 Network of the group motifs promoters

In the picture, the darker a cell the higher the belief, and the outlined cells pass the threshold. Motif 3 and promoter 6 have no links at all. That is a regular outcome.

In the Quickstart example, the threshold of group_1 is 0.85, and 122352 of the 854920 pairs (14%) pass it. The picture below shows all the beliefs of that group:

A histogram of beliefs: pairs with active motifs spread from 0 to 1, pairs with motifs of no activity pile up around 0.5A histogram of beliefs: pairs with active motifs spread from 0 to 1, pairs with motifs of no activity pile up around 0.5
Beliefs of the pairs of group_1. The vertical axis is logarithmic.

The dataset has motifs of zero activity, and 49 of them were kept by predict. Their beliefs pile up around the prior: 94% of them lie between 0.45 and 0.55, and the highest one is 0.76. None of their pairs passes the threshold. That's fine.

The synthetic loadings are dense (every motif has a non-zero loading at every promoter), so the network is dense too: a promoter is linked to 62 motifs and an active motif to 167 promoters (medians).

What about covariates?

In a project with covariates, an activity has a part due to them: the effect of a covariate times the covariate. As the table above shows, by default it is tested in one lump with the mean and the deviation, and with --no-means it is not tested at all. The --covariate option tests it alone. Let's take the project of the Covariates section and look for the promoters explained by the effect of age:

> maradoner grn MyProject results --covariate age

Here, the value of the option is the name of a covariate as create lists it. In the second model, the motif keeps its mean and its deviations and loses its effect of age. An effect is the same in all groups, so the samples are no longer split by groups. All of them enter one likelihood, each sample with the error variance of its group. The outcome is one table, results/belief/covariates/age.hdf, with a threshold next to it in age.txt.

The threshold is 0.87, and 67649 of the 968500 pairs (7.0%) pass it. All of them belong to motifs with a true effect of age. The stronger the effect the more promoters are linked to a motif: 31% of the pairs pass for the motifs with a true effect of 0.4 or more in absolute value, and none for those with an effect below 0.1. For the batch_batch_2 covariate, 1 pair of the 968500 passes. That's fine: the batches were assigned at random.

The option can be given several times for a table per covariate, and --covariate all stands for all the covariates of a project. The name of an interaction is accepted too.

These tables hold all motifs of the project. A motif left out by predict has no deviations to speak of, but it has an effect of a covariate like any other motif. Here 66 motifs were left out, and 7 of them have links.

Which mode suits which question?

The 3 modes answer different questions, and a link means a different thing in each:

Question Mode A link says
What regulates a promoter in a given condition? Default The expression of the promoter in the group is explained better with the motif than without it
What makes a group different from the others? --no-means The expression of the promoter in the group departs from its usual level, and the deviation of the motif in the group explains it
What changes with age, dose, time or another property of samples? --covariate The expression of the promoter follows the covariate across the samples, and the effect of the covariate on the motif explains it

Default

The default network describes a group as such. Most of it comes from the mean activities. In the Quickstart example, the share of promoters linked to a motif in group_1 has a correlation of 0.96 with the absolute value of the true mean activity of the motif. Hence the networks of different groups share many links: for a pair of groups, a median of 27% of the links found in either group is found in both.

This mode suits a project where the groups are studied one at a time, and a question about the regulators of a gene in general. It suits a comparison of groups poorly: a link present in one table and absent from another may be a matter of the threshold or of the error variance of a group.

--no-means

A deviation is the activity of a motif in a group relative to its average over all samples. A network of deviations therefore holds what is specific to a group. A motif equally active everywhere has no links in it, however strong it is as a regulator.

This network is much smaller. In the same example the default mode finds from 7777 to 122352 links per group, and --no-means finds from 14 to 125. That's expected: a group there has 5 or 6 samples, and a deviation is small next to a mean. The mode goes well with the tests: a motif is first found to differ between groups, and its links then tell at what promoters the difference shows.

In a project with covariates, a difference between groups that follows a covariate is absent from the deviations, and hence from this network.

--covariate

This mode is for a property of samples known beforehand and passed to create. It is not tied to a group, and it gains from the number of samples. In the example above, 67648 of the 67649 links belong to motifs with a significant effect of age in params/covariates/age.tsv. So the table of effects tells what motifs respond to a covariate, and the network adds the promoters.

For a categorical covariate, a link is about the difference between a level and the reference level.

In all modes

Reading the tables

A table is read in Python with pandas:

import pandas as pd

belief = pd.read_hdf('results/belief/group_1.hdf')
with open('results/belief/group_1.txt') as f:
    threshold = float(f.read())
pairs = belief.stack()
pairs = pairs[pairs >= threshold]

Here, pairs is a list of the promoter-motif pairs passing the threshold with their beliefs. The beliefs are stored in half precision to save space.

Options

Name Description Default value
--prior-h1 <float> The prior $π$: the expected fraction of motifs active at a promoter, strictly between 0 and 1 0.5
--no-means By default, the effect of a motif is its loading times its whole activity, the mean plus the deviation. With this option, only the deviation of the group is tested, and the mean activity stays in both models --means
--covariate <name> The effect of a covariate on the activities is tested in place of the activities, over all samples. The table goes to the belief/covariates folder. See above Disabled
--stat The likelihood ratios are saved alongside the beliefs, to the lr folder Disabled
--no-hdf Plain tab-separated tables in place of HDF --hdf

Promoters with an error variance of 0.001 or less are left out of the tables, and MARADONER prints a warning when that happens.

On this page