DOI: 10.5061/dryad.2z34tmps2
title: Data and code from: Variety is the spice of life: nongenetic variation in life histories influences population growth and evolvability

description: Individual vital rates, such as mortality and birth rates, are key
 determinants of lifetime reproductive success, and variability in these
 rates shapes population dynamics. Previous studies have found that this
 vital rate heterogeneity can influence demographic properties including
 population growth rates. However, the explicit effects of the amount of
 variation within and the covariance between vital rates that can also vary
 throughout the lifespan on population growth remains unknown. Here, we
 explore the analytical consequences of nongenetic heterogeneity on
 long-term population growth rates and rates of evolution by modifying
 traditional age-structured population projection matrices to incorporate
 variation among individual vital rates. The model allows vital rates to be
 permanent throughout life ("fixed condition”) or to change over the
 lifespan ("dynamic condition”). We reduce the complexity associated
 with adding individual heterogeneity to age-structured models through a
 novel application of matrix collapsing ("phenotypic
 collapsing"), showing how to collapse in a manner that preserves the
 asymptotic and transient dynamics of the original matrix. The main
 conclusion is that nongenetic individual heterogeneity can strongly impact
 the long-term growth rate and rates of evolution. The magnitude and sign
 of this impact depends heavily on how the heterogeneity covaries across
 the lifespan of an organism. Our results emphasize that nongenetic
 variation cannot simply be viewed as random noise, but rather that it has
 consistent, predictable effects on fitness and evolvability.
description: These files contain all R code used for performing simulations
 and generating plots in: "Variety is the spice of life: nongenetic
 variation in life histories influences population growth and
 evolvability" (Forsythe et al. 2024, Journal of Evolutionary
 Biology). The code is provided as RMarkdown (.RMD) files. The .RDS files
 contain the ouput data from the simulations that were used to generate the
 plots. The README.md provides information about each file and the packages
 required (for code files). 
description: # Data and code from: Variety is the spice of life: Nongenetic variation
 in life histories influences population growth and evolvability Code
 prepared for the following article: Forsythe, A.B., S.P. Otto, W.A.
 Nelson, and T. Day. 2024. Variety is the spice of life: nongenetic
 variation in life histories influences population growth and evolvability.
 Journal of Evoluionary Biology. All code performed in R (version 4.3.1, R
 Core Team 2023). There are 3 code files (prepared as R Markdown files) and
 4 data files (prepared as .RDS files) for this manuscript: 1\. "Code
 for Genotype Simulations - Fixed Condition.Rmd" -This file provides
 the code used to simulate genotypes with nongenetic heterogeneity that is
 permanent throughout life ("fixed condition") -Packages used:
 mvtnorm (version 1.2-4), Matrix (version 1.6-5) - for multivariate normal
 distributions and sparse matrices, respectively -The output of this code
 produces the data contained in two .RDS files:
 "FixedG1000P4Juv1.RDS" and "FixedG1000P4Juv10.RDS" 2\.
 "Code for Genotype Simulations - Uncorrelated Condition.Rmd"
 -This file provides the code used to simulate genotypes with nongenetic
 heterogeneity that allows vital rates to change randomly throughout life
 ("uncorrelated condition") -Packages used: mvtnorm (version
 1.2-4), Matrix (version 1.6-5) - for multivariate normal distributions and
 sparse matrices, respectively -The output of this code produces the data
 contained in two .RDS files: "UncorrelatedG1000P4Juv1.RDS" and
 "UncorrelatedG1000P4Juv10.RDS" 3\. "Code for Genotype
 Simulations - Plots.Rmd" -RUN LAST -This file provides the code to
 make the figures (main text and supplementary), using the data from the
 simulations in the above two files. -Packages used: ggplot2 (version
 3.4.4), ggpubr (version 0.6.0) 4\. The 4 data (.RDS) files contain the
 simulation outputs that were used to generate the plots in the main text
 and supplemental PDF of the manuscript. There are 3 columns in each .RDS
 file: 1) "fits" - the fitness of a genotype, 2)
 "scalar" - the ratio of nongenetic:genetic variation for that
 genotype, 3) "type" - the genetic covariance structure, followed
 by the nongenetic covariance (0 = none, + = positive covariance, - =
 negative covariance) Citations: Douglas Bates, Martin Maechler, Mikael
 Jagan. (2024). Matrix: Sparse and Dense Matrix Classes and Methods. R
 package version 1.6-5. URL
 [https://CRAN.R-project.org/package=Matrix](https://CRAN.R-project.org/package=Matrix) Alan Genz, Frank Bretz, Tetsuhisa Miwa, Xuefei Mi, Friedrich Leisch, Fabian Scheipl, Bjoern Bornkamp, Martin Maechler, Torsten Hothorn. (2023). mvtnorm: Multivariate Normal and t Distributions. R package version 1.2-4. URL [http://CRAN.R-project.org/package=mvtnorm](http://CRAN.R-project.org/package=mvtnorm) Alboukadel Kassambara. (2023). ggpubr: 'ggplot2' Based Publication Ready Plots. R package version 0.6.0. URL [https://CRAN.R-project.org/package=ggpubr](https://CRAN.R-project.org/package=ggpubr) R Core Team. 2023. R: a language and environment for statistical computing. R Foundation for Statistical Computing, Vienna. H. Wickham. ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York, 2016.