DOI: 10.5061/dryad.37pvmcvzg
title: Code from: Evolution of phenotypic plasticity owing to migration

description: Phenotypic plasticity enables organisms to produce better-suited
 phenotypes when the environment changes, enhancing fitness under adverse
 conditions. Yet responding to environmental cues may provide little use in
 a constant environment, where organisms already express optimal
 phenotypes. The forces that sustain plasticity and account for its
 widespread presence, thus, remain unclear, as plasticity must remain
 advantageous to persist. Although typically associated with changing
 environments, maintenance of plasticity requires generational turnover
 such that parents and offspring regularly encounter different conditions.
 Here, we demonstrate that even low number of migrants between locally
 adapted populations, in constant environments, can promote the emergence
 and persistence of phenotypic plasticity even when plasticity is costly,
 never associated with the fittest genotype, and independent of its genetic
 architecture. We support this conclusion by exploring the parameter space
 of a two-locus, two-deme model using stochastic simulations and analytical
 approximations. We derive analytical conditions under which plasticity is
 adaptively maintained as a function of selection strength, migration, and
 fitness trade-offs. These findings reshape our understanding of the
 evolutionary origins of plasticity and offer insight into how maladaptive
 traits can invade adapted populations in stable environments.
description: # Code from: Evolution of phenotypic plasticity owing to migration Dataset
 DOI: [10.5061/dryad.37pvmcvzg](https://doi.org/10.5061/dryad.37pvmcvzg) ##
 Description of the data and file structure This C program simulates
 evolutionary dynamics at a plasticity locus following the introduction of
 a single plasticity-conferring allele (*M*) into one of two locally
 adapted demes that exchange migrants, as described in Gulisija and
 Newberry (2025). At the structural locus, alleles *a* and *b* encode
 locally adapted, non-plastic phenotypes in demes A and B. At the modifier
 locus, alleles *m* and *M* determine whether plastic environmental
 responses occur, with specified benefits and costs. Input parameters for
 deme A are provided in the **pars** file: 1.    Selection coefficient
 against non-plastic immigrants (sel, *s*~A~) 2.    Plasticity benefit
 (pla, *p*~A~) 3.    Plasticity cost (cost, *c*~A~) \ A sample *pars* file
 includes *s*~A~ = 0.01, *p*~A~ = 0.01, and *c*~A~ = 0.0. Parameters for
 deme B are symmetric unless modified on **line 39**. Population sizes
 (N1=N~A~, N2=N~B~), maximum simulation time (TIME), and replicate number
 (REPS) are defined on **line 30**. Burn-in duration (migration–selection
 equilibrium without plasticity) is set on **line 31**, recombination rate
 between the two loci on **line 40**, and reciprocal migration values are
 specified on **lines 50–75**. Output is written to **output**, including:
 population sizes, migration rate, recombination rate, selection
 coefficients, plasticity benefits and costs, cumulative heterozygosity at
 the plasticity locus (where values &gt; 4 suggest balancing selection),
 fixation and loss times, fixation probability, equilibrium check at
 burn-in (difference in frequency of *a* over 100 generation before
 introduction of plasticity), with the number of polymorphic runs and
 replicates. To run, please compile using: `gcc -Wall 'exe_file'
 -o 'Migrant\ Plasticity.c' -lm ` , or `cc 'Migrant\
 Plasticity.c' -lm -o 'exe_file'` The output file (output)
 reports the main input parameters as well as the heterozygosity and
 fixation probabilities of the plasticity-conferring allele. ### Files and
 variables #### File: Migrant_Plasticity.c **Description:** Main program -
 forward-in-time evolution at the plasticity locus in a subdivided
 population with two locally adapted demes. #### File: pars
 **Description:** Sample input file, with suggested selection, plasticity,
 and cost coefficients. ## Code/software The code is written in C and need
 a C compiler, such as can freely available within Xcode. ## Access
 information Other publicly accessible locations of the data: *
 [https://www.unm.edu/~dgulisija/index.html](https://www.unm.edu/~dgulisija/index.html) Data was derived from the following sources: * NA