%!TEX root = ../chapter2.tex
%******************************
%	 Results
%*****************************

\section{Extending the  BASiCS model}

Unlike bulk RNA sequencing, scRNA-Seq provides information about cell-to-cell expression heterogeneity within a population of cells.
Past works have used a variety of measures to quantify this heterogeneity. Among others, this includes the \gls{CV2} \citep{Brennecke2013} and entropy measures \citep{Richard2016}.
The BASiCS model \citep{Vallejos2015BASiCS, Vallejos2016}, which was introduced in \textbf{Section \ref{sec0:BASiCS}}, focuses on biological \textit{over-dispersion} as a proxy for transcriptional heterogeneity.
This is defined as the excess of variability that is observed with respect to what would be predicted by Poisson sampling noise, after accounting for technical variation.

\subsection{The BASiCS model}

Let $X_{ij}$ be a random variable representing the expression count of gene $i \in \{1, \ldots, q\}$ in cell $j \in \{ 1, \ldots ,n\}$.
To control for technical noise, we employ reads from synthetic RNA spike-ins (see \citep{Jiang2011}).
We assume the first $q_0$ genes to be biological followed by the $q-q_0$ spike-in genes.
BASiCS assumes a hierarchical Poisson formulation:

\begin{equation} \label{eq::PoissonBASiCS}
 X_{ij}|\mu_i,\phi_j,\nu_j,\rho_{ij} \ind
 \left\lbrace
  \begin{aligned}
    &\text{Poisson}(\phi_j\nu_j\mu_i\rho_{ij}), && i=1,...,q_0,j=1,...n;  \\
    &\text{Poisson}(\nu_j\mu_i), && i=q_0+1,...,q,j=1,...,n,
  \end{aligned}
\right.
\end{equation}

where, to account for technical ($\nu_j$) and biological ($\rho_{ij}$) factors that affect the variance of the transcript counts, we incorporate two random effects:

\begin{equation} \label{eq::RandomEffectsBASiCS}
\nu_j|s_j,\theta \ind \text{Gamma}\left(\frac{1}{\theta},\frac{1}{s_j\theta}\right), \hspace{0.5cm} \rho_{ij}|\delta_i  \iid \text{Gamma}\left(\frac{1}{\delta_i},\frac{1}{\delta_i}\right)\\
\end{equation}

Here, $\phi_j$ represents a cell-specific normalisation parameter to correct for differences in mRNA content between cells.
Gene-specific parameters $\mu_i$ represent average expression of a gene across cells.
The strength of the technical noise $\nu_j$ is quantified by a global parameter $\theta$ (shared across all genes and cells).
$s_j$ models cell-specific differences in efficiency to capture RNA spike-in transcripts affecting all biological and technical genes.
The strength of heterogeneous gene expression across cells $\rho_{ij}$ is controlled by gene-specific over-dispersion parameters $\delta_i$ which we used as a proxy for biological expression variability in the previous chapter.
As shown in the previous chapter, over-dispersion as a measure of variability can be used to identify genes whose transcriptional heterogeneity differs between groups of cells (defined by experimental conditions or cell types).
However, the strong relationship that is typically observed between variability and mean estimates (see \textbf{Section \ref{sec0:BASiCS}} and \citep{Brennecke2013}) can hinder the interpretation of these results.

\newpage

\subsection{Approaches to correct the mean-variability confounding effect}

A simple solution to avoid the confounding effect of mean expression was used in \textbf{Chapter 2} by restricting the assessment of differential variability to genes with equal mean expression across populations \textbf{(Fig.~\ref{fig2:Schematic_model}A and Section \ref{sec1:BASiCS})}.
However, this is sub-optimal, particularly in the case of naive and activated CD4\plus{} T cells where large sets of genes are differentially regulated upon immune activation.
With the current model, immune response genes (e.g.~cytokines, nuclear receptors, transcription factors) are excluded from differential variability testing.
An alternative approach is to directly adjust variability measures to remove this confounding.
For example, Kolodziejczyk \emph{et al.}, 2015 computed the empirical distance between the \gls{CV2} to a rolling median along expression levels --- referred to as the DM method \citep{Newman2006, Kolodziejczyk2015cell}.  \\

In line with this idea, our method extends the statistical model implemented in BASiCS \citep{Vallejos2015BASiCS, Vallejos2016} to meaningfully assess changes in transcriptional heterogeneity when genes exhibit shifts in mean expression \textbf{(Fig.~\ref{fig2:Schematic_model}B)}.
For this, we infer a regression trend between over-dispersion ($\delta_i$) and gene-specific mean parameters ($\mu_i$), by introducing a joint informative prior to capture the dependence between these parameters.
A latent gene-specific \textit{residual over-dispersion} parameter $\epsilon_i$ describes departures from this trend \textbf{(Fig~\ref{fig2:Schematic_model}C)}.
The value of $\epsilon_i$ indicates whether a gene exhibits more (positive) or less (negative) variation than expected relative to genes with similar expression levels.
Importantly, this measure is not confounded by mean expression \textbf{(Fig.~\ref{fig2:Schematic_model}D)}. \\

The hierarchical Bayesian approach infers full posterior distributions for the gene-specific latent residual over-dispersion parameters $\epsilon_i$.
As a result, we can directly use a probabilistic approach to identify genes with large absolute differences in residual over-dispersion between two groups of cells.
When the posterior samples of $\epsilon_i$ in condition A are very different from posterior samples of $\epsilon_i$ in condition B, the majority of values for $|\epsilon_i^A - \epsilon_i^B|$ are larger than a given threshold $\psi_0>0$.
In this case, the gene is found to be differentially variable between the two conditions  \textbf{(Fig.~\ref{fig2:Schematic_model}E and Section \ref{sec0:decision})}.
In contrast, mean-corrected point estimates for residual noise parameters (such as those obtained by the DM method) cannot be directly used to perform gene-specific statistical testing between two conditions as no measure of the uncertainty in the estimate is available.\\

\newpage

\begin{figure}[!h]
\centering
\includegraphics[width=0.9\textwidth]{Fig_1.png}
\caption[Addressing the mean confounding effect in scRNA-Seq data]{\textbf{Addressing the mean confounding effect in scRNA-Seq data (full legend on next page).}\\}
\label{fig2:Schematic_model}
\end{figure}

\newpage

\captionsetup[figure]{list=no}
\addtocounter{figure}{-1}
\captionof{figure}{\textbf{Addressing the mean confounding effect in scRNA-Seq data (continued).}\\
\textbf{(A and B)} Illustration of changes in expression variability for a single gene between two cell populations without (left) and with (right) changes in mean expression,
\textbf{(C and D)} The extended BASiCS model infers a regression trend between gene-specific estimates of over-dispersion parameters $\delta_i$ and mean expression $\mu_i$.
Residual over-dispersion parameters $\epsilon_i$ are defined by departures from the regression trend (red arrow).
The colour code within the scatterplots is used to represent areas with high (yellow/red) and low (blue) concentration of genes.
For illustration purposes, the data introduced by Antolovi\'{c} \emph{et al.}, 2017 \cite{Antolovic2017} has been used, \textbf{(C)} Illustration of the typical confounding effect that is observed between gene-specific estimates of over-dispersion parameters $\delta_i$ and mean expression parameters $\mu_i$.
Genes that are not detected in at least 2 cells are indicated by purple points,
\textbf{(D)} Gene-specific estimates of residual over-dispersion parameters $\epsilon_i$ are independent of mean expression parameters $\mu_i$,
\textbf{(E)} Illustration of how posterior uncertainty is used to highlight changes in residual over-dispersion.
Two example genes with (upper panels) and without (lower panels) changes in residual over-dispersion are shown.
Left panels illustrate the posterior density associated to residual over-dispersion parameters $\epsilon_i$ for a gene in two groups of cells (group A: light blue, group B: dark blue).
The coloured area in the right panels represents the posterior probability of observing an absolute difference $|\epsilon^A_{i} - \epsilon^B_{i}|$ that is larger than the minimum tolerance threshold $\psi_0$.\\}
\captionsetup[figure]{list=yes}

\subsection{Modelling the confounding between mean and over-dispersion} \label{sec2:extended_BASiCS}

Here, we extend BASiCS to account for the confounding effect described above. In a Bayesian framework, the prior information captures the relationship between parameters.
Therefore, we introduce the following joint prior distribution for $(\mu_i, \delta_i)'$:

\begin{equation} \label{eq::jointprior} \mu_i \sim \text{log-Normal}\left(0, s^2_{\mu}\right), \hspace{0.8cm}
\delta_i | \mu_i \sim \text{log-}\text{T}_{\eta}\left( \text{f}(\mu_i), \sigma^2 \right).
\end{equation}

The latter is equivalent to the following non-linear regression model:

\begin{equation} \label{eq::regression}
\log(\delta_i) =\text{f}(\mu_i)+\epsilon_i, \hspace{0.5cm} \epsilon_i \sim{}\text{T}_{\eta}(0,\sigma^2),
\end{equation} where $\text{f}(\mu_i)$ represents the over-dispersion (on the log-scale) that is predicted by the global trend (across all genes) for a given mean expression $\mu_i$.
Therefore, $\epsilon_i$ can be interpreted as a latent gene-specific \textit{residual over-dispersion} parameter, capturing departures from the overall trend. \\

A similar approach was introduced by DESeq2 \citep{Love2014} in the context of bulk RNA sequencing.
Whereas DESeq2 assumes normally distributed errors when estimating this trend, here we use Student-T distributed errors (with $\eta$ degrees of freedom) as it leads to inference that is more robust to the presence of outlier genes \citep{Fernandez1999}.

\newpage

Moreover, the parametric trend assumed by DESeq2 is replaced by a more flexible semi-parametric approach. This is defined by

\begin{equation} \label{eq::trend}
\text{f}(\mu_i) = \alpha_0 + \log(\mu_i)\alpha_1 + \sum_{l=1}^L \text{g}_l(\log(\mu_i))\beta_l,
\end{equation}

which is a linear combination of an intercept, a linear term $\log(\mu_i)$ and a set of $L$ \gls{GRBF} kernels $\text{g}_1(\cdot), \ldots, \text{g}_L(\cdot)$. As in Kapourani \emph{et al.}, 2016 \cite{Kapourani2016}, these are defined as:

\begin{equation} \label{eq::GRBF}
\text{g}_l(\log(\mu_i)) = \exp\left\lbrace-\frac{1}{2}\left(\dfrac{\log(\mu_i)-m_l}{h_l}\right)^2\right\rbrace, \hspace{0.3cm} l = 1, \ldots, L,
\end{equation}

where $m_l$ and $h_l$ represent location and scale hyper-parameters for GRBF kernels and $\alpha_0, \alpha_1, \beta_1, \ldots, \beta_L$ are regression coefficients. \\

In equation \eqref{eq::trend}, the linear term captures the (typically negative) global correlation between $\delta_i$ and $\mu_i$.
Its addition also stabilises inference of GRBFs around mean expression values where only a few of genes are observed.
In equation \eqref{eq::GRBF}, the location and scale hyper-parameters $(m_l, h_l)$ are assumed to be fixed \emph{a priori} (see \textbf{Section \ref{sec2:hyper-parameters}}).

\newpage

\subsection{Implementation}

Next, we will give a detailed explanation on how the model was built and how posterior sampling was performed.

\subsubsection{Prior specification}

For implementation purposes, the log-Student-T distribution in equation \eqref{eq::jointprior} is represented via a shape mixture of a log-Normal density with a Gamma density as in Vallejos \emph{et al.}, 2015 \cite{Vallejos2015}.
This introduces an auxiliary set of parameters $\lambda_i$ such that the full prior specifications of the extended BASiCS model are:

\begin{align*}
\mu_i &\ind \mbox{log-Normal}\left(0, s^2_{\mu}\right) \\
\delta_i| \mu_i,\beta,\sigma^2, \lambda_i, \eta &\ind \text{log-N}\left( \text{f}(\mu_i),\frac{\sigma^2}{\lambda_i} \right)\\
\lambda_i|\eta &\ind \text{Gamma}\left(\frac{\eta}{2},\frac{\eta}{2}\right)\\
\beta|\sigma^2 & \sim \textnormal{Normal}(m_\beta,\sigma^2V_\beta),\\
\sigma^2 & \sim  \textnormal{Inv-Gamma}(a_{\sigma^2},b_{\sigma^2}),\\
s_j & \iid  \textnormal{Gamma}(a_s,b_s) \\
(\phi_1, \ldots, \phi_n)' & \sim  n \times \textnormal{Dirichlet}(a_\phi),\\
\theta & \sim  \textnormal{Gamma}(a_\theta,b_\theta)
\end{align*}

Here, $s^2_{\mu}, m_\beta, V_\beta, a_{\sigma^2}, b_{\sigma^2}, a_s, b_s, a_\phi, a_\theta, b_\theta$ are hyper-parameters that are fixed \emph{a priori}.
Their initial values can be found in \textbf{Appendix \ref{appB.1.hyper}}.
In principle, the degrees of freedom parameter $\eta$ could also be estimated within a Bayesian framework.
However, we observed that fixing this parameter \emph{a priori} led to more stable results.
A default choice for this parameter is described in \textbf{Section \ref{sec2:hyper-parameters}}.

\newpage

\subsubsection{Estimation of regression parameters}

To simplify inference for the regression coefficients $\beta = (\alpha_0, \alpha_1, \beta_1, \ldots, \beta_L)'$ equation \eqref{eq::trend} can be rewritten as a linear regression model using

\begin{equation} \label{eq::trend2}
\text{f}(\mu_i) = X \beta
\end{equation}

Here, $X$ is a $q_0 \times (L+2)$ model matrix given by

\begin{equation} \label{eq::X} X = \left( \begin{array}{ccccc}
1 & \log(\mu_1) & g_1(\log(\mu_1)) & \cdots & g_L(\log(\mu_1)) \\
1 & \log(\mu_2) & g_1(\log(\mu_2)) & \cdots & g_L(\log(\mu_2)) \\
\vdots & \vdots & \vdots & \ddots & \vdots  \\
1 & \log(\mu_{q_0}) & g_1(\log(\mu_{q_0})) & \cdots & g_L(\log(\mu_{q_0}))
\end{array}\right)
\end{equation}

Each column contains either the intercept, the linear component or values of one of the $L$ GRBF.
This matrix is updated every 50 iterations during posterior sampling.

\subsubsection{Posterior inference}

Posterior inference for the model described above is implemented by extending the Adaptive Metropolis within Gibbs sampler \citep{Roberts2009} that was adopted by Vallejos \emph{et al.}, 2016 \cite{Vallejos2016}.
To implement the sampler, the full conditionals for each model parameter need to be derived. \\

As in Vallejos \emph{et al.}, 2015 \cite{Vallejos2015BASiCS}, the random effect $\rho_{ij}$ in \ref{eq::PoissonBASiCS} is integrated out, leading to the following count distributions:

\begin{equation} \label{eq::NegBinBASiCS}
 X_{ij}|\mu_i,\delta_i,\phi_j,\nu_j \ind
 \left\lbrace
  \begin{aligned}
    &\text{Neg-Bin}\left(\frac{1}{\delta_i},\frac{\phi_j\nu_j\mu_i}{\phi_j\nu_j\mu_i+\frac{1}{\delta_i}}\right), && i=1,...,q_0,j=1,...n;  \\
    &\text{Poisson}(\nu_j\mu_i), && i=q_0+1,...,q,j=1,...,n
  \end{aligned}
\right.
\end{equation}

Based on equation \eqref{eq::NegBinBASiCS}, the likelihood function therefore takes the form

\begin{align} \label{eq::loglik}
\Lagr = & \left[\prod_{i=1}^{q_0}\prod_{j=1}^n\frac{\Gamma(x_{ij}+\frac{1}{\delta_i})}{\Gamma(\frac{1}{\delta_i})x_{ij}!}\left(\frac{\frac{1}{\delta_i}}{\phi_j\nu_j\mu_i+\frac{1}{\delta_i}}\right)^\frac{1}{\delta_i}\left(\frac{\phi_j\nu_j\mu_i}{\phi_j\nu_j\mu_i+\frac{1}{\delta_i}}\right)^{x_{ij}}\right] \nonumber\\
&\times\left[\prod_{i=q_0+1}^{q}\prod_{j=1}^n\frac{(\nu_j\mu_i)^{x_{ij}}}{x_{ij}!}\exp\lbrace-\nu_j\mu_i\rbrace\right]\times{}\left[\prod_{j=1}^n\frac{(s_j\theta)^{-\frac{1}{\theta}}}{\Gamma(\frac{1}{\theta})}\nu_j^{\frac{1}{\theta}-1}\exp\left\lbrace-\frac{\nu_j}{s_j\theta}\right\rbrace\right]
\end{align}

\newpage

The full conditionals can now be derived by calculating the parameter-dependent part of the posterior distribution which is a product of the likelihood times the prior specifications $\pi^\ast(\cdot)\propto{}\Lagr\times\pi(\cdot)$.
Full conditionals for the model are as follows: \\

\begingroup
\addtolength{\jot}{0.8em}
\begin{align*} \label{eq::FullCond}
&\pi^*(\mu_i|\cdot) && \propto \frac{\mu_i^{\sum_{j=1}^n{}x_{ij}}}{\prod_{j=1}^n{}(\phi_j\nu_j\mu_i+\frac{1}{\delta_i})^{\frac{1}{\delta_i}+x_{ij}}}\times{}\exp\left(-\frac{(\log(\mu_i))^2}{2a_\mu^2}-\frac{\lambda_i(\log(\delta_i)-f(\mu_i))^2}{2\sigma^2}\right)\frac{1}{\mu_i} \\
&\pi^*(\delta_i|\cdot) && \propto \left[\prod_{j=1}^n\frac{\Gamma(x_{ij}+\frac{1}{\delta_i})}{\Gamma(\frac{1}{\delta_i})}\frac{(\frac{1}{\delta_i})^{\frac{1}{\delta_i}}}{(\phi_j\nu_j\mu_i+\frac{1}{\delta_i})^{\frac{1}{\delta_i}+x_{ij}}}\right]\times{}\exp\left\lbrace-\frac{\lambda_i(\log(\delta_i)-f(\mu_i))^2}{2\sigma^2}\right\rbrace\frac{1}{\delta_i}\\
&\pi^*(\beta|\cdot)&&\propto{}\text{Normal}(m^*_\beta,\sigma^2V^*_\beta)\\
&\pi^*(\lambda_i|\cdot)&&\propto{}\text{Gamma}(a^*_\lambda,b^*_\lambda)\\
&\pi^*(\sigma^2|\cdot)&&\propto{}\text{Inv-Gamma}(a^*_{\sigma^2},b^*_{\sigma^2})\\
&\pi^*(s_j|\cdot)&&\propto{}s_j{}^{a_s-\frac{1}{\theta}-1}\exp\lbrace-\frac{\nu_j}{s_j\theta}-b_ss_j\rbrace\\
&\pi^*(\phi_j|\cdot)&&\propto{}\frac{\prod_{i=1}^{q_0}\phi_j{}^{\sum_{j=1}^nx_{ij}}}{\prod_{i=1}^{q_0}\prod_{j=1}^{n}(\phi_j\nu_j\mu_i+\frac{1}{\delta_i})^{\frac{1}{\delta_i}+x_{ij}}}\times{}\pi(\phi_j)\\
&\pi^*(\nu_j|\cdot)&&\propto{}\left[\prod_{i=1}^{q_0}\left(\frac{1}{\phi_j\nu_j\mu_i+\frac{1}{\delta_i}}\right)^\frac{1}{\delta_i}\left(\frac{\nu_j}{\phi_j\nu_j\mu_i+\frac{1}{\delta_i}}\right)^{x_{ij}}\right]\left[\prod_{i=q_0+1}^{q}\nu_j{}^{x_{ij}}\exp\lbrace-\nu_j\mu_i\rbrace\right]\nu_j^{\frac{1}{\theta}-1}\exp\lbrace-\frac{\nu_j}{s_j\theta}\rbrace\\
&\pi^*(\theta|\cdot)&&\propto{}\frac{\left(\prod_{j=1}^{n}\frac{s_j}{\nu_j}\right)^{-\frac{1}{\theta}}}{\Gamma{}^n(\frac{1}{\theta})}\theta^{a_\theta-\frac{n}{\theta}-1}\exp\lbrace-\frac{1}{\theta}\sum_{j=1}^n\frac{\nu_j}{s_j}-b_\theta\theta\rbrace
\end{align*}
\endgroup

Here, posteriors for $\beta, \lambda_i, \sigma^2$ take on closed form distributions.
The posterior for $s_j$ represents a Generalised Inverse Gaussian distribution.
To sample all other posterior distributions adaptive Metropolis sampling was implemented as described in \textbf{Section \ref{sec0:posterior_inference}}.
The derivation of the full conditionals can be found in \textbf{Appendix  \ref{appB.1.derivation}}.
In practice, the MCMC sampler is run for 40,000 iterations with a 20,000 iteration burn in period.
The chain was thinned by storing parameter samples every 20 iterations.

\newpage

\subsection{Probabilistic rule associated to the differential test} \label{sec:differentialtest}

The residual over-dispersion parameter is calculated as $\epsilon_i=\log(\delta_i)-\text{f}(\mu_i)$.
We can now implement a probabilistic approach to identify changes in residual over-disperison between groups of cells.
Let $\delta_i^A$ and $\delta_i^B$ be the over-dispersion parameters associated to gene $i$ in groups $A$ and $B$.
Following equation \eqref{eq::regression}, the log$_2$ fold change in over-dispersion between these groups can be decomposed as:

\begin{equation} \label{eq::dispersion_lfc}
\log_2 \left( \frac{\delta_i^A}{\delta_i^B}\right) = \log_2(e) \times \left[\underbrace{\text{f}^A(\mu_i^A) - \text{f}^B(\mu_i^B) }_{\text{Mean contribution}} + \underbrace{\epsilon_i^A - \epsilon_i^B}_{\text{Residual change}} \right]
\end{equation}

where the first term captures the over-dispersion change that can be attributed to differences between $\mu_i^A$ and $\mu_i^B$.
The second term in equation \eqref{eq::dispersion_lfc} represents the change in residual over-dispersion that is not confounded by mean expression.
Based on this observation, statistically significant differences in residual over-dispersion will be identified for those genes where the tail posterior probability of observing a large difference between $\epsilon_i^A$ and $\epsilon_i^B$ exceeds a certain threshold $\psi_0 > 0$:

\begin{equation} \label{eq::decision_rule}
\pi_i(\psi_0)=\text{P}(\mid\epsilon_i^{A}-\epsilon_i^{B}\mid >\psi_0 \mid \text{Data} ) >\alpha_R
\end{equation}

As a default choice for testing changes in over-dispersion we chose a 50\% increase.
This translates into $\psi_0 = \log_2(1.5) / \log_2(e) \approx 0.41$ as default threshold for testing changes in residual over-dispersion.
In the limiting case when $\psi_0 = 0$, the probability in equation \eqref{eq::decision_rule} is equal to 1 regardless of the information contained in the data.
Therefore, as in Bochkina \emph{et al.}, 2007 \cite{Bochkina2007}, our decision rule is based on the maximum of the posterior probabilities associated to the one-sided hypotheses $\epsilon^A - \epsilon^B_i > 0$ and  $\epsilon^A - \epsilon^B_i < 0$:

\begin{equation} \label{eq::decision_rule2} 2 \times \max\{\pi_i^+, 1-\pi_i^+\} - 1  >\alpha_R, \hspace{0.2cm} \text{with} \hspace{0.2cm} \pi_i^+ = \text{P}(\epsilon_i^{A}-\epsilon_i^{B} > 0 \mid \text{Data})
\end{equation}

In both cases, the posterior probability threshold $\alpha_R$ is chosen to control the expected false discovery rate (EFDR) \citep{Newton2004}. The default value for EFDR is set to 10\%. The EFDR is defined as:

\begin{equation}
\text{EFDR}_{\alpha_R}(\psi_0)=\frac{\sum_{i=1}^{q_0}(1-\pi_i(\psi_0))\text{I}(\pi_i(\psi_0)>\alpha_R)}{\sum_{i=1}^{q_0}\text{I}(\pi_i(\psi_0)>\alpha_R)}
\end{equation}

where I(A)=1 if the event A is true.
As a default and to support interpretability of the results, we exclude genes that are not expressed in at least 2 cells per condition from differential variability testing.

\newpage

\begin{figure}[!h]
\centering
\includegraphics[width=\textwidth]{Fig_3.png}
\caption[EFDR, FPR and TPR estimation using simulated data]{\textbf{EFDR, FPR and TPR estimation using simulated data (Full legend on next page).}\\
Data was simulated using the BASiCS model with model parameters set by empirical estimates based on 98 microglia cells \citep{Zeisel2015} \textbf{(Table \ref{tab2:datasets})}.
Different samples sizes (40 - 200 cells) were simulated in replicates of 5.
Differential testing was performed between 2 simulated datasets of equal size to calculate the false positive rate (FPR, number of detections divided by number of genes tested) and the true positive rate (TPR, number of true positive divided by number of all positives).
Moreover, we report the expected false discovery rate (EFDR, \citep{Newton2004}).
For each test, the EFDR was controlled to 10\% and the default minimum tolerance thresholds were used ($\tau_0 = \log_2(1.5)$, $\omega_0 = \log_2(1.5)$ and $\psi_0 = 0.41$),
\textbf{(A)-(C)} Synthetic datasets generated using the null model (without changes in variability). FPR and EFDR for (A) differential mean expression, (B) differential over-dispersion and (C) differential residual over-dispersion testing using datasets with increasing samples sizes,
\textbf{(D)-(E)} Synthetic datasets generated using the alternative model where 1000 genes were randomly selected and their associated over-dispersion parameters were increased or decreased by a $\log_2$ fold change of 5.
TPR and EFDR for (D) differential over-dispersion testing and (E) differential residual over-dispersion testing using simulated datasets with increasing samples sizes.}\label{fig2:EFDR}
\end{figure}

\newpage

To evaluate the performance of our test we generated synthetic data under a null model (without changes in variability) and an alternative model (with changes in variability).
All datasets were generated following the BASiCS model, with parameter values set by empirical posterior estimates based on 98 microglia cells \citep{Zeisel2015} (see \textbf{Table \ref{tab2:datasets}} in \textbf{Section \ref{sec2:datasets}}).
To simulate data under an alternative model, 1000 genes were randomly selected and their associated $\delta_i$'s were increased or decreased by a $\log_2$ fold change of 5.
Increasing numbers of cells were simulated to estimate the effect of sample size on differential testing.
Differential testing was performed either between data simulated on the same set of parameters (null model) or between data simulated from the original parameters and the altered parameters (alternative model).
We report the EFDR \citep{Newton2004} as well as the \gls{FPR} for simulations under the null model \textbf{(Fig.~\ref{fig2:EFDR}A-C)} and the \gls{TPR} for simulations under the alternative model \textbf{(Fig.~\ref{fig2:EFDR}D and E)}. \\

As specified, the EFDR is controlled at 10\%.
Furthermore, the FPR for differential mean expression and differential over-dispersion is consistently smaller than 10\% and is only slightly higher for differential residual over-dispersion testing.
Since the data was simulated under the non-regression BASiCS model, the simulated expression variability cannot be controlled in terms of residual over-dispersion parameters $\epsilon_i$ leading to subtle differences between simulated cell populations.
The TPR for differential over-dispersion and differential residual over-dispersion testing increases with increasing sample size and plateaus at 100\% \textbf{(Fig.~\ref{fig2:EFDR})}.

\subsection{Choice of hyper-parameters} \label{sec2:hyper-parameters}

As discussed above, the degrees of freedom $\eta$, the number of GRBFs  $L$ as well as their hyper-parameters ($m_l$, $h_l$) are set \emph{a priori}.
Here, we explain the default values implemented in the extended BASiCS model.
These were chosen to achieve a compromise between flexibility of the trend fit and the strength of shrinkage towards the estimated trend.
Further discussion on the shrinkage can be found in \textbf{Section \ref{sec2:stabilization}}. \\

Firstly, we observed that large values of $L$ can lead to over-fitting but that small values of $L$ can limit the flexibility to capture non-linear relations between $\log(\delta_i)$ and $\log(\mu_i)$ \textbf{(Fig.~\ref{fig2:choice_hyper})}.
Thus, as a parsimonious choice, we selected $L = 10$. Moreover, as in Kapourani \emph{et al.}, 2016 \cite{Kapourani2016}, values for $m_l$ were chosen to be equally spaced across the range of $\log(\mu_i)$:.

\begin{equation} m_l = a + (l-1)\frac{b - a }{L-1}, \hspace{0.2cm}  l=1,\ldots, L, \end{equation}

where $a=\min_{i\in\{1,\ldots,q_0\}}\{\log(\mu_i)\}$ and $b=\max_{i\in\{1,\ldots,q_0\}}\{\log(\mu_i)\}$.
As $\mu_i$ values are unknown \emph{a priori} and change throughout the sampling procedure, $a$ and $b$ are updated every 50 MCMC iterations during the burn-in phase.
Additionally, the scale hyper-parameters $h_l$ control the width of the GRBFs and, consequently, the locality of the regression.
As a default, we set these as $h_l = c \times \Delta m$, where $c$ is a fixed proportionality constant and $\Delta m$ is the distance between consecutive values of $m_l$.
In practice, we observed that the choice of a particular value of $c$ is not critical, as long as narrow kernels ($c<0.5$) are avoided \textbf{(Fig.~\ref{fig2:choice_hyper})}.
As a default, $c = 1.2$ was chosen.

\begin{figure}[!h]
\centering
\includegraphics[width=0.75\textwidth]{Fig_4.png}
\caption[Effect of regression hyper-parameters on trend fitting]{\textbf{Effect of regression hyper-parameters on trend fitting.}\\
Posterior estimates of over-dispersion parameters $\delta_i$ are plotted versus posterior estimates of mean expression parameters $\mu_i$ on the log-log scale.
The extended BASiCS model was used to estimate these parameters using naive CD4\plus{} T cells from the previous chapter.
Different hyper-parameter combinations were used to fit the model.
L: number of Gaussian Radial Basis Functions, c: constant multiplier of the scale parameter, $\eta$: degrees of freedom.
Purple points indicate genes which are expressed in fewer than 2 cells.}
\label{fig2:choice_hyper}
\end{figure}

\newpage

The degrees of freedom $\eta$ controls the tails of the distribution for the residual term in equation \eqref{eq::regression}.
This influences the shrinkage towards the global trend and the robustness against outlying observations \textbf{(Fig.~\ref{fig2:choice_hyper})}.
If $\eta \geq 30$, $\epsilon_i$ approximately follows a normal distribution for which posterior inference for $\beta$ is known to be sensitive to outliers.
Instead, small values of $\eta$ introduce heavy-tails for $\epsilon_i$, leading to more robust posterior inference.
In principle, $\eta$ could be estimated within a Bayesian framework.
However, this is problematic as the likelihood function associated to equation \eqref{eq::regression} can be unbounded \citep{Fernandez1999}. Here, we opt for a pragmatic approach where the value of $\eta$ is fixed \emph{a priori}.
To select a reasonable default value, we ran the regression BASiCS model for a grid of possible values of $\eta$, using the datasets described in \textbf{Table \ref{tab2:datasets}} in \textbf{Section \ref{sec2:datasets}} (with $L$, $m_l$ and $h_l$ fixed as described above).
In all cases, we calculated a Monte Carlo estimate for the log-likelihood associated to equation \eqref{eq::PoissonBASiCS} as a proxy for goodness-of-fit \textbf{(Fig.~\ref{fig2:DoF}A)}.
We observed that log-likelihood estimates were consistently the smallest for $\eta=1$ and that no substantial differences are observed across larger values of $\eta$.
The \textit{Dictyostelium} data show very similar log-likelihood estimates for all tested $\eta$.
When visualising posterior estimates for the variance $\sigma^2$ of the distribution for the residual term depending on the degrees of freedom chosen, we observe a constant increase plateauing when the distribution reaches the normal distribution at $\eta=30$ \textbf{(Fig.~\ref{fig2:DoF}B)}.
We chose $\eta=5$ to be the default parameter as a compromise between shrinkage and sensitivity to outlying data points.

\begin{figure}[!h]
\centering
\includegraphics[width=\textwidth]{Fig_5.png}
\caption[Comparison of model fits for varying degrees of freedom]{\textbf{Comparison of model fits for varying degrees of freedom.}\\
The regression BASiCS model was fit to datasets listed in \textbf{Table \ref{tab2:datasets}}.
These include CA1 pyramidal neurons (CA1, \citep{Zeisel2015}), pool-and-split RNA 2i medium (PS, \citep{Grun2014}), mouse embryonic stem cells 2i medium (mESC, \citep{Grun2014}), \textit{Dictyostelium} cells at day 0 of differentiation (Dict, \citep{Antolovic2017}) and naive CD4\plus{} T cells (CD4, previous chapter).
\textbf{(A)} The model was fit using varying degrees of freedom and the log-likelihood was calculated as stated in equation \eqref{eq::loglik}. The log-likelihood was scaled between the highest and lowest value for each dataset.
\textbf{(B)} Posterior estimates of the variance parameter $\sigma^2$ depending on the number of degrees of freedom.}
\label{fig2:DoF}
\end{figure}

%Based on these observations, default values implemented in the BASiCS software are set to $L=10, c=1.2, \eta=5$. Despite this, the model's implementation also allows flexible adjustment of $L$, $c$ and $\eta$ by the user.

\section{Pre-processing of scRNA-Seq data used in this chapter} \label{sec2:datasets}

We employed a range of different datasets to test the proposed methodology.
These datasets were selected to cover different experimental techniques (with and without UMIs) and to encompass a variety of cell types.
Moreover, key features of each dataset can be found in \textbf{Table \ref{tab2:datasets}}.

\begin{table}[ht	]
\centering
\caption[Datasets used for model testing and analysis]{\textbf{Datasets used for model testing and analysis.} \\
For each of the datasets analysed in this study: number of cells (2$^\text{nd}$ column), number of genes (biological + technical spike-ins, 3$^{rd}$ column), number of batches (4$^\text{th}$ column), type of data acquisition system (5$^\text{th}$ column), information on whether the data was generated using unique molecular identifiers (UMIs, 6$^\text{th}$ column) and the reference to the original study (7$^\text{th}$ column) are provided.}
\label{tab2:datasets}
\begin{tabular}{lllllll}
\toprule
\textbf{Dataset} & \textbf{\# cells} & \textbf{\# genes} & \textbf{\# batches} & \textbf{Protocol} & \textbf{UMIs} & \textbf{Ref.}                       \\
\midrule
Young naive  & 93       & 10,553    & 2          & Fluidigm C1       & No   & \citep{Martinez-jimenez2017} \\
CD4\plus{} T cells   &        &   &          &       & No   &  \\
\midrule

Young active    & 53       & 10,553    & 2          & Fluidigm C1       & No   & \citep{Martinez-jimenez2017} \\
CD4\plus{} T cells    &        &     &           &        &    &  \\
\midrule

Microglia cells                         & 98       & 10,687    & 1          & Fluidigm C1       & Yes  & \citep{Zeisel2015}           \\
\midrule

CA1 pyramidal                    & 948      & 10,687    & 1          & Fluidigm C1       & Yes  & \citep{Zeisel2015}           \\
neurons       &       &     &           &       &   &           \\
\midrule

Malaria infected     & 89       & 7899     & 2          & Fluidigm C1       & No   & \citep{Lonnberg2017}         \\
CD4\plus{} T cells day 2     &        &      &          &  &    &  \\
\midrule

Malaria infected  & 133      & 7899     & 2          & Fluidigm C1       & No   & \citep{Lonnberg2017}         \\
CD4\plus{} T cells day 4     &       &      &    &  &    &\\
\midrule

Malaria infected  & 64       & 7899     & 1          & Fluidigm C1       & No   & \citep{Lonnberg2017}         \\
CD4\plus{}  T cells day 7    &   & &  &  &  &   \\
\midrule

\textit{Dictyostelium}             & 131      & 10,738    & 3          & Fluidigm C1       & No   & \citep{Antolovic2017}        \\
cells day 0  &  &   &   &  & & \\
\midrule

Pool-split RNA                 & 76       & 8924     & 2          & CEL-Seq           & Yes  & \citep{Grun2014}            \\
2i medium  &  &  & &  &  & \\
\midrule

mESC 2i medium    & 74       & 8924     & 2          & CEL-Seq           & Yes  & \citep{Grun2014} \\
\midrule

Pool-split RNA             & 56       & 8924     & 2          & CEL-Seq           & Yes  & \citep{Grun2014}            \\
serum medium &  &      &         &   &   &  \\
\midrule

mECS serum medium & 52       & 8924     & 2          & CEL-Seq           & Yes  & \citep{Grun2014} \\
\bottomrule
\end{tabular}
\end{table}
\addcontentsline{lot}{table}{\ref{tab2:datasets} \hspace{2.5mm} Datasets used for model testing and analysis.}

\subsection{\textit{Dictyostelium} cells} \label{seq::data_dict}

Antolovi\'{c} \emph{et al.}, 2017 studied changes in expression variability between 0 hours (undifferentiated), 3 hours and 6 hours of \emph{Dictyostelium} differentiation \cite{Antolovic2017}.
Raw data is available by direct download (see Data S1 in \citep{Antolovic2017}).
Across all time points, 5 cells were removed due to low quality. Technical spike-in genes that were not detected and biological genes with an average expression (across all cells) smaller than 1 count were removed.
In total, 433 cells (131 cells in 3 batches at 0h, 157 cells in 3 batches at 3h, and 145 cells in 3 batches at 6h) and 10,551 genes (88 technical and 10,650 biological genes) passed filtering.
We used data from the 0h time point to test the functionality of our model.

\subsection{Mouse brain cells} \label{seq::data_micro}

This dataset was composed of UMI scRNA-Seq data of cells isolated from the mouse somatosensory cortex and hippocampal CA1 region \citep{Zeisel2015}.
Raw data is available from Gene Expression Omnibus under accession code GSE60361. Prior to the analysis, we removed technical genes with 0 total counts and biological genes for which the average count across all 3007 cells was below 0.1.
The groups comprising microglia cells and CA1 neurons were chosen for analysis to include cell populations comprising a small and large number of cells.
For these groups, 98 cells (microglia), 939 cells (CA1 pyramidal neurons) and 10,744 genes (10,687 biological and 57 technical genes) passed filtering.

\subsection{Pool-and-split RNAseq data} \label{seq::data_PaS}

This UMI-based dataset provides a control experiment to assess changes in biological heterogeneity in a situation where mean expression remains unchanged across conditions.
Pool-and-split samples were created by pooling 1 million mESCs grown in 2i or serum medium and splitting 20pg of RNA into aliquots.
These libraries are compared against single-cell samples (mESCs) \citep{Grun2014}.
Raw data is available from Gene Expression Omnibus under accession code GSE54695. \\

As in Gr\"un \emph{et al.}, 2014 \cite{Grun2014}, some cells were removed from the analysis due to low expression of the stem cell marker \textit{Oct4}.
Technical genes with 0 total counts were also removed from the analysis. Additionally, lowly expressed biological genes with fewer than 0.5 counts (on average, across all samples) were excluded.
This left 258 libraries (74 single mESCs grown in 2i medium, 52 single mESCs grown in serum medium, 76 pool-and-split aliquots from cells grown in 2i medium and 56 pool-and-split aliquots from cells grown in serum medium) as well as 8924 genes (50 technical spike-ins and 8874 biological genes) for the analysis.
Each condition contained 2 batches.\\

Matched smFISH data from mESCs grown in 2i and serum media were obtained from Dominic Gr\"un (Max Planck Institute of Immunobiology and Epigenetics, Freiburg, Germany) through personal communications. This smFISH experiment assayed 9 genes (\textit{Gli1}, \textit{Klf4}, \textit{Notch1}, \textit{Pcna}, \textit{Pou5f1}, \textit{Sohlh2}, \textit{Sox2}, \textit{Stag3}, \textit{Tpx2}) in more than 70 cells per condition. %We excluded \textit{Notch1} from the analysis due to strong disagreement between smFISH and scRNA-Seq data of cells grown in serum medium.

\subsection{CD4\plus{} T cell activation} \label{seq::data_cd4}

Non-UMI scRNA-Seq data of CD4\plus{} T cells represent data analysed in  the previous chapter.
Raw data is available from ArrayExpress under accession code E-MTAB-4888. To perform a variety of tests, naive and activated CD4\plus{} T cells from young \emph{Mus musculus} (B6) mice were selected.
Biological genes with an average count $<~1$ and non-detected technical genes were removed from the analysis.
In total, 146 cells (93 naive and 53 activated CD4\plus{} T cells) and 10,553 genes (10,495 biological and 58 technical genes) passed filtering. Each condition contains 2 replicates.

\subsection{CD4\plus{} T cell differentiation} \label{seq::data_cd4diff}

Non-UMI scRNA-Seq data were generated from CD4\plus{} T cells during differentiation towards Th1 and Tfh cell fates after \emph{Plasmodium} infection \citep{Lonnberg2017}.
Raw reads were downloaded from ArrayExpress [E-MTAB-4388] and mapped against the \emph{Mus musculus} genome (GRCm38) using \emph{gsnap} \citep{Wu2010a} with default settings.
Read counting was performed using \emph{HTSeq} \citep{Anders2014} with default settings. \\

Quality control was performed by removing cells with fewer than 300,000 biological reads or fewer than 600,000 technical reads at day 2.
At days 4 and 7, cells with fewer than 1,000,000 biological reads were excluded from downstream analysis.
Additionally, we removed genes that did not show an average detection of more than 1 read at day 2, day 3, day 4 or day 7 after infection.
After applying these criteria, 376 cells (Day 0: 16 cells, Day 2: 89, Day 3: 21, Day 4: 133, Day 7: 64, Day 7 non-infected: 53) and 7899 genes (7847 biological and 52 technical) remained for analysis.
Note that, due to low sample sizes, we focused our analysis on data from day 2, day 4 and day 7 post-infection.

\newpage

\section{The informative prior stabilises parameter estimation}
\label{sec2:stabilization}

Our joint prior formulation induces a non-linear regression that captures the overall trend between gene-specific over-dispersion parameters $\delta_i$ and mean expression parameters $\mu_i$.
Thus, we also refer to the extended model induced by this prior as the \textit{regression} BASiCS model.
Accordingly, the model induced by the original independent prior specification \citep{Vallejos2016} is referred to as the \textit{non-regression} BASiCS model.

\subsection{Dataset specificity of the regression trend}

To study the performance of the regression BASiCS model, we applied both the regression and non-regression BASiCS model to a variety of scRNA-Seq datasets.
Each dataset is unique in its composition, covering a range of different cell types and experimental protocols (see \textbf{Section \ref{sec2:datasets}} and \textbf{Table \ref{tab2:datasets}}).
Qualitatively, we observe that the inferred regression trend varies substantially across different datasets \textbf{(Fig.~\ref{fig2:datasets})}, justifying the choice of a flexible semi-parametric approach (see \textbf{Section \ref{sec2:extended_BASiCS}} and \textbf{Section \ref{sec2:hyper-parameters}}).
Moreover, as expected, we observe that residual over-dispersion parameters $\epsilon_i$ are not confounded by mean expression.
Additionally, we assessed whether the residual over-dispersion parameter is biased by the percentage of zero counts per gene \textbf{(Fig.~\ref{fig2:datasets}, fourth column)}.
This feature increases for lowly expressed genes due to technical expression drop-outs.
Nevertheless, posterior estimates of gene-specific residual over-dispersion parameters are not confounded by the percentage of zero counts per gene \textbf{(Fig.~\ref{fig2:datasets})}. \\

Next, we observed that the regression BASiCS model shrinks the posterior estimates for $\mu_i$ and $\delta_i$ towards the regression trend.
This is due to the joint prior specification on $(\mu_i,\delta_i)'$ and is consistent with the shrinkage observed in Love \emph{et al.}, 2014 \citep{Love2014}.
The strength of this shrinkage is dataset-specific, being more prominent in sparser datasets with a higher frequency of zero counts and for lowly-expressed genes where measurement error is greatest \textbf{(Fig.~\ref{fig2:datasets}A)}.

\newpage

\begin{figure}[!h]
\centering
\includegraphics[width=0.95\textwidth]{Fig_6.png}
\caption[Parameter estimation using a variety of scRNA-Seq datasets]{\textbf{Parameter estimation using a variety of scRNA-Seq datasets.}\\
Model parameters were estimated using the regression and non-regression BASiCS models on \textbf{(A)} naive CD4\plus{} T cells \citep{Martinez-jimenez2017}, \textbf{(B)} \textit{Dictyostelium} cells prior to differentiation (day 0) \citep{Antolovic2017}, \textbf{(C)} microglia cells \citep{Zeisel2015} and \textbf{(D)} pool-and-split RNA \citep{Grun2014}.
These datasets were selected to highlight situations with different levels of sparsity (i.e.~the proportion of zero counts, see fourth column).
The colour code within the scatterplots is used to represent areas with high (yellow/red) and low (blue) density of genes.
\textbf{First column:} gene-specific over-dispersion $\delta_i$ versus mean expression $\mu_i$ as estimated by the non-regression BASiCS model.
\textbf{Second column:} gene-specific over-dispersion $\delta_i$ versus mean expression $\mu_i$ as estimated by the regression BASiCS model.
The red line indicates the estimated regression trend.
Purple dots indicate genes detected (i.e.~with at least one count) in less than 2 cells.
\textbf{Third column:} gene-specific residual over-dispersion $\epsilon_i$ versus mean expression $\mu_i$ as estimated by the regression BASiCS model.
\textbf{Forth column:} gene-specific posterior estimates for residual over-dispersion $\epsilon_i$ parameters versus percentage of zero counts for each gene.\\}
\label{fig2:datasets}
\end{figure}

\newpage

\subsection{Stabilisation of posterior inference}
\label{sec2:parameter_stabilization}

Next, we asked whether or not the shrinkage introduced by the regression BASiCS model improves posterior inference.
To assess this, we compared estimates for gene-specific parameters across (i) different sample sizes and (ii) different gene expression levels.
Both the sample size and the level of expression influence posterior estimation of model parameters due to loss of power when few cells are used to estimate parameters for lowly expressed genes.
More concretely, we used a large dataset containing 939 CA1 pyramidal neurons \citep{Zeisel2015} (\textbf{Section \ref{seq::data_micro}}) to artificially generate smaller datasets by randomly sub-sampling 50-500 cells.
For each sample size, parameter estimates were then obtained using both the regression and non-regression BASiCS models.
Based on parameter estimates using the non-regression model, we split the genes into three sets: lowly expressed ($\mu_i<1.89$), medium expressed ($1.89<\mu_i<5.37$) and highly expressed ($\mu_i>5.37$).
These cut-off values were chosen such that roughly a third of genes were assigned to each category.
The distribution of these estimates is summarised in \textbf{Fig.~\ref{fig2:parameter_stabilization}}. \\

Firstly, we observe that both the regression and non-regression BASiCS models led to consistent and largely stable mean expression estimates $\mu_i$ across different sample sizes and expression levels \textbf{(Fig.~\ref{fig2:parameter_stabilization}A)}.
Secondly, in line with the results in \textbf{Fig.~\ref{fig2:datasets}}, the main differences between the methods arise when estimating the over-dispersion parameters $\delta_i$ \textbf{(Fig.~\ref{fig2:parameter_stabilization}B)}.
In particular, we observe that the non-regression BASiCS model appears to underestimate $\delta_i$ for lowly expressed genes when the sample size is small (with respect to the parameter estimates obtained based on the full dataset of 939 cells).
This is due to the original, non-informative prior: $\delta_i\sim\textnormal{log-N}(0,a_\delta^2)$.
In the case of lowly expressed genes, the data is not informative and the over-dispersion parameters are estimated as $\delta_i\approx{}0$. In contrast, the shrinkage introduced by our regression BASiCS model aids parameter estimation, leading to robust estimates even for the smallest sample size.
This is particularly important for rare cell populations where large sample sizes are difficult to obtain.
A similar effect is observed for genes with medium and high expression levels, where the non-regression BASiCS model appears to slightly overestimate $\delta_i$.
We also observe that estimates of residual over-dispersion parameters $\epsilon_i$ are stable across sample sizes and expression levels. \textbf{Fig.~\ref{fig2:parameter_stabilization2}A-C} summarises 10 replicates of the down-sampling experiment performed in \textbf{Fig.~\ref{fig2:parameter_stabilization}A-C}.
We use parameters estimated from the full dataset as \gls{pgt} values.
For each sub-sampling experiment, sample size and gene set, we computed the median $\log_2$ fold change in $\mu_i$ and $\delta_i$ and the median difference for $\epsilon_i$ between the estimates and the \gls{pgt}.
The median and the range of these values across 10 sub-sampling experiments is used for visualisation purposes \textbf{(Fig.~\ref{fig2:parameter_stabilization2}A-C)}.

\begin{figure}[!h]
\centering
\includegraphics[width=0.9\textwidth]{Fig_7.png}
\caption[Estimation of gene-specific model parameters for varying sample sizes]{\textbf{Estimation of gene-specific model parameters for varying sample sizes.}\\
The regression (orange) and non-regression (blue) BASiCS models were used to estimate gene-specific model parameters for lowly (lower panels), medium (mid panels) and highly (upper panels) expressed genes across populations with varying numbers of cells.
These were generated by randomly sub-sampling cells from a population of 939 CA1 pyramidal neurons \citep{Zeisel2015}.
Extended results based on multiple downsampling experiments are displayed in \textbf{Fig.~\ref{fig2:parameter_stabilization2}A-C}.
\textbf{(A-C)} For a single sub-sampling experiment, boxplots summarise the distribution of gene-specific estimates for (A) mean expression parameters $\mu_i$ (log-scale), (B) over-dispersion parameters $\delta_i$ (log-scale) and (C) residual over-dispersion parameters $\epsilon_i$.
\textbf{(D-F)} For 10 sub-sampling experiments, parameter estimates were compared against a \textit{pseudo} ground truth (pgt).
The latter is defined as the parameter estimates obtained for the full population of 939 cells using the regression BASiCS model.
For each sub-sampling experiment, gene-specific log$_2$ fold changes ($\log_2(\mu_i/\mu_{i,pgt})$ and $\log_2(\delta_i/\delta_{i,pgt})$) and distances ($\epsilon_i - \epsilon_{i,pgt}$) between the estimates and the pgt were computed.
For visualisation purposes, the medians across genes for each sub-sampling experiment are presented,}
\label{fig2:parameter_stabilization}
\end{figure}

\subsection{Validation of gene-specific posterior estimates by smFISH}

As an external validation, we compared our posterior estimates of gene-specific model parameters obtained from scRNA-Seq data to empirical estimates from matched smFISH data of mouse embryonic stem cells grown in 2i and serum media \citep{Grun2014}.
Firstly, posterior estimates of mean-expression parameters $\mu_i$ exhibit high correlation to smFISH mean transcript counts \textbf{(Fig.~\ref{fig2:parameter_stabilization2}D)}.
Secondly, we also observe a strong correlation between posterior estimates for over-dispersion parameters $\delta_i$ and the empirical CV$^2$ values obtained from smFISH data \textbf{(Fig.\ref{fig2:parameter_stabilization2}E)}.
Finally, a similar behaviour is observed when comparing posterior estimates of residual over-dispersion parameters $\epsilon_i$ to a residual CV$^2$ \textbf{(Fig.\ref{fig2:parameter_stabilization2}F)}.
As in Brennecke \emph{et al.}, 2013 \cite{Brennecke2013}, to obtain residual CV$^2$ values for the smFISH data, we fitted a gamma generalised linear model with identity link (\textit{glmgam.fit} of the \textit{statmod} package in R) between the CV$^2$ and the reciprocal log-transformed mean transcript counts.

\begin{figure}[!h]
\centering
\includegraphics[width=0.9\textwidth]{Fig_8.png}
\caption[Stability of posterior estimates for gene-specific parameters]{\textbf{Stability of posterior estimates for gene-specific parameters.}\\
\textbf{(A-C)} Matched scRNA-Seq and smFISH data measured on mouse embryonic stem cells grown in 2i and serum media \citep{Grun2014} was used to validate the performance of the regression BASiCS model.
Gene-specific parameter estimates obtained by the regression BASiCS model were compared against empirical estimates calculated based on smFISH data.
This comparison includes 8 genes, measured in both conditions. Pearson's correlation is indicated for each comparison,
\textbf{(D)} Estimates of mean expression parameters $\mu_i$ (log-scale) are plotted against mean transcript count (smFISH),
\textbf{(E)} Estimates of over-dispersion parameters $\delta_i$ (log-scale) are plotted against the squared coefficient of variation (CV$^2$) of transcript counts (smFISH),
\textbf{(F)} Estimates for residual over-dispersion parameters $\epsilon_i$ are compared against residual estimates of variability estimated for the smFISH data.}
\label{fig2:parameter_stabilization2}
\end{figure}

\newpage

\section{Expression variability during immune responses}

Here, we illustrate how the regression BASiCS model assesses changes in expression variability using CD4\plus{} T cell activation and differentiation.
For all datasets, pre-processing steps are described in \textbf{Section \ref{sec2:datasets}}.

\subsection{Testing variability changes upon immune activation}
\label{sec2:immune_activation}

As described in the previous chapter, the non-regression BASiCS model only allows the assessment of changes in variability for genes that remain stable in gene expression across conditions.
Here, we extend the previous analysis and test for changes in variability in parallel to changes in mean expression. \\

To identify gene expression changes during early T cell activation, we compared CD4\plus{} T cells before (naive) and after (active) 3 hours of stimulation with CD28 and CD3\textepsilon{} antibodies (see \textbf{Section \ref{sec1:activation}} and \citep{Martinez-jimenez2017}).
For both conditions, we ran the regression BASiCS model independently and performed differential mean expression and differential variability testing using the residual over-dispersion parameters.
Testing changes in variability through residual over-dispersion is performed across all genes, including the large set of genes that are up-regulated upon immune activation \textbf{(Fig.~\ref{fig1:immune_activation})}.
The latter include immune-response genes and critical drivers for CD4\plus{} T cell functionality that had to be excluded from analysis in the previous chapter.

\subsubsection{Comparison between the regression and non-regression BASiCS model}

Firstly, we compared the results obtained by the regression BASiCS model to those presented in \textbf{Section \ref{sec1:activation}}.
To allow for a direct comparison of the results, the same inclusion criteria as in the previous chapter is adopted, i.e.~we excluded genes with low mean expression ($\mu_i<50$) in both conditions from testing.
Moreover, the minimum tolerance thresholds were also adapted to match the choices in \textbf{Section \ref{sec1:activation}}.
To detect differentially expressed genes, a minimum tolerance threshold $\tau_0 = 2$ was used \textbf{(Fig.~\ref{fig2:model_comparison}A)}.
To compare the detection of differentially over-dispersed genes, we performed differential mean expression testing using a stringent minimum tolerance threshold $\tau_0 = 0$ for both models (this is to avoid the results being confounded by changes in mean, see upper panel in \textbf{Fig.~\ref{fig2:model_comparison}B}).
For the 463 genes that are detected as non-differentially expressed by both models for this threshold, a total of 111 genes are detected as differentially over-dispersed by either model (minimum tolerance log$_2$ fold change threshold $\omega_0 = \log_2(1.5) = 0.58$).
Out of this set, 93 genes ($\sim$83\%) are detected as differentially over-dispersed by both models (see lower panel in \textbf{Fig.~\ref{fig2:model_comparison}B}).

\begin{figure}[!h]
\centering
\includegraphics[width=\textwidth]{Fig_9.png}
\caption[Differential testing results of the two BASiCS models]{\textbf{Differential testing comparison between the regression and non-regression BASiCS model.}\\
\textbf{(A)-(B)} Results of differential testing between naive and activated CD4\plus{} T cells were compared between the regression and non-regression BASiCS models.
As in \textbf{Section \ref{sec1:activation}}, genes with low mean expression ($\mu_i<50$) in both conditions were excluded from testing. \textbf{(A)} Overlap of differentially expressed genes (mean) using a minimum tolerance threshold $\tau_0=2$ obtained by the regression and non-regression BASiCS models (EFDR = 10\%),
\textbf{(B)} Upper panel: overlap of genes detected as non-differentially expressed using a stringent minimum tolerance threshold $\tau_0=0$ obtained by the regression and non-regression BASiCS models (EFDR = 10\%).
Lower panel: overlap of differentially over-dispersed genes using a minimum tolerance threshold $\omega_0=\log_2(1.5)$ obtained using the regression and non-regression  BASiCS models for the 463 genes detected as non-differentially expressed by both models (EFDR = 10\%).}
\label{fig2:model_comparison}
\end{figure}

\subsubsection{Differential testing during immune activation}

For further analyses in this chapter (and in contrast to the previous chapter), we exclude genes whose estimated mean expression parameter $\mu_i$ was below 1 from the differential testing.
Furthermore, a $\log_2$ fold change threshold $\tau_0 = 1$ was adopted for mean expression testing.
Unlike the more stringent threshold used in the previous chapter ($\tau_0 = 2$), this choice allows us to detect more subtle changes in mean expression.
Moreover, the default threshold $\psi_0 = 0.41$ was used for differential variability testing.
The EFDR was controlled to 10\%. By using these thresholds, our model classifies genes into four categories based on their expression dynamics: down-regulated upon activation with (i) lower and (ii) higher variability, and up-regulated with (iii) lower and (iv) higher variability \textbf{(Fig.~\ref{fig2:immune_activation}A)}. \\

Genes with up-regulated expression upon activation and decreased expression variability encode components of the splicing machinery (e.g.~\textit{Sf3a3}, \textit{Plrg1}), RNA polymerase subunits (e.g.~\textit{Polr2l}, \textit{Polr1d}) as well as translation machinery components (e.g.~\textit{Ncl}, \textit{Naf1}) (see \textbf{Fig.~\ref{fig2:immune_activation}B}).
These biosynthetic processes help naive T cells to rapidly enter a programme of proliferation and effector molecule synthesis \citep{Tan2017,Araki2017}.
Therefore, rapid and uniform up-regulation of these transcripts would assist such processes.
This observation also confirms our previous findings that the translational machinery is tightly regulated during early immune activation (see \textbf{Section \ref{sec1:activation}}).\\

In contrast, genes with up-regulated expression and increased expression variability (see \textbf{Fig.~\ref{fig2:immune_activation}C}) include the death-inducing and inhibitory transmembrane ligands \gls{Fasl} and \gls{PDL1} (gene symbol: \textit{Cd274}), the regulatory transcription factor Smad3 (\textit{Smad3}), and the TCR-induced transcription factor, Oct2 (\textit{Pou2f2}).
Additionally, we detect a heterogeneous up-regulation in the mRNA expression of the autocrine/paracrine growth factor Il2 (\textit{Il2}) upon immune activation.
This is in line with previous reports of binary Il2 expression within a population of activated T cells, which has been suggested to be necessary for a scalable antigen response \citep{Fuhrmann2016}.
Heterogeneity in expression of these genes suggests that, despite their uniform up-regulation of biosynthetic machinery, the T cells in this early activation culture represent a mixed population with varying degrees of activation and/or regulatory potential. \\

For each of these gene sets, functional annotation analysis was performed using all tested genes as background.
The functional annotation clustering tool in DAVID \citep{Dennis2003} was used to cluster annotation categories based on similarity and sort them according to their enrichment score.
Here, we list the top 3 functional annotation clusters per gene set and their corresponding enrichment score (ES):
\begin{itemize}
\item \textbf{Down-regulated with lower variability:} Pleckstrin homology domain (ES = 1.57), G protein signalling (ES = 1.51), glycosidase (ES = 1.49),
\item \textbf{Down-regulated with higher variability:} Ankyrin repeat-containing domain (ES = 2.19), GTPase mediated signalling (ES = 1.51), steroid biosynthesis (ES = 0.89),
\item \textbf{Up-regulated with lower variability:} RNA polymerase (ES = 1.6), RNA binding (ES = 1.53), splicing (ES = 1.41),
\item \textbf{Up-regulated with higher variability:} Cytokine-cytokine receptor interaction (ES = 1.65), WD40 repeat (ES = 1.22), transcription (ES = 1.18).
\end{itemize}

\newpage

\begin{figure}[!h]
\centering
\includegraphics[width=0.7\textwidth]{Fig_10.png}
\caption[Changes in expression patterns during early immune activation]{\textbf{Changes in expression patterns during early immune activation.}\\
Differential testing (mean and residual over-dispersion) was performed between naive and activated murine CD4\plus{} T cells taken from the previous chapter.
This analysis uses a minimum tolerance threshold of $\tau_0=1$ for changes in mean expression and a minimum tolerance threshold of $\psi_0=0.41$ for differential residual over-dispersion testing (expected false discovery rate is fixed at 10\%).
\textbf{(A)} For each gene, the difference in residual over-dispersion estimates (Active - Naive) is plotted versus the log$_2$ fold change in mean expression (Active/Naive).
Genes with statistically significant changes in mean expression and variability are coloured based on their regulation (up/down-regulated, higher/lower variability),
\textbf{(B-C)} Normalised expression counts across the naive (purple) and active (green) CD4\plus{} T cell population are visualised for representative genes that (B) increase in mean expression and decrease in expression variability and (C) increase in mean expression as well as expression variability  upon immune activation.
Each dot represents a single cell.}
\label{fig2:immune_activation}
\end{figure}

\newpage

\subsubsection{Effect of expression outliers on changes in variability}

We observe that for some genes (e.g.~\textit{Plrg1}), changes in variability are driven by a small number of outlier cells with high expression.
The interpretation of these results is not trivial as it could reflect very subtle sub-structure or genuine changes in variability.
To explore this, we performed the following synthetic experiment: We artificially created a mixed population of cells by combining 5 activated CD4\plus{} T cells with a population of 93 naive CD4\plus{} T cells therefore simulating expression outliers.
Subsequently, we performed a differential testing (mean and residual over-dispersion) between this mixed population and a \textit{pure} population of 93 naive CD4\plus{} T cells.
As expected, this analysis shows an overall increase in variability in the mixed population.
For example, among the genes that exhibit higher mean expression and higher residual over-dispersion in the mixed population, we found \textit{Il2} which is up-regulated upon CD4\plus{} T cell activation \textbf{(Fig.~\ref{fig2:mixture_population}A)}.
Moreover, we observe that the genes in this category are enriched for those that are only expressed in the 5 activated CD4\plus{} T cells \textbf{(Fig.~\ref{fig2:mixture_population}B)}.
This result suggests that differential variability testing can potentially uncover markers for heterogeneous cell states or cell types that can provide important biological insights.
However, changes in residual over-dispersion that are driven by outliers can also reflect unwanted contamination (e.g.~mixed cell types), hence careful data filtering and clustering analysis should be performed prior to differential variability testing.

\begin{figure}[!h]
\centering
\includegraphics[width=\textwidth]{Fig_11.png}
\caption[Dissecting changes in variability driven by expression outliers]{\textbf{Dissecting changes in variability driven by expression outliers.}\\
5 activated CD4\plus{} T cells were combined with a population of 93 naive CD4\plus{} T cells.
\textbf{(A)} Distribution of normalised expression counts for \textit{Il2} in a population of naive CD4\plus{} T cells (red) and the mixture population representing a mix of 93 naive and 5 activated CD4\plus{} T cells (blue).
Each dot represents a single cell, \textbf{(B)} Genes with increased mean expression and increased variability in the mixed population were detected.
The heatmap shows normalised expression counts for these genes across the mixed population (93 naive and 5 activated CD4\plus{} T cells).}
\label{fig2:mixture_population}
\end{figure}

\newpage

In summary, our approach allows us to extend the findings from the previous chapter, dissecting immune-response genes into two functional sets: (i) homogeneous up-regulation of biosynthetic machinery components and (ii) heterogeneous up-regulation of several immunoregulatory genes.

\subsection{Expression dynamics during \textit{in vivo} CD4\plus{} T cell differentiation}

In contrast to the quick transcriptional switch that occurs within hours of naive T cell activation, transcriptional changes during cellular differentiation processes are more subtle and were found to be coupled with changes in variability prior to cell fate decisions \citep{Richard2016, Mojtahedi2016}.
Here, we apply our method to study changes in expression variability during CD4\plus{} T cell differentiation after malaria infection using the dataset introduced by L\"onnberg \emph{et al.}, 2017 \cite{Lonnberg2017}.
In particular, we focus on samples collected 2, 4 and 7 days post-malaria infection, for which more than 50 cells are available.
The BASiCS model was run for 40,000 iterations independently for each condition.

\subsubsection{Changes in variability over the differentiation time course}

First, we studied global changes in over-dispersion along the differentiation time course by comparing posterior estimates for the gene-specific over-dispersion parameter $\delta_i$, focusing on 126 genes for which mean expression does not change \textbf{(Fig.~\ref{fig2:immune_differentiation}A)}.
These genes were detected by testing changes in mean expression using a stringent threshold ($\tau_0=0$) between day 2 and day 4 as well as between day 4 and day 7.
Genes that are not detected as differentially expressed in both tests were considered for variability analysis.
We found that the expression of these genes is most tightly regulated at day 4, when cells are in a highly proliferative state.
Moreover, between day 4 and day 7, the cell population becomes more heterogeneous.
This is in line with the emergence of differentiated Th1 and Tfh cells that was observed by L\"onnberg \emph{et al.}, 2017. \\

Next, we exploited the residual over-dispersion parameters to identify changes in variability (irrespective of changes in mean expression) between consecutive time points.
For this, we performed differential variability testing using the default threshold on changes in the residual over-dispersion parameter ($\psi_0 = 0.41$) between day 2 and day 4 as well as between day 4 and day 7.
After testing, we excluded all genes that are expressed in fewer than 2 cells in at least one time point from down-stream analysis.
Separating the remaining genes by whether their variability increases or decreases between time points revealed four different patterns \textbf{(Fig.~\ref{fig2:immune_differentiation}B)}.
These include genes whose variability systematically increases (or decreases) as well as patterns where variability is highest (or lowest) at day 4.

\begin{figure}[!h]
\centering
\includegraphics[width=\textwidth]{Fig_12.png}
\caption[Dynamics of expression variability throughout CD4\plus{} T cell differentiation]{\textbf{Dynamics of expression variability throughout CD4\plus{} T cell differentiation.}\\
Analysis was performed on CD4\plus{} T cells assayed 2 days, 4 days and 7 days after \textit{Plasmodium} infection.
Changes in residual over-dispersion were tested using a minimum tolerance threshold of $\psi_0=0.41$ (EFDR is fixed at 10\%),
\textbf{(A)} Distribution of posterior estimates of over-dispersion parameters $\delta_i$ for genes that exhibit no changes in mean expression across the differentiation time course.
Changes in mean expression were tested using a minimum tolerance threshold of $\tau_0=0$ (expected false discovery rate is fixed at 10\%),
\textbf{(B)} Posterior estimates for residual over-dispersion parameters  $\epsilon_i$, focusing on genes with statistically significant changes in expression variability between time points.
Gene set size is indicated for each plot,
\textbf{(C-D)} Normalised expression counts across cell populations at day 2 (yellow) and day 4 (red) post infection are visualised for representative genes that (C) increase or (D) decrease in variability during differentiation.
Each dot represents a single cell.\\}
\label{fig2:immune_differentiation}
\end{figure}

\subsubsection{Opposing expression dynamics of lineage-defining marker genes}

The differential variability analysis between day 2 and day 4, revealed  changes in expression variability for a set of immune-related genes \textbf{(Fig.~\ref{fig2:immune_differentiation}C-D)}.
For example, expression of \gls{Cxcr5} which encodes the chemokine receptor that directs Tfh cells to the B cell follicles \citep{Crotty2014}, strongly increases in variability on day 4.
This finding agrees with results from L\"onnberg \emph{et al.}, 2017 \citep{Lonnberg2017}, where Tfh and Th1 differentiation was observed to be transcriptionally detectable at day 4 within a subset of activated cells.
A similar behaviour was observed for \gls{Tyk2} and \gls{Tigit}. The latter encodes a receptor that is expressed by a subset of Tfh cells and that was found to promote Tfh function \citep{Godefroy2015}.
In contrast, we observe a decrease in variability between day 2 and day 4 for \gls{Ikzf4} (Treg-associated gene), \textit{Ly6c1} (expressed by effector T cells) and \textit{Tbx21} (encoding the Th1 lineage-defining transcription factor Tbet). \\

To achieve a broader view on changes in variability within sets of genes that drive this differentiation process, we selected gene sets listed in L\"onnberg \emph{et al.}, 2017 to visualise their changes in mean expression and residual over-dispersion \citep{Lonnberg2017}.
The first set of genes is taken from Figure 3E of the original publication, which filtered genes based on their association with the bifurcation of Th1 and Tfh differentiation.
The second set of genes with sequential peak expression over pseudo-time is taken from Figure 5A of the original publication, which were selected based on immunological relevance from a list of dynamic genes during \textit{in vivo} differentiation.
For the genes that were detected to be lineage-associated, we detected a continuous increase in expression of Th1-associated genes but not Tfh-associated genes \textbf{(Fig.~\ref{fig2:immune_differentiation2}A)}, with the majority of changes in variability for these genes occurring between day 2 and day 4. \\

Finally, we examined immune-related genes (\textit{Il2ra, Tbx21, Il2rb, Cxcr5, Selplg, Id2, Ifng, Icos, Ifngr1}) that were previously described as showing differences in their peak expression over the pseudo time course of differentiation \citep{Lonnberg2017} \textbf{(Fig.~\ref{fig2:immune_differentiation2}B)}.
From this list, the lineage-associated genes \textit{Tbx21} and \textit{Cxcr5} are up-regulated between days 2 and 4.
However, these genes  exhibit opposite behaviours in terms of variability: \textit{Cxcr5} increases and \textit{Tbx21} decreases in variability between day 2 and day 4 \textbf{(Fig.~\ref{fig2:immune_differentiation2}C)}.
The fact that variability of \textit{Tbx21} (Tbet) expression was highest on day 2 suggests that Tbet is up-regulated very early in differentiation, as seen in \cite{Lonnberg2017} and similar to \textit{in vitro} Th1 induction \citep{Szabo2000}.
Moreover, this suggests that Th1 fate decisions (for at least a subset of cells) may be made even earlier than the differentiation bifurcation point identified on day 4 by the original study \citep{Lonnberg2017}.

\newpage

\begin{figure}[!h]
  \begin{minipage}[c]{0.57\textwidth}
    \includegraphics[width=\textwidth]{Fig_13.png}
  \end{minipage}\hfill
  \begin{minipage}[c]{0.4\textwidth}
\caption[Differential regulation of lineage-associated genes across differentiation]{\textbf{Differential regulation of Th1- and Tfh-associated genes across the differentiation process.}\\
Differential mean expression testing (minimum tolerance threshold $\tau_0=1$) and differential residual over-dispersion testing (minimum tolerance threshold $\psi_0=0.41$) was performed on cell populations between day 2 and day 4 as well as day 4 and day 7 controlling the EFDR to 10\%.
Genes that increase in expression over time are marked with a red dot while genes that decrease in expression over time are marked with a blue dot.
Similarly, genes that increase in variability over time are marked in purple while genes that decrease in variability over time are marked in green. Only genes that pass filtering are visualised.
\textbf{(A)} Differential testing results are visualised for Th1- and Tfh-associated genes taken from Figure 3E in L\"onnberg \emph{et al.}, 2017 \citep{Lonnberg2017}.
Genes are ordered based on their correlation with the Th1 trend assignment (top to bottom) or their correlation to Tfh trend assignment (bottom to top),
\textbf{(B)} Differential testing results are visualised for important genes during CD4\plus{} T cell differentiation taken from Figure 5A in \citep{Lonnberg2017}. Genes were ordered based on their peak expression point in pseudo-time as defined by L\"onnberg \emph{et al.}, 2017 \citep{Lonnberg2017},
\textbf{(C)} \textit{Tbx21} (blue) and \textit{Cxcr5} (red) measured at day 2, day 4 and day 7 post-infection.
Posterior estimates for residual over-dispersion parameters $\epsilon_i$ are plotted against posterior estimates for mean expression parameters $\mu_i$.
Statistically significant changes in mean expression (DE, minimum tolerance threshold of $\tau_0=1$) and variability (DV, minimum tolerance threshold of $\psi_0=0.41$) are indicated for each comparison} \label{fig2:immune_differentiation2}
  \end{minipage}
\end{figure}

\newpage

\section{Application to droplet-based scRNA-Seq data}
\label{sec2:droplet}

\begin{Comment}
\hspace{-3mm} \textbf{Declaration} In the context of expanding the BASiCS framework to test changes in variability independent of mean expression, Catalina A. Vallejos (The Alan Turing Institute/MRC Institute of Human Genetics/University of Edinburgh) developed an approach where technical variation was quantified by borrowing information across multiple replicates.
This avoids the use of technical spike-in genes when droplet-based scRNA-Seq data is analysed.
This approach is part of the publication:\\

Nils Eling, Arianne C. Richard, Sylvia Richardson, John C. Marioni, Catalina A. Vallejos. Robust expression variability testing reveals heterogeneous T cell responses. \emph{Cell Systems}, In press, 2018 \\

Here, I will not describe this approach in detail as this has not been my own work.
However in the context of this section, it integrates with my contribution to assess mean-independent changes in variability for droplet-based scRNA-Seq data.
\end{Comment}

With the development of droplet-based scRNA-Seq technologies, the number of cells that can be profiled per experiment strongly increased at the cost of lower sequencing depth per cell \citep{Macosko2015, Klein2015, Zheng2017}.
Furthermore, these technologies exclude the use of spike-in RNA to measure technical variation, which is essential for quantifying technical variation using the original BASiCS model \citep{Vallejos2015BASiCS, Vallejos2016}.
To ensure the broad applicability of the BASiCS model, both the regression and non-regression models have been expanded to handle datasets without spike-in genes.
For this purpose, principles of measurement error models were exploited, where --- in the absence of gold standard features --- technical variation is quantified through {\it replication} \citep{Carroll1998}.
This horizontal data integration approach is based on experimental designs where cells from a population are randomly allocated to multiple independent experimental replicates (batches).
In such an experimental design, the no-spikes implementation of BASiCS assumes that biological effects are shared across batches and that technical variation will be reflected by spurious differences.
As shown in the publication, posterior inference under the no-spikes BASiCS model closely matches the original implementation for datasets where spike-ins and batches are available.
Technical details about the no-spikes implementation of BASiCS are discussed in the original publication (see \textbf{Declaration}).

\newpage

\subsection{Differential testing using somitic and pre-somitic mesoderm cells}

To test the applicability of the regression BASiCS model to droplet-based scRNA-Seq data, I analysed cells isolated from mouse embryos at E8.25 \citep{Ibarra-Soria2018}.
Ibarra-Soria \emph{et al.}, 2018 analysed more than 20,000 cells to identify the major cell types following gastrulation.
Key findings included a spatial sub-structure within the foregut, detection of oscillating gene expression patterns during somitogenesis and the contribution of the leukotriene pathway to blood formation.
I selected the cells identified as presomotic mesoderm and somitic mesoderm as test populations as they reside in contrasting differentiation stages.
Somitogenesis is a rhythmic and sequential differentiation process from \gls{PSM} cells to mature somites, which later will give rise to bone, muscle and skin of the adult body.
Throughout this process, oscillating gene expression patterns control the differentiation of PSM into \gls{SM}.
Driving factors for this are Wnt and \gls{Fgf} signalling on the side of the PSM and retinoic acid signalling in somites \cite{Oates2012}.
The regression BASiCS model can now further dissect transcriptional regulation between these groups of cells.

\subsubsection{Data processing}

The raw counts data and assigned cluster labels can be obtained from ArrayExpress [E-MTAB-6153] \citep{Ibarra-Soria2018}.
I selected cells labelled as pre-somitic mesoderm and somitic mesoderm for further down-stream analysis and removed lowly expressed genes ($< 0.1$ reads on average).
For visualisation purposes, I normalised the data using \emph{scran} by pooling cells within each cell type.
PCA computed on the log-transformed normalised counts shows a clear separation between these two cells types with an additional intermediate cell type labelled as 'presomiticmesoderm.b'.
I excluded this small set of cells as well as outlying cells for which $\text{PC2}{}<{}-5$ \textbf{(Fig.~\ref{fig2:droplet}A)}.
After filtering, I obtained 791 pre-somitic mesoderm cells and 670 somitic mesoderm cells for further analysis. For each of the two populations, the MCMC was run for 20,000 iterations separately.
After posterior inference was completed, I first confirmed that the model estimated the regression trend between the over-dispersion parameters $\delta_i$ and mean expression parameters $\mu_i$ correctly.
For both conditions, the regression trend captures the full range of data points and differential testing can be performed \textbf{(Fig.~\ref{fig2:droplet}B)}.
For differential testing, I used a threshold of $\tau_0=1$ to assess changes in mean expression and the default threshold $\psi_0\approx{}0.41$ to test changes in residual over-dispersion.

\newpage

\begin{figure}[!h]
\centering
\includegraphics[width=\textwidth]{Fig_14.png}
\caption[Quantification of expression dynamics from droplet-based scRNA-Seq data]{\textbf{Quantification of expression dynamics from droplet-based scRNA-Seq data (Full legend on next page).}}
\label{fig2:droplet}
\end{figure}

\newpage

\captionsetup[figure]{list=no}
\addtocounter{figure}{-1}
\captionof{figure}{\textbf{Quantification of expression dynamics from droplet-based scRNA-Seq data (continued).}\\
\textbf{(A)} Somitic (SM) and pre-somitic mesoderm (PSM) cells from droplet-based scRNA-Seq data \citep{Ibarra-Soria2018} were selected and visualised via a PCA.
Colour labelling was done based on the cluster annotation taken from the original publication.
For down-stream analysis cells with $\text{PC2}{}<{}-5$ and marked as 'presomiticmesoderm.b'/Pre-somitic mesoderm 2 were removed, \textbf{(B)} For each condition, over-dispersion estimates $\delta_i$ were plotted against mean expression estimates $\mu_i$.
The regression trend is indicated as red line,
\textbf{(C)} Posterior estimates for the log$_2$ fold change in mean expression between PSM and SM were plotted against mean expression averaged across the two populations.
Differentially expressed genes are coloured based on their regulation: blue: PSM-specific (PSM+), red: SM-specific (SM+),
\textbf{(D)} Posterior estimates for differences in residual over-dispersion between PSM and SM were plotted against mean expression averaged across the two populations.
Differentially variable genes are coloured based on their regulation: purple: PSM-specific (PSM+), brown: SM-specific (SM+),
\textbf{(E)} Heatmap showing the Z score scaled gene expression of pre-somitic mesoderm-specific genes of the GO category GO:0009952: anterior/posterior pattern specification.
Genes were ordered based on their log$_2$ fold change in expression from highest to lowest,
\textbf{(F)} Gene expression of \textit{Meox2} in PSM and SM. This gene was detected to be heterogeneously up-regulated in SM.
Upper panel: violin plots showing distribution of log-normalised expression counts.
Lower panel: \textit{Meox2} expression across the PCA from \textbf{(A)}.\\}
\captionsetup[figure]{list=yes}

\subsubsection{Changes in mean expression during somitogenesis}

I first tested changes in mean expression between SM and PSM and detected 203 SM-specific genes and 236 PSM-specific genes.
Based on these cell type-specific gene lists, I performed GO analysis using the Bioconductor \emph{goseq} package while correcting for gene length biases.
As expected, top enriched categories for SM-specific genes include 'animal organ morphogenesis' and 'skeletal system development' which contain genes such as \textit{Bmp7}, \textit{Fgfr2}, \textit{Gata6} and \textit{Meox2}.
Somites are rhythmically formed from the PSM and are embryonic precursors for vertebrae and skeletal muscles \citep{Dequeant2008}.
On the other hand, top categories for PSM-specific genes include 'pattern specification process', 'somitogenesis' and 'Wnt signaling pathway'.
It is known that the posterior end of the PSM is high in Wnt and Fgf signalling that determines the oscillation dynamics of individual cells during somitogenesis \citep{Oates2012}.
\textbf{Fig.~\ref{fig2:droplet}E} visualises the PSM-specific gene expression of the GO category: GO:0009952 - anterior/posterior pattern specification.
This category includes contributors to embryonic patterning: \textit{Fgf8} \citep{Dubrulle2004}, Wnt signalling components (e.g.~\textit{Wnt5a}, \textit{Dkk1}), Notch signalling components (e.g.~\textit{Dll1}) \citep{Dequeant2008} and several members of the Hox gene family which control embryonic patterning \citep{Pearson2005}.

\newpage

\subsubsection{Changes in variability during somitogenesis}

Next, I tested changes in variability between SM and PSM and categorised genes based on their regulation as in \textbf{Section \ref{sec2:immune_activation}}.
These categories include genes with higher expression and higher variability in SM, higher expression and lower variability in SM, higher expression and higher variability in PSM and higher expression and lower variability in PSM.
Interestingly, I detected the \gls{Meox2} gene to be heterogeneously up-regulated in somitic mesoderm when compared to the precursor mesoderm \textbf{(Fig.~\ref{fig2:droplet}F)}.
\textit{Meox2} has been shown to regulate somite morphogenesis, patterning and differentiation specifically in the sclerotome (forming the vertebrae and rib cartilage) alongside its paralog \textit{Meox1}.
While knocking out \textit{Meox1} in mice only shows mild defects in vertebrate and rib bones, the knockout of \textit{Meox2} induces defective differentiation and morphogenesis of the limb muscles \cite{Mankoo2003}.
The heterogeneous, but unstructured \textbf{(Fig.~\ref{fig2:droplet}F)}, expression of \textit{Meox2} might therefore indicate the identity of early progenitor cells that later on differentiate to form  muscles of the limbs.
Similarly, I find \gls{Dmrt2} heterogeneously up-regulated in SM compared to PSM.
This transcription factor has been implicated in somite development with specific expression in the dermomyotome, the part of the mesoderm that forms skin.
The homozygous loss of \textit{Dmrt2} leads to severe somite patterning defects at E10.5 and mice die shortly after birth \citep{Seo2006}.
The differential variability analysis revealed an early and heterogeneous expression of \textit{Dmrt2} in SM which leads to the possible identification of dermomyotome progenitor cells.\\

In sum, I confirmed that the regression BASiCS model can be applied to droplet-based scRNA-Seq data to assess changes in transcriptional variability between conditions.
This is an important validation for the next chapter, where I apply the regression BASiCS model to continuous droplet-based scRNA-Seq data to study changes in variability during spermatogenesis.