DOI: 10.5061/dryad.m0cfxpp3z
title: Data and code from: Predicting population genetic change in an autocorrelated random environment: insights from a large automated experiment

description: Most natural environments exhibit a substantial component of random
 variation, with a degree of temporal autocorrelation that defines the
 color of environmental noise. Such environmental fluctuations cause random
 fluctuations in natural selection, affecting the predictability of
 evolution. But despite long-standing theoretical interest for population
 genetics in stochastic environments, there is a dearth of empirical
 estimation of underlying parameters of this theory. More importantly, it
 is still an open question whether evolution in fluctuating environments
 can be predicted indirectly using simpler measures, which combine
 environmental time series with population estimates in constant
 environments. Here we address these questions by resorting to an automated
 experimental evolution approach. We used a liquid-handling robot to expose
 over a hundred lines of the micro-alga Dunaliella
 salina to randomly fluctuating salinity over a continuous range,
 with controlled mean, variance, and autocorrelation. We then tracked the
 frequencies of two competing strains through amplicon sequencing of a
 nuclear and choloroplastic barcode sequences. We show that the magnitude
 of environmental fluctuations (variance), but also their predictability
 (autocorrelation), had large impacts on the average selection coefficient.
 The stochastic variance in frequency change, which quantifies randomness
 in population genetics, was substantially higher in a fluctuating
 environment. The reaction norm of selection coefficients against constant
 salinity yielded accurate predictions for the mean selection coefficient
 in a fluctuating environment. This selection reaction norm was in turn
 well predicted by environmental tolerance curves, with population growth
 rate against salinity. However, both the selection reaction norm and
 tolerance curves underestimated  the variance in selection caused
 by random environmental fluctuations. Overall, our results provide
 exceptional insights into the prospects for understanding and predicting
 genetic evolution in randomly fluctuating environments.
description: We exposed a mixture of two <i>Dunaliella salina</i>
 strains to fluctuating vs constant salinity (strains CCAP  19/12 : A and
 CCAP 19/15 : C), and tracked their frequencies through time by amplicon
 sequencing of the ITS2 and a chloroplast locus. Genomic DNA from 1071
 samples was extracted using the Nucleospin® plant II
 (Macherey-Nagel). In order to make efficient use of the
 sequencing data, we reduced all chloroplast and ITS2 reads to short
 haplotypes made of a succession of few linked SNPs that individually
 maximized the <i>F<sub>ST</sub></i> among pure,
 reference cultures of A and C. We estimated fluctuating selection by
 tracking the dynamics of the frequency <i>p</i> of strain C
 through time, by combining two sources of genetic information, from the
 ITS2 and the chloroplast locus. We considered that the frequencies
 measured at the ITS2 and chloroplast loci were two observations (with
 error) of a true, unobserved strain frequency <i>p</i>. This
 corresponds to a state-space model, and we wrote its explicit likelihood
 function in C++, and optimized it using the TMB package in R
 (v.3.5.2)
description: Users can perform the analysis by running the R script
 (frequency_dynamics_analysis.R) after the installation of all
 the<br> packages mentioned in "Packages and
 functions". This folder contains: 
 <br>  - The sequences dataset divided into the following
 directories:<br> Reference (ITS2 and Chloro), Calibration (ITS2 and
 Chloro), ITS2 and Chloro. <br> They must be extracted from .zip
 before use. "Reference" and
 "Calibration" folders contain the sequences from pure and mix
 populations of the back-up A and C strains <br> used in the
 experiment. "Chloro" and "ITS2" contain the sequences
 from the evolutionary experiments.<br> Each file corresponds to one
 population measured at a specific time. It is obtained from a fasta
 file <br> (after quality check) and gives the total number of copies
 per individual sequences. <br> - one  data set
 giving the salinities used in the stochastic treatments, and the
 associated growth rates estimated in a previous paper (Rescan et al.
 2020) estimationR_gamma.csv
 <br> - one  data set giving the salinities used in the
 constant treatments, and the associated growth rates estimated in a
 previous paper (Rescan et al. 2020)
 estimationR_DD.csv <br> - 3 C++ scripts
 that must be compiled and run with the R TMB package: 
 * logistic_regression.cpp : computes the negative loglikelihood
 of the allele C frequency dynamics.<br> The fixed slope gives the
 mean selection coefficient, as a function of environmental mean,
 variance,<br> autocorrelation and predictability (autocorrelation²).
 The random slope gives the selection variance<br> and is fitted as a
 function of the environmental variance treated as a factor: 0 or
 1.<br> The code returns estimations for all fixed parameters (fixed
 term) and the estimated allele C frequency <br> in each population
 and at each time point (random terms). *
 regression_all_line.cpp : computes the negative loglikelihood for the
 dynamics of each line in constant<br> salinities. The mean selection
 coefficient depends on each line and its variance (random term)
 is <br> generated by micro environmental variations or demographic
 stochasticity. * regression_salinity.cpp : computes the
 negative loglikelihood for the regression between frequency
 changes<br> and salinity (current and past), initial frequency and
 density during one transfer. <br> - 1 R
 script:  frequency_dynamics_analysis.R: Builds the data
 table including all ITS2 and chloroplast sequences.<br> Analyses the
 allele C dynamics. Estimates selection mean and variance in constant and
 stochastic <br> autocorrelated environments. Analyses the selection
 response to previous and current salinity.<br> Builds the paper
 Figures.<br>