''This page aims at helping people like me, interested in quantitative genetics, to get a better understanding of some Bayesian models, most importantly the impact of the modeling assumptions as well as the underlying maths. It starts with a simple model, and gradually increases the scope to relax assumptions. See references to scientific articles at the end.''

-

* '''Data''': let's assume that we obtained data from N individuals. We note <math>y_1,\ldots,y_N</math> the (quantitative) phenotypes (e.g. expression level at a given gene), and <math>g_1,\ldots,g_N</math> the genotypes at a given SNP (as allele dose, 0, 1 or 2).

+

* '''Data''': let's assume that we obtained data from N individuals. We note <math>y_1,\ldots,y_N</math> the (quantitative) phenotypes (e.g. expression levels at a given gene), and <math>g_1,\ldots,g_N</math> the genotypes at a given SNP (encoded as allele dose: 0, 1 or 2).

Line 21:

Line 21:

-

* '''Likelihood''':

+

* '''Likelihood''': we start by writing the usual linear regression for one individual

Let's define <math>\Omega = (\Sigma_B^{-1} + X^TX)^{-1}</math>. We can see that <math>\Omega^T=\Omega</math>, which means that <math>\Omega</math> is a [http://en.wikipedia.org/wiki/Symmetric_matrix symmetric matrix].

+

Importantly, let's define:

+

+

<math>\Omega = (\Sigma_B^{-1} + X^TX)^{-1}</math>

+

+

We can see that <math>\Omega^T=\Omega</math>, which means that <math>\Omega</math> is a [http://en.wikipedia.org/wiki/Symmetric_matrix symmetric matrix].

This is particularly useful here because we can use the following equality: <math>\Omega^{-1}\Omega^T=I</math>.

This is particularly useful here because we can use the following equality: <math>\Omega^{-1}\Omega^T=I</math>.

In this case, as we need neither <math>a</math> nor <math>d</math>, <math>B</math> is simply <math>\mu</math>, <math>\Sigma_B</math> is <math>\sigma_{\mu}^2</math> and <math>X</math> is a vector of 1's.

+

We can also defines <math>\Omega_0 = ((\sigma_{\mu}^2)^{-1} + N)^{-1}</math>.

When the Bayes factor is large, we say that there is enough evidence in the data to ''support the alternative''.

+

Indeed, the Bayesian testing procedure corresponds to measuring support for the specific alternative hypothesis compared to the null hypothesis.

+

Importantly, note that, for a frequentist testing procedure, we would say that there is enough evidence in the data to ''reject the null''.

+

However we wouldn't say anything about the alternative as we don't model it.

+

+

The threshold to say that a Bayes factor is large depends on the field. It is possible to use the Bayes factor as a test statistic when doing permutation testing, and then control the false discovery rate. This can give an idea of a reasonable threshold.

Such a question is never easy to answer. But note that all hyperparameters are not that important, especially in typical quantitative genetics applications. For instance, we are mostly interested in those that determine the magnitude of the effects, <math>\sigma_a</math> and <math>\sigma_d</math>, so let's deal with the others first.

+

+

As explained in Servin & Stephens, the posteriors for <math>\tau</math> and <math>B</math> change appropriately with shifts (<math>y+c</math>) and scaling (<math>y \times c</math>) in the phenotype when taking their limits.

+

This also gives us a new Bayes factor, the one used in practice (see Guan & Stephens, 2008):

Now, for the important hyperparameters, <math>\sigma_a</math> and <math>\sigma_d</math>, it is usual to specify a grid of values, i.e. <math>M</math> pairs <math>(\sigma_a, \sigma_d)</math>. For instance, Guan & Stephens used the following grid:

In the same vein as what is explained [http://openwetware.org/wiki/User:Timothee_Flutre/Notebook/Postdoc/2011/06/28 here], we can simulate data under different scenarios and check the BFs:

+

+

<nowiki>

+

N <- 300 # play with it

+

PVE <- 0.1 # play with it

+

grid <- c(0.05, 0.1, 0.2, 0.4, 0.8, 1.6, 3.2)

+

MAF <- 0.3

+

G <- rbinom(n=N, size=2, prob=MAF)

+

tau <- 1

+

a <- sqrt((2/5) * (PVE / (tau * MAF * (1-MAF) * (1-PVE))))

+

d <- a / 2

+

mu <- rnorm(n=1, mean=0, sd=10)

+

Y <- mu + a * G + d * (G == 1) + rnorm(n=N, mean=0, sd=tau)

+

for(m in 1:length(grid))

+

print(BF(G, Y, grid[m], grid[m]/4))

+

</nowiki>

+

+

+

* '''Binary phenotype''': using a similar notation, we model case-control studies with a [http://en.wikipedia.org/wiki/Logistic_regression logistic regression] where the probability to be a case is <math>\mathsf{P}(y_i = 1) = p_i</math>.

+

+

There are many equivalent ways to write the likelihood, the usual one being:

The interesting point here is that there is no way to calculate these integrals analytically. Therefore, we will use [http://en.wikipedia.org/wiki/Laplace_approximation Laplace's method] to approximate them, as in Guan & Stephens (2008).

Second, we need to calculate the second derivatives of <math>f</math>:

+

+

...

+

+

The second derivatives of <math>f</math> are strictly negative. Therefore, <math>f</math> is globally convex, which means that it has a unique global maximum, at <math>B^\star = [\mu^\star a^\star d^\star]^T</math>. As a consequence, we have the right to use the Laplace's method to approximate the integral around its maximum.

Revision as of 17:04, 11 January 2013

Bayesian model of univariate linear regression for QTL detection

This page aims at helping people like me, interested in quantitative genetics, to get a better understanding of some Bayesian models, most importantly the impact of the modeling assumptions as well as the underlying maths. It starts with a simple model, and gradually increases the scope to relax assumptions. See references to scientific articles at the end.

Data: let's assume that we obtained data from N individuals. We note the (quantitative) phenotypes (e.g. expression levels at a given gene), and the genotypes at a given SNP (encoded as allele dose: 0, 1 or 2).

Goal: we want to assess the evidence in the data for an effect of the genotype on the phenotype.

Assumptions: the relationship between genotype and phenotype is linear; the individuals are not genetically related; there is no hidden confounding factors in the phenotypes.

Likelihood: we start by writing the usual linear regression for one individual

where β1 is in fact the additive effect of the SNP, noted a from now on, and β2 is the dominance effect of the SNP, d = ak.

Even though we can write the likelihood as a multivariate Normal, I still keep the term "univariate" in the title because the regression has a single response, Y.
It is usual to keep the term "multivariate" for the case where there is a matrix of responses (i.e. multiple phenotypes).

We can see that ΩT = Ω, which means that Ω is a symmetric matrix.
This is particularly useful here because we can use the following equality: Ω − 1ΩT = I.

This now becomes easy to factorizes totally:

We recognize the kernel of a Normal distribution, allowing us to write the conditional posterior as:

Posterior of τ:

Similarly to the equations above:

But now, to handle the second term, we need to integrate over B, thus effectively taking into account the uncertainty in B:

Again, we use the priors and likelihoods specified above (but everything inside the integral is kept inside it, even if it doesn't depend on B!):

As we used a conjugate prior for τ, we know that we expect a Gamma distribution for the posterior.
Therefore, we can take τN / 2 out of the integral and start guessing what looks like a Gamma distribution.
We also factorize inside the exponential:

We recognize the conditional posterior of B.
This allows us to use the fact that the pdf of the Normal distribution integrates to one:

We finally recognize a Gamma distribution, allowing us to write the posterior as:

Joint posterior (2): sometimes it is said that the joint posterior follows a Normal Inverse Gamma distribution:

In Bayesian modeling, hypothesis testing is performed with a Bayes factor, which in our case can be written as:

We can shorten this into:

Note that, compare to frequentist hypothesis testing which focuses on the null, the Bayes factor requires to explicitly model the data under the alternative.
This makes a big difference when interpreting the results (see below).

Let's start with the numerator:

First, let's calculate what is inside the integral:

Using the formula obtained previously and doing some algebra gives:

Now we can integrate out τ (note the small typo in equation 9 of supplementary text S1 of Servin & Stephens):

Inside the integral, we recognize the almost-complete pdf of a Gamma distribution.
As it has to integrate to one, we get:

We can use this expression also under the null.
In this case, as we need neither a nor d, B is simply μ, ΣB is and X is a vector of 1's.
We can also defines .
In the end, this gives:

We can therefore write the Bayes factor:

When the Bayes factor is large, we say that there is enough evidence in the data to support the alternative.
Indeed, the Bayesian testing procedure corresponds to measuring support for the specific alternative hypothesis compared to the null hypothesis.
Importantly, note that, for a frequentist testing procedure, we would say that there is enough evidence in the data to reject the null.
However we wouldn't say anything about the alternative as we don't model it.

The threshold to say that a Bayes factor is large depends on the field. It is possible to use the Bayes factor as a test statistic when doing permutation testing, and then control the false discovery rate. This can give an idea of a reasonable threshold.

Hyperparameters: the model has 5 hyperparameters, . How should we choose them?

Such a question is never easy to answer. But note that all hyperparameters are not that important, especially in typical quantitative genetics applications. For instance, we are mostly interested in those that determine the magnitude of the effects, σa and σd, so let's deal with the others first.

As explained in Servin & Stephens, the posteriors for τ and B change appropriately with shifts (y + c) and scaling () in the phenotype when taking their limits.
This also gives us a new Bayes factor, the one used in practice (see Guan & Stephens, 2008):

Now, for the important hyperparameters, σa and σd, it is usual to specify a grid of values, i.e. M pairs (σa,σd). For instance, Guan & Stephens used the following grid:

Then, we can average the Bayes factors obtained over the grid using, as a first approximation, equal weights:

In eQTL studies, the weights can be estimated from the data using a hierarchical model (see below), by pooling all genes together as in Veyrieras et al (PLoS Genetics, 2010).

Binary phenotype: using a similar notation, we model case-control studies with a logistic regression where the probability to be a case is .

There are many equivalent ways to write the likelihood, the usual one being:

Using Xi to denote the i-th row of the design matrix X and keeping the same definition as above for B, we have:

As the yi's can only take 0 and 1 as values, the likelihood can be written as:

We still use the same prior as above for B (but there is no τ anymore) and the Bayes factor now is:

The interesting point here is that there is no way to calculate these integrals analytically. Therefore, we will use Laplace's method to approximate them, as in Guan & Stephens (2008).

Starting with the numerator:

Let's use f to denote the function inside the exponential:

First we need to calculate the first derivatives of f, noting that they all have a very similar form:

where x is μ, a or d.

Also, there is a simple form for the first derivatives of pi:

where is 1 for μ, gi for a, and for d.

This gives us one equation per parameter:

Second, we need to calculate the second derivatives of f:

...

The second derivatives of f are strictly negative. Therefore, f is globally convex, which means that it has a unique global maximum, at . As a consequence, we have the right to use the Laplace's method to approximate the integral around its maximum.