DOI: 10.5061/dryad.0k6djhb41
title: Larval and adult traits coevolve in response to asymmetric coastal currents to shape marine dispersal kernels

description: Dispersal emerges as an outcome of organismal traits and external
 forcings. However, it remains unclear how the emergent dispersal kernel
 evolves as a by-product of selection on the underlying traits. This
 question is particularly compelling in coastal marine systems where
 dispersal is tied to development and reproduction, and where directional
 currents bias larval dispersal downstream causing selection for retention.
 We modelled the dynamics of a metapopulation along a finite coastline
 using an integral projection model and adaptive dynamics to understand how
 asymmetric coastal currents influence the evolution of larval (pelagic
 larval duration) and adult (spawning frequency) life history traits, which
 indirectly shape the evolution of marine dispersal kernels. Selection
 induced by alongshore currents favors the release of larvae over multiple
 time periods, allowing long pelagic larval durations and long-distance
 dispersal to be maintained in marine life cycles in situations where they
 were previously predicted to be selected against. Two evolutionary stable
 strategies emerged: one with a long pelagic larval duration and many
 spawning events resulting in a dispersal kernel with a larger mean and
 variance, and another with a short pelagic larval duration and few
 spawning events resulting in a dispersal kernel with a smaller mean and
 variance. Our theory shows how coastal ocean flows are important agents of
 selection that can generate multiple, often co-occurring, evolutionary
 outcomes for marine life history traits that affect dispersal.
description: Data sets were generated using provided code for simulations in
 the R language. Full details are available in associated
 manuscript.
description: Program can be run using R. A C++ file is included that can be
 implemented in R using the package "RCPP". Using this function
 requires having a C++ compiler on your computer, however the code can
 still be run (although at a slower speed) in the absence of the C++
 function.
description: README
 ============================================================================ Larval and adult traits coevolve in response to asymmetric coastal currents to shape marine dispersal kernels By: Jimmy H. Peniston and Scott C. Burgess June 2023 This is the README file for the code and data associated with manuscript "Larval and adult traits coevolve in response to coastal oceanography to shape marine dispersal kernels". A full description of the models can be found in the manuscript. This ReadMe file explains what files are included here and how to run the code. ============================================================================ ============================================================================ 1. GENERAL INFORMATION: ============================================================================ A. Disclaimer This program is free software: you can redistribute it and/or modify it in any way you wish. ============================================================================ B. Contact Information: This code was primarily written by James (Jimmy) Peniston, please feel free to contact them with any questions regarding the workings of this model or adapting the code for a different use. Contact information: jimmpen@gmail.com ============================================================================ C. Summary of study: The goal of this study was to explore the effects of ocean currents on the evolution of larval (pelagic larval duration) and adult traits (number of spawning events) in coastal marine organisms. In the study, we develop an integral projection model structured by both space and time and investigate trait evolution using an adaptive dynamics framework. Most of our conclusions rely on deterministic simulations, but we also tested some of our assumption using stochastic simulations. Analyses were run using R version 3.6.3 (Holding the Windsock) ============================================================================2. FILES: === A. Deterministic simulation code The results and conclusions of our manuscript come primarily come from the code presented in the file "dispersal\_in\_flow\_code.R". This file provides code for running adaptive dynamics simulations of our integral projection model and givens instructions for how to generate the data to make the figures presented in the manuscript. It all provides the code used to create the figures themselves. ============================================================================ B. RCPP functions The file "Rcpp\_functions\_dispersal\_in\_flow.cpp" is a C++ file that contains C++ code for a calculating the dispersal kernel. This function can then be used in R implement using the package "RCPP". Using this code requires that you have a C++ compiler installed on your computer. Which C++ compiler you need will depend on your operating system. We use the g++ compiler which is available for free. Instructions for installing the g++ compiler on a mac can be found on the webpage: http://www-scf.usc.edu/\~csci104/20142/installation/gccmac.html And instructions for installing on a Windows systems can be found on the webpage: http://www.codebind.com/cprogramming/install-mingw-windows-10-gcc/ If you do not wish to install a C++ compiler on your computer, you can still run the code using the code provided. It will just run much slower. ============================================================================ D. Stochastic simulation code Code for the stochastic simulations is found in "stochastic\_simulation\_code.R". A description of this model can be found in the appendix of the manuscript. ============================================================================ D. Data files The csv files are contain the data used to produce the figures presented in the paper. Code for generating these C++ files can be found in "dispersal\_in\_flow\_code.R". TPLD = Pelagic Larval Duration *** File name: "flow\_tpld\_data\_1000.csv" Description: evolutionarily stable TPLD values when s=1000 U = Flow rate U8 = Output of "calcESSup" function when Nspawn = 8 D8 = Output of "calcESSdown" function when Nspawn = 8 S8 = Output of "calcESSsep" function when Nspawn = 8 U4 = Output of "calcESSup" function when Nspawn = 4 D4 = Output of "calcESSdown" function when Nspawn = 4 S4 = Output of "calcESSsep" function when Nspawn = 4 U2 = Output of "calcESSup" function when Nspawn = 2 D2 = Output of "calcESSdown" function when Nspawn = 2 S2 = Output of "calcESSsep" function when Nspawn = 2 U1 = Output of "calcESSup" function when Nspawn = 1 D1 = Output of "calcESSdown" function when Nspawn = 1 S1 = Output of "calcESSsep" function when Nspawn = 1 NA = Not Applicable. There is no unstable equilibrium given by "calcESSsep" if "calcESSup" and "calcESSdown" output same value *** File name: "flow\_tpld\_data\_3000.csv" Description: evolutionarily stable TPLD values when s=3000 U = Flow rate U8 = Output of "calcESSup" function when Nspawn = 8 D8 = Output of "calcESSdown" function when Nspawn = 8 S8 = Output of "calcESSsep" function when Nspawn = 8 U4 = Output of "calcESSup" function when Nspawn = 4 D4 = Output of "calcESSdown" function when Nspawn = 4 S4 = Output of "calcESSsep" function when Nspawn = 4 U2 = Output of "calcESSup" function when Nspawn = 2 D2 = Output of "calcESSdown" function when Nspawn = 2 S2 = Output of "calcESSsep" function when Nspawn = 2 U1 = Output of "calcESSup" function when Nspawn = 1 D1 = Output of "calcESSdown" function when Nspawn = 1 S1 = Output of "calcESSsep" function when Nspawn = 1 NA = Not Applicable. There is no unstable equilibrium given by "calcESSsep" if "calcESSup" and "calcESSdown" output same value *** File name: "flow\_Nspawn\_data.csv" Description: evolutionary stable Nspawn values when Am=0.1 U = Flow rate Tpld\_10\_1000 = Output of "NsESSup" when PLD = 10 and SiA = 1000 Tpld\_20\_1000 = Output of "NsESSup" when PLD = 20 and SiA = 1000 Tpld\_30\_1000 = Output of "NsESSup" when PLD = 30 and SiA = 1000 Tpld\_40\_1000 = Output of "NsESSup" when PLD = 40 and SiA = 1000 Tpld\_10\_3000 = Output of "NsESSup" when PLD = 10 and SiA = 3000 Tpld\_20\_3000 = Output of "NsESSup" when PLD = 20 and SiA = 3000 Tpld\_30\_3000 = Output of "NsESSup" when PLD = 30 and SiA = 3000 Tpld\_40\_3000 = Output of "NsESSup" when PLD = 40 and SiA = 3000 *** File name: "flow\_Nspawn\_data\_Am0.csv" Description: evolutionary stable Nspawn values when Am=0 U = Flow rate Tpld\_4\_1000 = Output of "NsESSup" when PLD = 4 and SiA = 1000 Tpld\_10\_1000 = Output of "NsESSup" when PLD = 10 and SiA = 1000 Tpld\_40\_1000 = Output of "NsESSup" when PLD = 40 and SiA = 1000 Tpld\_4\_3000 = Output of "NsESSup" when PLD = 4 and SiA = 3000 Tpld\_10\_3000 = Output of "NsESSup" when PLD = 10 and SiA = 3000 Tpld\_40\_3000 = Output of "NsESSup" when PLD = 40 and SiA = 3000 *** File name: "flow\_Nspawn\_SiA\_data.csv" Description: evolutionarily stable Nspawn for different values of interannual variation U = Flow rate SiA\_0\_T10 = Output of "NsESSup" when PLD = 10 and SiA = 0 SiA\_3000\_T10 = Output of "NsESSup" when PLD = 10 and SiA = 3000 SiA\_6000\_T10 = Output of "NsESSup" when PLD = 10 and SiA = 6000 SiA\_0\_T40 = Output of "NsESSup" when PLD = 40 and SiA = 0 SiA\_1000\_T40 = Output of "NsESSup" when PLD = 40 and SiA = 1000 SiA\_3000\_T40 = Output of "NsESSup" when PLD = 40 and SiA = 3000 SiA\_6000\_T40 = Output of "NsESSup" when PLD = 40 and SiA = 6000 *** File name: "fig3\_.2\_data.csv" Description: Pairwise invasion data used in figure 3A. This is the output of the for loop of the Figure 3 section of the code *** File name: "fig3\_1.2\_data.csv" Description: Pairwise invasion data used in figure 3B. This is the output of the for loop of the Figure 3 section of the code *** File name: "coevolution\_data\_1000.csv" Description: evolutionarily stable TPLD and Nspawn values when s=1000 U = Flow rate TPLD\_low = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 TPLD\_high = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 N\_low = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 N\_high = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 *** File name: "coevolution\_data\_3000.csv" Description: evolutionarily stable TPLD and Nspawn values when s=3000 U = Flow rate TPLD\_low = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 TPLD\_high = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 N\_low = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 N\_high = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 *** File name: "Am\_.1\_coevolve.csv" Description: evolutionarily stable TPLD and Nspawn values when Am = 0.1 TPLD\_low = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 TPLD\_high = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 N\_low = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 N\_high = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 *** File name: "Am\_.25\_coevolve.csv" Description: evolutionarily stable TPLD and Nspawn values when Am = 0.25 TPLD\_low = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 TPLD\_high = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 N\_low = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 N\_high = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 *** File name: "Am\_.4\_coevolve.csv" Description: evolutionarily stable TPLD and Nspawn values when Am = 0.4 TPLD\_low = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 TPLD\_high = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 N\_low = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 N\_high = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 *** File name: "g\_.10\_coevolve.csv" Description: evolutionarily stable TPLD and Nspawn values when g = 0.10 TPLD\_low = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 TPLD\_high = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 N\_low = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 N\_high = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 *** File name: "g\_.14\_coevolve.csv" Description: evolutionarily stable TPLD and Nspawn values when g = 0.14 TPLD\_low = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 TPLD\_high = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 N\_low = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 N\_high = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 *** File name: "g\_.18\_coevolve.csv" Description: evolutionarily stable TPLD and Nspawn values when g = 0.18 TPLD\_low = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 TPLD\_high = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 N\_low = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 N\_high = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 *** File name: "m\_6\_coevolve.csv" Description: evolutionarily stable TPLD and Nspawn values when m = 5 x 10^-6 TPLD\_low = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 TPLD\_high = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 N\_low = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 N\_high = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 *** File name: "m\_7\_coevolve.csv" Description: evolutionarily stable TPLD and Nspawn values when m = 5 x 10^-7 TPLD\_low = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 TPLD\_high = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 N\_low = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 N\_high = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 *** File name: "m\_8\_coevolve.csv" Description: evolutionarily stable TPLD and Nspawn values when m = 5 x 10^-8 TPLD\_low = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 TPLD\_high = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 N\_low = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 N\_high = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 *** File name: "cL\_10\_coevolve.csv" Description: evolutionarily stable TPLD and Nspawn values when coastline length = 10km TPLD\_low = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 TPLD\_high = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 N\_low = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 N\_high = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 *** File name: "cL\_100\_coevolve.csv" Description: evolutionarily stable TPLD and Nspawn values when coastline length = 100km TPLD\_low = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 TPLD\_high = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 N\_low = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 N\_high = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 *** File name: "cL\_1000\_coevolve.csv" Description: evolutionarily stable TPLD and Nspawn values when coastline length = 1000km TPLD\_low = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 TPLD\_high = TPLD output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10 N\_low = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 4 and Nspawn value is 1 N\_high = Nspawn output of "calcCoevolveESS\_TF" when initial TPLD value is 40 and Nspawn value is 10