% Gemini theme
% https://github.com/anishathalye/gemini
%
% We try to keep this Overleaf template in sync with the canonical source on
% GitHub, but it's recommended that you obtain the template directly from
% GitHub to ensure that you are using the latest version.

\documentclass[final]{beamer}

% ====================
% Packages
% ====================

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[orientation=portrait,size=a0,scale=1.4]{beamerposter}
\usetheme{gemini}
\usecolortheme{gemini}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\usepackage[justification=centering]{caption}
\usepackage{amsmath, stackengine}
\usepackage{amssymb}
\usepackage{xcolor}
\usepackage[backend=biber, style=numeric-comp, url=false, doi=false, eprint=false, maxnames=2, isbn=false, giveninits=true, hyperref]{biblatex}
\usepackage{subfig}
\usepackage{wrapfig}

\addbibresource[datatype=bibtex]{poster.bib}
\AtBeginBibliography{\small}
\AtEveryBibitem{\clearfield{pages}} 
\AtEveryBibitem{\clearfield{title}}

% ====================
% Lengths
% ====================

% If you have N columns, choose \sepwidth and \colwidth such that
% (N+1)*\sepwidth + N*\colwidth = \paperwidth
\newlength{\sepwidth}
\newlength{\colwidth}
\setlength{\sepwidth}{0.025\paperwidth}
\setlength{\colwidth}{0.462\paperwidth}

\newcommand{\separatorcolumn}{\begin{column}{\sepwidth}\end{column}}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\renewcommand{\thempfootnote}{\fnsymbol{footnote}}

\definecolor{blueHMM}{HTML}{1071e5}
\definecolor{redHMM}{HTML}{e81313}
\definecolor{greenHMM}{HTML}{54c45e}
\definecolor{purpleHMM}{HTML}{ba23f6}
\definecolor{yellowHMM}{HTML}{fcce14}

% ====================
% Title
% ====================

\title{Infer selection and demography from genomic \hspace{10cm} time series}

\author{Paul Bunel \and Mathieu Uhl \and Miguel de Navascués \and Simon Boitard \and Bertrand Servin}

% \institute[shortinst]{\inst{1} CBGP, Université de Montpellier, CIRAD, INRAE, IRD, Institut Agro Montpellier, Montpellier, France \samelineand \inst{2} GenPhySE, Université de Toulouse, INRAE, INPT, Castanet-Tolosan, France \samelineand \inst{3} CEFE, CNRS, Montpellier, France}

% ====================
% Footer (optional)
% ====================

\footercontent{
    \includegraphics[height=0.02\paperheight]{Logo-INRAE_Transparent.svg.png}
    \hspace{0.03\paperwidth}
    \includegraphics[height=0.025\paperheight]{cbgp_logo.png}
    \hspace{0.03\paperwidth}
    \includegraphics[height=0.025\paperheight]{genphyse-dark.png}
    \hspace{0.03\paperwidth}
    \includegraphics[height=0.025\paperheight]{OC-1706-instit-logo-rectangle-quadri-150x150-72dpi.png}
    \hspace{0.03\paperwidth}
    \includegraphics[height=0.025\paperheight]{logo_um_2022_rouge_RVB-768x280.png}
    \hspace{0.03\paperwidth}
    \includegraphics[height=0.025\paperheight]{BiodivOc-cmjn-blanc.png}
    \hspace{0.03\paperwidth}
    \includegraphics[height=0.025\paperheight]{logo-pepr-agroeconum.jpg}
}
% (can be left out to remove footer)

% ====================
% Logo (optional)
% ====================

% use this to include logos on the left and/or right side of the header:
% \logoright{\includegraphics[height=7cm]{logo1.pdf}}
% \logoleft{\includegraphics[height=7cm]{logo2.pdf}}

% ====================
% Body
% ====================

\begin{document}

\begin{frame}[t]
\begin{columns}[t]
\separatorcolumn

\begin{column}{\colwidth}

  \begin{alertblock}{Context}
    \begin{itemize}
        \item Genomic time series = allelic frequencies trajectories in a population.
        \item \textbf{Population size ($N$)} and \textbf{selection intensity} on a locus \textbf{($s$)} are two parameters shaping the evolution of its allele frequency $\Rightarrow$ we aim to \textbf{infer} those parameters from \textbf{observed trajectories}.
        \item Challenge: frequencies in samples $\neq$ true frequencies in population
    \end{itemize}

    \begin{figure}
      \centering
      \includegraphics[width=0.8\colwidth]{allele_freq.pdf}
      \caption{Simulation of an allele frequency trajectory. \textcolor{redHMM}{Red points} are frequencies in sample collected at specific generations, \textcolor{blueHMM}{blue triangles} are the true frequencies in the population at the same generations.}
    \end{figure}
  \end{alertblock}

  \begin{block}{Hidden Markov Models (HMM)}
    We use \textbf{Hidden Markov Models (HMM)} to modelize trajectories. \textbf{HMM} are statistical models where the modelized system is supposed to contain a sequence of observed data that depend on hidden parameters. We define:
    
    \vspace*{-0.5\baselineskip}\begin{itemize}
        \item \textcolor{blueHMM}{$X$, \textbf{hidden parameters}} $\rightarrow$ allelic frequencies in the population ;
        \item \textcolor{redHMM}{$Y$, \textbf{observed data}} $\rightarrow$ allele count in samples ;
        \item \textcolor{greenHMM}{$Q$, \textbf{transition matrix}} $\rightarrow$ a matrix representing the probabilities to go from one hidden state to another: $P(\textcolor{blueHMM}{X_{i+1}} = x_{i+1} | \textcolor{blueHMM}{X_i} = x_i)$ ;
        \item \textcolor{purpleHMM}{$g$, \textbf{emission matrix}} $\rightarrow$ the probability to observe \textcolor{redHMM}{$Y$} knowing \textcolor{blueHMM}{$X$}: $P(\textcolor{redHMM}{Y_i} = y_i | \textcolor{blueHMM}{X_i} = x_i)$, here a binomial distribution ;
        \item \textcolor{yellowHMM}{$\nu$, \textbf{start vector}} $\rightarrow$ the distribution of the hidden parameter at the first observation (referred later as $x_0$), here an uniform distribution between 0 and 1
    \end{itemize}\vspace*{-0.5\baselineskip}

  \begin{figure}
      \centering
      \includegraphics[width=0.7\colwidth]{hmm.pdf}
      \caption{A time series modelized by an \textbf{HMM}}
  \end{figure}
  \end{block}
  
  \vspace*{-0.8\baselineskip}
  
  \begin{block}{Modelize transitions}
    \begin{wrapfigure}{r}{0.4\colwidth}
        \centering
        \includegraphics[width=0.35\colwidth]{beta_with_spikes_trimed.jpg}
        \caption{\textbf{BwS} and \textbf{WF} comparison \cite{tataru2016}. Lines represent the discretized distribution after 60 generations, for $N = 200$, $s = 0.005$, $x_0 = 0.5$.}
    \end{wrapfigure}
        The \textbf{transition matrix} \textcolor{greenHMM}{$Q$} can be built with the \textbf{Wright-Fisher (WF)} model. However, it implies to have a matrix of dimensions $N \times N$, which raises computational issues when $N$ is large. Instead, we use an approximation with the \textbf{Beta with Spikes (BwS)} \cite{tataru2015} distribution, which combines a continuous (Beta) density with discrete fixation probabilities at frequencies 0 and 1. \textbf{BwS} was pointed out by Paris et al. \cite{paris2019} to be promising, and allows to run accurate estimations for a large range of demographic and selective parameters.
  \end{block}
  
  \begin{block}{References}

    % \nocite{*}
    \printbibliography

  \end{block}

  \end{column}
  \separatorcolumn
  \begin{column}{\colwidth}

  \begin{block}{Compute likelihood}
    \begin{itemize}
        \item The \textbf{forward algorithm} allows to compute the likelihood of observing data with our model: $\mathcal{L}(\textcolor{redHMM}{Y} ; \textcolor{greenHMM}{Q}, \textcolor{purpleHMM}{g}, \textcolor{yellowHMM}{\nu}) = P(\textcolor{redHMM}{Y_1} = y_1, \dots, \textcolor{redHMM}{Y_n} = y_n | \textcolor{greenHMM}{Q}, \textcolor{purpleHMM}{g}, \textcolor{yellowHMM}{\nu})$.
        \item In our application, parameters of interest are $N$ and $s$, which influence only \textcolor{greenHMM}{$Q$} since they are parameters of the \textbf{WF} / \textbf{BwS} distributions: $\mathcal{L}(\textcolor{redHMM}{Y} ; N, s) = P(\textcolor{redHMM}{Y_1} = y_1, \dots, \textcolor{redHMM}{Y_n} = y_n | \textcolor{greenHMM}{Q(}N, s\textcolor{greenHMM}{)}, \textcolor{purpleHMM}{g}, \textcolor{yellowHMM}{\nu})$
        \item We look for a \textbf{maximum likelihood estimator (MLE)} of $N$ by computing the likelihood across loci for a grid of value of $N$ and assuming $s = 0$: $\hat{N} \leftarrow max\bigl[\prod_{\ell} \mathcal{L}(\textcolor{redHMM}{Y_{\ell}} ; N_i, s_{\ell} = 0)\bigr]$, with $\ell$ representing a locus
        \item Then use $\hat{N}$ to infer an \textbf{MLE} on $s_{\ell}$: $\hat{s_{\ell}} \leftarrow max\bigl[\mathcal{L}(\textcolor{redHMM}{Y_{\ell}} ; N = \hat{N}, s_{\ell, i})\bigr]$
    \end{itemize}
  \end{block}

  \begin{exampleblock}{SelNeTime accuracy evaluation}
    \textbf{SelNeTime}\footnotemark \cite{selnetime_preprint} is our python tool implementing algorithms using \textbf{HMM} and \textbf{BwS} approximation to infer on selection and demography as explained above. Here is some examples of figures displaying \textbf{SelNeTime}'s performance in various scenarios. While there is a good accuracy for selection when $\hat{N}$ is supposed correct \textbf{(a)}, and for population size when there is null or weak selection \textbf{(b)} ; we observe a bias in $\hat{N}$ when $Ns$ is strong \textbf{(c)} (i.e. selection intensity and population size both have high values). This bias is caused by the assumption made by \textbf{SelNeTime} that $s = 0$, as it disappeared when we gave the true value of $s$ to \textbf{SelNeTime} \textbf{(d)}.
    
    \begin{figure}
        \centering
        \subfloat[]{\includegraphics[width=0.49\colwidth]{S_with_N.pdf}}
        \subfloat[]{\includegraphics[width=0.49\colwidth]{Ne_over_pi0.pdf}}\\
        \subfloat[]{\includegraphics[width=0.49\colwidth]{N_without_S.pdf}}
        \subfloat[]{\includegraphics[width=0.49\colwidth]{N_with_S.pdf}}
        \caption{\textbf{SelNeTime}'s estimation of $N$ and $s$ on datasets simulated under a \textbf{WF} model, with various parameters. All loci were simulated with the same selection intensity for each dataset. \textbf{(a)} Estimations of $s$ with the true $N$ given in parameter, datasets simulated with different values of $s$, $N$ and $dt$ (sampling time). \textbf{(b)} Estimations of $N$ on datasets simulated with different values of $N$ and $x_0$ ($s = 0$). \textbf{(c, d)} Estimations of $N$ on datasets simulated with different values of $s$ and $N$ ($dt$ = 10, $x_0 = 0.5$).}
    \end{figure}
  \end{exampleblock}
  \footnotetext{\small{\textbf{SelNeTime} package: \url{https://pypi.org/project/selnetime/}}}
\end{column}

\separatorcolumn
\end{columns}
\end{frame}

\end{document}
