DOI: 10.5061/dryad.p8cz8w9xd
title: Range expansion can promote the evolution of plastic generalism in coarse-grained landscapes

description: Phenotypic plasticity is one way for organisms to deal with variable
 environments through generalism. However, plasticity is not found
 universally and its evolution may be constrained by costs and other
 limitations such as complexity: the need for multiple mutational steps
 before the adaptation is realized. Theory predicts that greater
 experienced heterogeneity, such as organisms may encounter when spatial
 heterogeneity is fine-grained relative to dispersal, should favor the
 evolution of a broader niche. Here we tested this prediction via
 simulation. We found that, contrary to classical predictions,
 coarse-grained landscapes can be the most favorable for the evolution of
 plasticity, but only when populations encountered those landscapes through
 range expansion. During these range expansions, coarse-grained landscapes
 select for each step in the complex mutational pathway to plastic
 generalism by blocking the dispersal of specialists. These circumstances
 provide ecological opportunities for innovative mutations that change the
 niche. Our results indicate a new mechanism by which range expansion and
 spatially structured landscapes interact to shape evolution, and reveal
 that the environments in which a complex adaptation has the highest
 fitness may not be the most favorable for its evolution.
description: This dataset comes from a computer simulation study and is
 generated from code that is also available in this repository.
description: # Range expansion can promote the evolution of plastic generalism in
 coarse-grained landscapes [DOI: 10.5061/dryad.p8cz8w9xd]() This dataset
 was created for a study of how the grain size of clustering of
 environmental heterogeneity could alter how like plastic generalism is to
 evolve using computer simulation models. All of the code for simulations
 was written in R and consists of two main experiments. In one experiment
 (using the “clustering simulation script.R”), random landscapes were
 generated with variable levels of clustering to evaluate how the
 likelihood of plastic generalism arising on landscapes with a variety of
 clustering levels changed when populations were already located across the
 landscape vs. when they were expanding through the landscape. This
 experiment showed that in settled populations, the likelihood of plastic
 generalism evolving decreased with increasing grain size of clusters.
 However, in expanding populations coarse-grained landscapes led to plastic
 generalism being much more likely to evolve. This surprising result led to
 the second experiment. In the second experiment (using “stripes simulation
 script.R”), landscapes with alternating stripes of different types of
 environments were generated to evaluate if the increase in evolution of
 plastic generalism in coarse-grained landscapes was because alternating
 blocks of the environment created impassable barriers that forced
 incremental evolutionary steps. Stripe widths varied from thin stripes
 that organisms could disperse across to wide stripes that they had to
 evolve to be able to use to cross. In one treatment, populations were
 initially placed so that expansion would happen parallel to stripes while
 in the other they were placed so expansion would happen perpendicular to
 stripes. These different treatments were designed so that the parallel one
 (“with the grain” or wg) showed how the population would evolve when
 alternating environments were not an explicit barrier to expansion and the
 perpendicular one (“against the grain” or atg) would show how the
 population would evolve when alternating environment were a barrier to
 expansion. This treatment showed that alternating blocks of environments
 being a barrier to range expansion was the component that increased the
 likelihood of plastic generalism evolving, with perpendicular treatments
 leading to many more replicates evolving plastic generalism. This
 repository contains the code used to run simulations and generate results
 (all written in R), the code used to generate figures shown in the paper
 associated with this repository (all written in R), and the results from
 simulations (as text files and jpegs). The code used for the simulations
 is all written in R, and can be opened in R or in any text editing window.
 It can be run in R. For the first experiment, the code used to generate
 the simulations is in the file titled “clustering_simulation_script.R”.
 This file uses functions located in the file
 “functions_for_clustering_sims.R” by calling the file as source code on
 the 79th line. The pathname for the source code will need to be changed to
 reflect the files location on each individual users computer to access it.
 At the beginning of the script (line 2) there is also a line to set the
 working directory to direct the data files that are output to the
 appropriate location on a users computer. Lines 15-36 allow setting
 parameters that did not vary in the results presented in the accompanying
 paper, line 39 allows you to set the number of replicates. Line 43 allows
 users to alter whether a set of replicates will have the range expansion
 (“re”) or no range expansion (“nr”) treatment, and line 49 allows users to
 set the grain size of landscape for a treatment (with eligible options
 shown in lines 121-130). Once these parameters are set, the entire script
 can be run at once and will output the number of replicates set in the
 treatment that has been set. Results from the first experiment can be
 found in the zipped files that start are named with the format
 “theta_#_treatment.zip”, where # can be 0.5, 2, 6, 24, 43, 90, 175, or 370
 and treatment can be re or nr. Each zipped file is a folder that contains
 several text files for each replicate containing genotype information and
 a jpeg of the end state of the landscape in that replicate. These data
 files were processed using “Analysis_of_data.R” script to create summary
 files that indicate whether plastic generalism arose in each replicate and
 when it arose. These summary files can be found in the zipped file
 “clusters_gen_emerge.zip” which is a folder of text files. These summary
 files were used to create figure 2 in the accompanying paper using the
 script “Figure_2.R” to generate images in R. Figure 3 was also generated
 using the data from this experiment in R, using the script “Figure_3.R”.
 This used summaries of the number of steps to generalism that can be found
 in each treatment’s individual zipped folder and randomly selected
 replicates that evolved generalism to plot trajectories of, drawing from
 the data in individual treatments folders. Supplemental figure 2 was a
 similar figure to figure 3, and used the same pool of data and a similar
 method located in the “Supplemental_figure_2.R” script. For the second
 experiment, the code used to generate the simulations is in the file
 titled “stripes_simulation_script.R”. This file is an R script that also
 uses the same source file as the first experiment, and has similar
 locations of changeable parameters. This script generated data located in
 zipped files titled “treatment_#.zip”, where treatment can be “wg” or
 “atg”, and # can be 3, 5, 7, 10, 11, 12, 13, 14, 15, 20, 30, or 40. Each
 of these zipped files is a folder containing several text files for each
 treatment and a jpeg for the state of the population at the end of the
 replicate. These results were also processed using the
 “Analysis_of_data.R” script, and the summary text files can be found in
 the zipped folder “stripes_gen_emerge.zip”. These data were used to
 generate figure 4 in the accompanying paper, using the script
 “Figure_4.R”. In addition to the figures derived directly from results,
 there is a script called “Figure_1.R” which is a script that generates a
 conceptual figure that was in the methods. There is also a script called
 “SF1_making_blank_landscapes.R” that generated the first supplemental
 figure, which is a series of blank landscape subsections that allows
 readers to get a sense of what different levels of clustering actually
 look like.