Skip to contents

Introduction

This vignette contains the computations that underlie the numerical code of vsn. If you are a new user and looking for an introduction on how to use vsn, please refer to the vignette Robust calibration and variance stabilization with vsn, which is provided separately.

Setup and Notation

Consider the model:

arsinh(f(bi)⋅yki+ai)=μk+εki(#eq:model)\begin{equation} \text{arsinh}\left(f(b_i)\cdot y_{ki}+a_i\right) = \mu_k + \varepsilon_{ki} (\#eq:model) \end{equation}

where μk\mu_k, for k=1,…,nk=1,\ldots,n, and aia_i, bib_i, for i=1,…,di=1,\ldots,d are real-valued parameters, ff is a function ℝ→ℝ\mathbb{R}\to\mathbb{R} (see below), and εki\varepsilon_{ki} are i.i.d. Normal with mean 0 and variance σ2\sigma^2. ykiy_{ki} are the data. In applications to μ\muarray data, kk indexes the features and ii the arrays and/or colour channels.

Examples for ff are f(b)=bf(b)=b and f(b)=ebf(b)=e^b. The former is the most obvious choice; in that case we will usually need to require bi>0b_i>0. The choice f(b)=ebf(b)=e^b assures that the factor in front of ykiy_{ki} is positive for all b∈ℝb\in\mathbb{R}, and as it turns out, simplifies some of the computations.

In the following calculations, I will also use the notation

Y≡Y(y,a,b)=f(b)⋅y+ah≡h(y,a,b)=arsinh(f(b)⋅y+a).\begin{align} Y \equiv Y(y,a,b) &= f(b)\cdot y+a\\ h \equiv h(y,a,b) &= \text{arsinh}\left(f(b)\cdot y+a\right). \end{align}

The probability of the data (yki)k=1…n,i=1…d(y_{ki})_{k=1\ldots n,\;i=1\ldots d} lying in a certain volume element of yy-space (hyperrectangle with sides [ykiα,ykiβ][y_{ki}^\alpha,y_{ki}^\beta]) is

P=∏k=1n∏i=1d∫ykiαykiβdykipNormal(h(yki),μk,σ2)dhdy(yki),\begin{equation} P=\prod_{k=1}^n\prod_{i=1}^d \int\limits_{y_{ki}^\alpha}^{y_{ki}^\beta} dy_{ki}\;\; p_{\text{Normal}}(h(y_{ki}),\mu_k,\sigma^2)\;\; \frac{dh}{dy}(y_{ki}), \end{equation} where μk\mu_k is the expectation value for feature kk and σ2\sigma^2 the variance.

With

pNormal(x,μ,σ2)=12πσ2exp⁡(−(x−μ)22σ2)\begin{equation} p_{\text{Normal}}(x,\mu,\sigma^2)=\frac{1}{\sqrt{2\pi\sigma^2}} \exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right) \end{equation}

the likelihood is

L=(12πσ2)nd∏k=1n∏i=1dexp⁡(−(h(yki)−μk)22σ2)⋅dhdy(yki).(#eq:likelihood)\begin{equation} L=\left(\frac{1}{\sqrt{2\pi\sigma^2}}\right)^{nd} \prod_{k=1}^n \prod_{i=1}^d \exp\left(-\frac{(h(y_{ki})-\mu_k)^2}{2\sigma^2}\right) \cdot\frac{dh}{dy}(y_{ki})\,. (\#eq:likelihood) \end{equation}

For the following, I will need the derivatives

∂Y∂a=1∂Y∂b=y⋅f′(b)dhdy=f(b)1+(f(b)y+a)2=f(b)1+Y2,∂h∂a=11+Y2,∂h∂b=y1+Y2⋅f′(b).\begin{align} \frac{\partial Y}{\partial a}&=1\\ \frac{\partial Y}{\partial b}&=y\cdot f'(b)\\ \frac{dh}{dy}&= \frac{f(b)}{\sqrt{1+(f(b)y+a)^2}}= \frac{f(b)}{\sqrt{1+Y^2}},\\ \frac{\partial h}{\partial a}&=\frac{1}{\sqrt{1+Y^2}},\\ \frac{\partial h}{\partial b}&=\frac{y}{\sqrt{1+Y^2}}\cdot f'(b). \end{align}

Note that for f(b)=bf(b)=b, we have f′(b)=1f'(b)=1, and for f(b)=ebf(b)=e^b, f′(b)=f(b)=ebf'(b)=f(b)=e^b.

Likelihood for Incremental Normalization

Here, incremental normalization means that the model parameters μ1,…,μn\mu_1,\ldots,\mu_n and σ2\sigma^2 are already known from a fit to a previous set of μ\muarrays, i.,e. a set of reference arrays. See Section @ref(sec:prof) for the profile likelihood approach that is used if μ1,…,μn\mu_1,\ldots,\mu_n and σ2\sigma^2 are not known and need to be estimated from the same data. Versions ≥2.0\ge2.0 of the vsn package implement both of these approaches; in versions 1.X1.X only the profile likelihood approach was implemented, and it was described in the initial publication (Huber et al. 2002).

First, let us note that the likelihood @ref(eq:likelihood) is simply a product of independent terms for different ii. We can optimize the parameters (ai,bi)(a_i,b_i) separately for each i=1,…,di=1,\ldots,d. From the likelihood @ref(eq:likelihood) we get the ii-th negative log-likelihood

−log⁡(L)=∑i=1d−LLi−LLi=n2log⁡(2πσ2)+∑k=1n((h(yki)−μk)22σ2+log1+Yki2f(bi))=n2log⁡(2πσ2)−nlog⁡f(bi)+∑k=1n((h(yki)−μk)22σ2+12log(1+Yki2))(#eq:nll)\begin{align} -\log(L) &=\sum_{i=1}^d -LL_i\\ -LL_i&=\frac{n}{2}\log\left(2\pi\sigma^2\right)+ \sum_{k=1}^n \left(\frac{(h(y_{ki})-\mu_k)^2}{2\sigma^2} +\log\frac{\sqrt{1+Y_{ki}^2}}{f(b_i)}\right)\\ &=\frac{n}{2}\log\left(2\pi\sigma^2\right) -n\log f(b_i) +\sum_{k=1}^n\left(\frac{(h(y_{ki})-\mu_k)^2}{2\sigma^2} +\frac{1}{2}\log\left(1+Y_{ki}^2\right)\right) (\#eq:nll) \end{align}

This is what we want to optimize as a function of aia_i and bib_i. The optimizer benefits from the derivatives. The derivative with respect to aia_i is

∂∂ai(−LLi)=∑k=1n(h(yki)−μkσ2+Yki1+Yki2)⋅11+Yki2=∑k=1n(rkiσ2+AkiYki)Aki(#eq:ddanll)\begin{align} \frac{\partial}{\partial a_i}(-LL_i) &= \sum_{k=1}^n \left( \frac{h(y_{ki})-\mu_k}{\sigma^2} +\frac{Y_{ki}}{\sqrt{1+Y_{ki}^2}} \right) \cdot\frac{1}{\sqrt{1+Y_{ki}^2}} \nonumber\\ &= \sum_{k=1}^n \left(\frac{r_{ki}}{\sigma^2}+A_{ki}Y_{ki}\right)A_{ki} (\#eq:ddanll) \end{align}

and with respect to bib_i

∂∂bi(−LLi)=−nf′(bi)f(bi)+∑k=1n(h(yki)−μkσ2+Yki1+Yki2)⋅yki1+Yki2⋅f′(bi)=−nf′(bi)f(bi)+f′(bi)∑k=1n(rkiσ2+AkiYki)Akiyki(#eq:ddbnll)\begin{align} \frac{\partial}{\partial b_i}(-LL_i) &= -n\frac{f'(b_i)}{f(b_i)} +\sum_{k=1}^n \left( \frac{h(y_{ki})-\mu_k}{\sigma^2} +\frac{Y_{ki}}{\sqrt{1+Y_{ki}^2}}\right) \cdot\frac{y_{ki}}{\sqrt{1+Y_{ki}^2}}\cdot f'(b_i) \nonumber\\ &= -n\frac{f'(b_i)}{f(b_i)} +f'(b_i)\sum_{k=1}^n \left(\frac{r_{ki}}{\sigma^2}+A_{ki}Y_{ki}\right) A_{ki}y_{ki} (\#eq:ddbnll) \end{align}

Here, I have introduced the following shorthand notation for the “intermediate results” terms

rki=h(yki)−μkAki=11+Yki2.\begin{align} r_{ki}&= h(y_{ki})-\mu_k\\ A_{ki}&=\frac{1}{\sqrt{1+Y_{ki}^2}}. \end{align}

Variables for these intermediate values are also used in the C code to organise the computations of the gradient.

Profile Likelihood

If μ1,…,μn\mu_1,\ldots,\mu_n and σ2\sigma^2 are not already known, we can plug in their maximum likelihood estimates, obtained from optimizing LLLL for μ1,…,μn\mu_1,\ldots,\mu_n and σ2\sigma^2:

μ̂k=1d∑j=1dh(ykj)(#eq:muhat)σ̂2=1nd∑k=1n∑j=1d(h(ykj)−μ̂k)2(#eq:sigmahat)\begin{align} \hat{\mu}_k &= \frac{1}{d}\sum_{j=1}^d h(y_{kj}) (\#eq:muhat)\\ \hat{\sigma}^2 &= \frac{1}{nd}\sum_{k=1}^n\sum_{j=1}^d (h(y_{kj})-\hat{\mu}_k)^2 (\#eq:sigmahat) \end{align}

into the negative log-likelihood. The result is called the negative profile log-likelihood

−PLL=nd2log⁡(2πσ̂2)+nd2−n∑j=1dlog⁡f(bj)+12∑k=1n∑j=1dlog⁡1+Ykj2.(#eq:npll)\begin{equation} -PLL= \frac{nd}{2}\log\left(2\pi\hat{\sigma}^2\right) +\frac{nd}{2} -n\sum_{j=1}^d\log f(b_j) +\frac{1}{2}\sum_{k=1}^n\sum_{j=1}^d \log\sqrt{1+Y_{kj}^2}. (\#eq:npll) \end{equation}

Note that this no longer decomposes into a sum of terms for each jj that are independent of each other – the terms for different jj are coupled through Equations @ref(eq:muhat) and @ref(eq:sigmahat). We need the following derivatives.

∂σ̂2∂ai=2nd∑k=1nrki∂h(yki)∂ai=2nd∑k=1nrkiAki∂σ̂2∂bi=2nd⋅f′(bi)∑k=1nrkiAkiyki\begin{align} \frac{\partial \hat{\sigma}^2}{\partial a_i} &= \frac{2}{nd}\sum_{k=1}^n r_{ki}\frac{\partial h(y_{ki})}{\partial a_i}\nonumber\\ &= \frac{2}{nd} \sum_{k=1}^n r_{ki}A_{ki}\\ \frac{\partial \hat{\sigma}^2}{\partial b_i} &= \frac{2}{nd}\cdot f'(b_i) \sum_{k=1}^n r_{ki}A_{ki}y_{ki} \end{align}

So, finally

∂∂ai(−PLL)=nd2σ̂2⋅∂σ̂2∂ai+∑k=1nAki2Yki=∑k=1n(rkiσ̂2+AkiYki)Aki(#eq:ddanpll)∂∂bi(−PLL)=−nf′(bi)f(bi)+f′(bi)∑k=1n(rkiσ̂2+AkiYki)Akiyki(#eq:ddbnpll)\begin{align} \frac{\partial}{\partial a_i}(-PLL) &= \frac{nd}{2\hat{\sigma}^2}\cdot \frac{\partial \hat{\sigma}^2}{\partial a_i} +\sum_{k=1}^n A_{ki}^2Y_{ki}\nonumber\\ &=\sum_{k=1}^n \left(\frac{r_{ki}}{\hat{\sigma}^2}+A_{ki}Y_{ki}\right)A_{ki} (\#eq:ddanpll)\\ \frac{\partial}{\partial b_i}(-PLL) &= -n\frac{f'(b_i)}{f(b_i)} + f'(b_i) \sum_{k=1}^n \left(\frac{r_{ki}}{\hat{\sigma}^2}+A_{ki}Y_{ki}\right)A_{ki}y_{ki} (\#eq:ddbnpll) \end{align}

Summary

Likelihoods, from Equations @ref(eq:nll) and @ref(eq:npll):

−LLi=n2log⁡(2πσ2)⏟scale+∑k=1n(h(yki)−μk)22σ2⏟residuals−nlog⁡f(bi)+12∑k=1nlog⁡(1+Yki2)⏟jacobian−PLL=nd2log⁡(2πσ̂2)⏟scale+nd2⏟residuals+∑i=1d(−nlogf(bi)+12∑k=1nlog(1+Yki2))⏟jacobian\begin{align} -LL_i&= \underbrace{% \frac{n}{2}\log\left(2\pi\sigma^2\right) }_{\mbox{scale}} + \underbrace{% \sum_{k=1}^n \frac{(h(y_{ki})-\mu_k)^2}{2\sigma^2} }_{\mbox{residuals}} \underbrace{% -n\log f(b_i) + \frac{1}{2}\sum_{k=1}^n \log(1+Y_{ki}^2) }_{\mbox{jacobian}}\\ -PLL&= \underbrace{% \frac{nd}{2}\log\left(2\pi\hat{\sigma}^2\right) }_{\mbox{scale}}+ \underbrace{% \frac{nd}{2} }_{\mbox{residuals}} + \underbrace{% \sum_{i=1}^d\left( -n\log f(b_i) + \frac{1}{2}\sum_{k=1}^n \log(1+Y_{ki}^2)\right) }_{\mbox{jacobian}} \end{align}

The computations in the C code are organised into steps for computing the terms “scale”, “residuals” and “jacobian”.

Partial derivatives with respect to aia_i, from Equations @ref(eq:ddanll) and @ref(eq:ddanpll):

∂∂ai(−LLi)=∑k=1n(rkiσ2+AkiYki)Aki∂∂ai(−PLL)=∑k=1n(rkiσ̂2+AkiYki)Aki\begin{align} \frac{\partial}{\partial a_i}(-LL_i) &= \sum_{k=1}^n \left(\frac{r_{ki}}{\sigma^2}+A_{ki}Y_{ki}\right)A_{ki}\\ % \frac{\partial}{\partial a_i}(-PLL) &= \sum_{k=1}^n \left(\frac{r_{ki}}{\hat{\sigma}^2}+A_{ki}Y_{ki}\right)A_{ki} \end{align}

Partial derivatives with respect to bib_i, from Equations @ref(eq:ddbnll) and @ref(eq:ddbnpll):

∂∂bi(−LLi)=−nf′(bi)f(bi)+f′(bi)∑k=1n(rkiσ2+AkiYki)Akiyki∂∂bi(−PLL)=−nf′(bi)f(bi)+f′(bi)∑k=1n(rkiσ̂2+AkiYki)Akiyki.\begin{align} \frac{\partial}{\partial b_i}(-LL_i) &= -n\frac{f'(b_i)}{f(b_i)} +f'(b_i)\sum_{k=1}^n \left(\frac{r_{ki}}{\sigma^2}+A_{ki}Y_{ki}\right)A_{ki}y_{ki}\\ % \frac{\partial}{\partial b_i}(-PLL) &= -n\frac{f'(b_i)}{f(b_i)} +f'(b_i)\sum_{k=1}^n \left(\frac{r_{ki}}{\hat{\sigma}^2}+A_{ki}Y_{ki}\right)A_{ki}y_{ki}. \end{align}

Note that the terms have many similarities – this is used in the implementation in the C code.

References

Huber, Wolfgang, Anja von Heydebreck, Holger Sültmann, Annemarie Poustka, and Martin Vingron. 2002. “Variance Stabilization Applied to Microarray Data Calibration and to the Quantification of Differential Expression.” Bioinformatics 18 Suppl 1: 96–104. http://bioinformatics.oxfordjournals.org/content/18/suppl_1/S96.abstract.
Huber, Wolfgang, Anja von Heydebreck, Holger Sültmann, Annemarie Poustka, and Martin Vingron. 2003. “Parameter Estimation for the Calibration and Variance Stabilization of Microarray Data.” Statistical Applications in Genetics and Molecular Biology 2 (1): Article 3. http://www.degruyter.com/view/j/sagmb.2003.2.1/sagmb.2003.2.1.1008/sagmb.2003.2.1.1008.xml.