<figure><img src="image_1.png" /></figure>

HAL
open science

# Infer selection and demography from genomic time series

Paul Bunel, Mathieu Uhl, Miguel de Navascués, Simon Boitard, Bertrand Servin

► To cite this version:

Paul Bunel, Mathieu Uhl, Miguel de Navascués, Simon Boitard, Bertrand Servin. Infer selection and demography from genomic time series. Séminaire des doctorants du département de Génétique Animale de l'INRAE, May 2025, Bordeaux, France. hal-05111581

HAL Id: hal-05111581

https://hal.science/hal-05111581v1

Submitted on 13 Jun 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

Public Domain
# Infer selection and demography from genomic time series

Paul Bunel

Mathieu Uhl

Miguel de Navascués

Simon Boitard

Bertrand Servin

## Context

* Genomic time series = allelic frequencies trajectories in a population.
* **Population size (N)** and **selection intensity** on a locus (s) are two parameters shaping the evolution of its allele frequency ⇒ we aim to **infer** those parameters from **observed trajectories**.
* Challenge: frequencies in samples ≠ true frequencies in population

<figure><img src="image_2.png" /><figcaption>Figure 1. Simulation of an allele frequency trajectory. Red points are frequencies in sample collected at specific generations, blue triangles are the true frequencies in the population at the same generations.</figcaption></figure>

## Hidden Markov Models (HMM)

We use **Hidden Markov Models (HMM)** to modelize trajectories. HMM are statistical models where the modelized system is supposed to contain a sequence of observed data that depend on hidden parameters. We define:

* **X**, **hidden parameters** → allelic frequencies in the population;

* **Y**, **observed data** → allele count in samples;

* **Q**, **transition matrix** → a matrix representing the probabilities to go from one hidden state to another: $P(X_{i+1} = x_{i+1} | X_i = x_i)$;

* **g**, **emission matrix** → the probability to observe **Y** knowing **X**: $P(Y_i = y_i | X_i = x_i)$, here a binomial distribution;

* **v**, **start vector** → the distribution of the hidden parameter at the first observation (referred later as $x_1$), here an uniform distribution between 0 and 1

<figure><img src="image_3.png" /><figcaption>Figure 2. A time series modelized by an HMM</figcaption></figure>

## Modelize transitions

The transition matrix **Q** can be built with the Wright-Fisher (WF) model. However, it implies to have a matrix of dimensions *N* × *N*, which raises computational issues when *N* is large. Instead, we use an approximation with the **Beta with Spikes (BwS)** [2] distribution, which combines a continuous (Beta) density with discrete fixation probabilities at frequencies 0 and 1. **BwS** was pointed out by Paris et al. [1] to be promising, and allows to run accurate estimations for a large range of demographic and selective parameters.

<figure><img src="image_4.png" /><figcaption>Figure 3. **BwS** and **WF** comparison [3]. Lines represent the discretized distribution after 60 generations, for *N* = 200, *s* = 0.005, $x_1$ = 0.5.</figcaption></figure>

## References

[1] C. Paris et al. In: *G3 Genes|Genomes|Genetics* 9.12 (Dec. 2019).

[2] P. Tataru et al. In: *Genetics* 201.3 (Aug. 2015).

[3] P. Tataru et al. In: *Systematic Biology* 66.1 (Aug. 2016).

[4] M. Uhl et al. In: *bioRxiv* (2024).

## Compute likelihood

* The **forward algorithm** allows to compute the likelihood of observing data with our model: $\mathcal{L}(Y; Q, g, v) = P(Y_1 = y_1, \dots, Y_n = y_n | Q, g, v)$.

* In our application, parameters of interest are *N* and *s*, which influence only *Q* since they are parameters of the **WF** / **BwS** distributions: $\mathcal{L}(Y; N, s) = P(Y | Q(N, s), g, v)$

* We look for a **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[\prod_l \mathcal{L}(Y_l; N, s_l = 0)]$, with *l* representing a locus

* Then use $\hat{N}$ to infer an **MLE** on $s_l$: $\hat{s}_l \leftarrow \max[\mathcal{L}(Y_l; N = \hat{N}, s_l)]$

## SelNeTime accuracy evaluation

SelNeTime* [4] is our python tool implementing algorithms using **HMM** and **BwS** approximation to infer on selection and demography as explained above. Here is some examples of figures displaying SelNeTime's performance in various scenarios. While there is a good accuracy for selection when $\hat{N}$ is supposed correct (a), and for population size when there is null or weak selection (b); we observe a bias in $\hat{N}$ when $N_s$ is strong (c) (i.e. selection intensity and population size both have high values). This bias is caused by the assumption made by SelNeTime that *s* = 0, as it disappeared when we gave the true value of *s* to SelNeTime (d).

<figure><img src="image_5.png" /></figure>

<figure><img src="image_6.png" /><figcaption>Figure 4. SelNeTime's estimation of *N* and *s* on datasets simulated under a **WF** model, with various parameters. All loci were simulated with the same selection intensity for each dataset. (a) Estimations of *s* with the true *N* given in parameter, datasets simulated with different values of *s*, *N* and *dt* (sampling time). (b) Estimations of *N* on datasets simulated with different values of *N* and $x_1$ (*s* = 0). (c, d) Estimations of *N* on datasets simulated with different values of *s* and *N* (*dt* = 10, $x_1$ = 0.5).</figcaption></figure>

<footnote>*SelNeTime* package: https://pypi.org/project/selnetime/</footnote>