DOI: 10.5061/dryad.2fqz6132n
title: Data and code from: Longevity hinders evolutionary rescue through slower growth but not necessarily slower adaptation

description: ''Evolutionary rescue'' is the process by which
 populations experiencing severe environmental change avoid extinction
 through adaptation. Applying theory to natural populations and
 conservation targets requires investigating the effects of several
 life-history traits, including longevity. Theory demonstrates that
 longevity can inhibit rescue through slower phenotypic adaptation when
 selection acts once per lifetime, leaving open questions about
 longevity's effects when individuals face multiple rounds of
 selection. We developed a model integrating evolutionary rescue with
 concepts from life-history theory, particularly the trade-off where
 increasing longevity produces slower population growth rates. Our model
 varies longevity by modifying the balance of survival and reproduction,
 with selection acting on survival allowing for adaptation within cohorts.
 We used this model to study life-history strategies with different
 longevities responding to sudden environmental change. Simulations
 demonstrated that higher longevity resulted in more time at low density
 and increased extinction. With perfect trait heritability, rates of
 adaptation were nearly identical across longevities. But at lower
 heritabilities, repeated selection under longevity decoupled mean
 population phenotypes and genotypes, producing a transient phase of rapid
 phenotypic change. Our results demonstrate that longevity impedes rescue
 by slowing population growth but does not always slow rates of adaptation.
description: # Data and code from: Longevity hinders evolutionary rescue through slower
 growth but not necessarily slower adaptation All simulation code (in
 language R, using packages dplyr, tidyr, mc2, and parallel for code and
 ggplot2 and cowplot for figures) and output (in .csv form) for paper
 "Longevity hinders evolutionary rescue through slower growth but not
 necessarily slower adaptation". Contents include: * Functions for
 running simulations * Scripts to run simulated experiments (including
 outputs) * Scripts for validating simulation outputs (including figures) *
 Scripts for generating figures in manuscripts ## Main simulation analysis
 output files File `sim_results_m1_allsizes_n.csv`: Mean and variance of
 population size for each of 27 parameter combinations over 101 time steps
 for main batch of simulations. One row corresponds to a summary of one
 time step within a parameter combination. This file was generated by
 script `run_sims/model1_popsize_extinctions.R` and used to generate
 Figures 2 and 3 in main text. Fields: * `s.max` - maximum survival value
 ($\widehat{s}$ in paper) * `var.z` - initial population-level phenotypic
 variance ($\gamma^2$ in paper) * `h2` - heritability ($h^2$ in paper) *
 `t` - time step * `nbar` - mean of population size across simulation
 trials with given parameter combination in time step * `nvar` - variance
 of population size across simulation trials with given parameter
 combination in time step * `psrv` - proportion of surviving populations
 (i.e., with size &gt; 0) within parameter combination at the given time
 step * `nn` - number of trials used to estimate mean and variance File
 `sim_results_m1_disaggregated_n.csv`: Simulation output (recording size
 only) for 20 trials individual trials per parameter combination over 101
 time steps (or time of extinction, whichever occurs first) for each of 27
 parameter combinations in "main" batch of simulations. One row
 corresponds to one time step within one simulation trial. This file was
 generated by script `run_sims/model1_popsize_extinctions.R` and used to
 generate Figure 2 in main text. Fields: * `t` - time step * `n` -
 population size in time step * `trial` - simulation trial number * `s.max`
 - maximum survival value ($\widehat{s}$ in paper) * `var.z` - phenotypic
 variance ($\gamma^2$ in paper) * `h2` - heritability ($h^2$ in paper) File
 `sim_results_m1_phtype.csv`: Mean and variance of each of three phenotypic
 components (breeding value, environmental component of phenotype, and
 phenotype) for 200 simulated population over time for nine parameter
 combinations over 51 time steps. One row corresponds to one time step
 within one simulation trial. This file was generated by script
 `run_sims/model1_phenotypic_components.R` and used to generate Figures 4
 and 6 in main text and Fig. S28 in Supporting Info. Fields: * `t` - time
 step * `n` - population size in time step (*note: not used in analysis*) *
 `bbar` - mean breeding value in population within time step ($\bar{b}$ in
 paper) * `bvar` - variance of breeding values in population within time
 step ($\gamma^2_a$ in paper) * `bvarw` - *not used in analysis* * `ebar` -
 mean environmental component of phenotype in population within time step
 ($\bar{e}$ in paper) * `evar` - variance of environmental component of
 phenotype in population within time step ($\gamma^2_e$ in paper) * `evarw`
 - *not used in analysis* * `zbar` - mean phenotype in population within
 time step ($\bar{z}$ in paper) * `zvar` - variance of phenotypes in
 population within time step ($\gamma^2$ in paper) * `zvarw` - *not used in
 analysis* * `trial` - simulation trial number * `s.max` - maximum survival
 value ($\widehat{s}$ in paper) * `h2` - heritability ($h^2$ in paper) File
 `sim_results_m1_ages.csv`: Mean and variance of each of three phenotypic
 components (breeding value, environmental component of phenotype, and
 phenotype) and size of each cohort (age class) for 200 simulated
 population over time for nine parameter combinations over 51 time steps.
 One row corresponds to one cohort within time step within one simulation
 trial. This file was generated by script `run_sims/model1_age_structure.R`
 and used to generate Figure 5 in main text and Fig. S27 in Supporting
 Info. Fields: * `t` - time step * `age` - age of cohort (denoted $k$ in
 paper) * `n` - cohort size in time step * `r` - number of offspring sired
 by cohort (*note: not used in analysis*) * `bbar` - mean breeding value in
 cohort within time step ($\bar{b}$ in paper) (*note: not used in
 analysis*) * `bvar` - variance of breeding values in cohort within time
 step ($\gamma^2_{a,k}$ in paper) (*note: not used in analysis*) * `ebar` -
 mean environmental component of phenotype in cohort within time step
 ($\bar{e}_k$ in paper) (*note: not used in analysis*) * `evar` - variance
 of environmental component of phenotype in cohort within time step
 ($\gamma^2_{e,k}$ in paper) (*note: not used in analysis*) * `zbar` - mean
 phenotype in cohort within timestep ($\bar{z}_k$ in paper) (*note: not
 used in analysis*) * `zvar` - variance of phenotypes in cohort within time
 step ($\gamma^2_k$ in paper) (*note: not used in analysis*) * `trial` -
 simulation trial number * `s.max` - maximum survival value ($\widehat{s}$
 in paper) * `h2` - heritability ($h^2$ in paper) ## Additional simulations
 ### Equal-$lambda$ simulations These additional simulations were run with
 all life-history strategies having equal maximum per-time step growth
 rates rather than maximum intrinsic fitness equivalent (as in main
 simulations). Files are named and largely structured similarly to the main
 output files described above but with the following exceptions: Files
 `sim_results_m1_allsizes_n_equal-lambda.csv` and
 `sim_results_m1_disaggregated_n_equal-lambda.csv`: This file includes
 summaries of only 500 trials per combination. These were created by script
 `run_sims/equal_lambda/model1_popsize_extinctions_lambda.R` and were used
 to make Figs. S17 and S18 in Supporting Information. Files
 `sim_results_m1_phenotypic_components_equal-lambda.csv` and
 `sim_results_m1_ages_equal-lambda.csv`: These files recorded the
 equilibrium population size (`lstar`, equivalent to $\lambda^*$ in main
 text) of each life-history strategy. The phenotypic component file
 includes the `s.max` used in the treatment, but by mistake the age
 structure file does not. The longevity treatments are assigned using the
 following `R` code: ``` n.all = mutate( n.all, long = cut(lstar, breaks =
 c(0, 1.185, 1.19, Inf), labels = c('low', 'medium',
 'high')) ) ``` These files were generated, respectively, by
 scripts `run_sims/equal_lambda/model1_phenotypic_components_lambda.R` and
 `run_sims/equal_lambda/model1_age_structure_lambda.R` and were used to
 make Figures S20-22. ### Equal-$\gamma^2_0$ simulations These additional
 simulations were run with all life-history strategies having equal
 phenotypic variance in newborn cohorts rather than population-level
 phenotypic variance equivalent (as in main simulations). Files are named
 and largely structured similarly to the main output files described above
 but with the following exceptions: Files
 `sim_results_m1_allsizes_n_equalg20.csv` and
 `sim_results_m1_disaggregated_n_equalg20.csv`: Note that here the variable
 `var.z` corresponds to the phenotypic variance in a newborn cohort (rather
 than at the population level). These files were created by the script
 `run_sims/model1_popsize_extinctions_equal_g20.R` and were used to make
 Figs. S23 and S24 in Supporting Information. File
 `sim_results_m1_phtype_equalg20.csv`: This file was created by the script
 `run_sims/model1_phenotpyic_components_equal_g20.R` and was used to make
 Figures S25 and S26 in Supporting Information. ### Note on variances
 "missing" data (`NA` in fields) All variances reported in these
 files are sample variances rather than population variances. `NA` appears
 in some files in columns reporting variances (`bvar`, `evar`, and `zvar`)
 where the sample size is one (i.e., `n` is equal to `1` for the
 corresponding row in the file). This is because variance reported is
 sample variance, under which conditions variance is undefined and the `R`
 function `var()` function returns `NA`. ## Scripts All code to re-create
 analysis, including but not limited to data files presented here, are
 publicly available on GitHub at the address
 [https://github.com/melbourne-lab/evo_rescue_longevity](https://github.com/melbourne-lab/evo_rescue_longevity). Please contact [scottwatsonnordstrom@gmail.com](mailto:scottwatsonnordstrom@gmail.com) with questions.