Online Resource 2: Commented SLiM simulation scripts

Article: From Possibility to Probability: Population-Genetic Accessibility of Enzyme Specialization After Gene Duplication
Journal: Journal of Molecular Evolution
Author: Jordan A. Dowell
Affiliation: Department of Biological Sciences, Louisiana State University, Baton Rouge, Louisiana 70803, USA
Correspondence:
Archive version: 1.0.0 (2 November 2026)

Purpose

Promiscuous enzymes can perform more than one reaction, but selection that improves one activity may reduce another. Gene duplication can resolve this catalytic conflict only if a new copy persists long enough for the two copies to diverge. These simulations separate that process into two population-genetic transitions: access to a retained two-copy state and specialization after retention.

This electronic supplement contains the exact two-reaction SLiM model used in the paper, the exact portable base-R launch and validation scripts, the frozen production design grids, and a small example design. The canonical source files are preserved byte-for-byte. MODEL_GUIDE.md provides the deeper annotation needed to connect each code section to the biological questions addressed in the manuscript.

Contents

Path Purpose
model/duplication_invasion.slim Canonical SLiM 4.0.1 model for ancestral adaptation, duplicate introduction, invasion, retention, specialization, dosage, and mutation-fate tracking.
MODEL_GUIDE.md Commented map of the model, launcher, parameters, phases, outcomes, and production contrasts.
scripts/run_invasion_row.R Exact portable base-R launcher for one design row, used by array workflows.
scripts/run_invasion_grid.R Exact restart-safe base-R launcher for a complete design grid, with optional local parallel workers.
scripts/check_invasion_run.R Exact run-completeness and error-term check.
config/ Frozen production CSVs used to construct the ancestral, retained-duplication, single-origin, and dosage experiments.
examples/example_grid.csv Five short demonstration rows: one ancestral-state save, two retained-duplication treatments, and two single-origin treatments.
examples/run_examples.sh Runs the example rows sequentially and stores outputs below example_results/.
examples/EXPECTED_OUTPUTS.md Describes the generated folders and columns without treating the small demonstration as a biological experiment.
FILE_MANIFEST.tsv File purpose, paper component, byte count, and SHA-256 checksum.
VERSION.txt Archive version and provenance.
LICENSE MIT license for the scripts in this archive.

Requirements

  • SLiM 4.0.1. Later SLiM releases may work, but 4.0.1 is the version used for the reported simulations.
  • R 4.6.0. The launchers use base R only.
  • A POSIX shell for run_examples.sh.

The example runner searches for slim and Rscript on PATH. Their locations can be overridden without editing a file:

SLIM_BIN=/path/to/slim RSCRIPT_BIN=/path/to/Rscript sh examples/run_examples.sh

Quick test

From the unpacked top-level directory, run:

sh examples/run_examples.sh

The first row adapts and saves a small ancestral population. The next four rows load that same state and compare compensated with additive dosage in two experiments:

  1. Retained duplication: the duplication marker is introduced on every chromosome (duplication_intro_copies = 2N). This experiment asks what evolves after access to the two-copy state is imposed.
  2. Single origin: one duplication marker is introduced (duplication_intro_copies = 1). This experiment asks whether a rare new copy survives long enough to establish and specialize.

The example uses a small population and short phases only to verify installation and file generation. It is not expected to reproduce the publication estimates.

State-bank prerequisite

Rows with load_ancestral_state = TRUE require a state bank created by the corresponding paper1_ancestral_state_bank_*.csv grid. Each state has two required files with the same identifier:

  • <ancestral_state_id>.slimbin, the binary SLiM population state; and
  • <ancestral_state_id>.effects.csv, the catalytic effects associated with every segregating mutation.

The two files must be placed together in <output-root>/ancestral_states/. A .slimbin file alone is insufficient because the catalytic effects stored as simulation values must be restored from the sidecar.

Biological design

Ancestral phase

The population begins with one enzyme copy and adapts under selection on two required catalytic activities. Each catalytic mutation changes both activities. The correlation between those changes is determined by relationship:

  • strong_antagonism: improving one reaction usually reduces the other.
  • weak_antagonism: the conflict remains, but mutational effects are less strongly opposed.
  • unconstrained: effects on the two reactions are independent.
  • weak_synergism: improvements in one reaction tend to improve the other.
  • strong_synergism: mutational effects on the two reactions are strongly aligned.

The paper used independently adapted ancestral populations and condition-specific burn-in lengths established by ensemble stationarity analyses. Saved population files and mutation-effect sidecars allowed matched post-duplication treatments to begin from the same evolved state.

Duplicate introduction

At duplication_intro_generation = burnin_generations + 1, the model copies the catalytic state of the chromosome receiving the duplication marker. A value of one for duplication_intro_copies represents one new origin. A value of 2N creates the retained-duplication contrast by placing the marker on every chromosome.

Dosage treatments

  • compensated: total catalytic output is averaged across present copies. The new copy therefore provides no immediate output increase.
  • additive: every gene copy contributes its full activity. An otherwise identical heterozygous duplication begins with nominal activity of 3/2 relative to the ancestral diploid, whereas a duplication on both homologs begins with 4/2.

These treatments bracket two mechanistic possibilities. They do not imply that all biological duplicates are completely compensated or completely additive.

Catalytic boundaries and selection

The hard boundary excludes catalytic states outside the declared feasible region. The soft boundary applies a continuous penalty whose strength is controlled by soft_boundary_strength. selection_strength scales the conversion from relative catalytic performance to reproductive success. The manuscript evaluates how these settings change both ancestral dynamics and post-duplication accessibility.

Recorded outcomes

The model records:

  • establishment and near-fixation of the duplicate;
  • loss of the duplicate;
  • first and persistent complementary specialization;
  • time from duplicate introduction to each outcome;
  • catalytic activities, fitness, specialization, promiscuity, and boundary violation through time; and
  • optional mutation origins, realized selection effects, and mutation fates.

Persistent specialization requires both sufficient duplicate frequency and specialization above the declared threshold for persistence_generations. This distinguishes transient catalytic separation from an outcome that remains present across multiple event checks.

Production settings used in the paper

The production design used a population size of 1,000; per-position mutation rates of 10^-7 and 10^-6; mutation-effect standard deviation of 0.025; recombination rate of 10^-8; hard and soft boundaries (soft-boundary strength 100); selection-strength multipliers of 0.5, 1, and 2; zero direct duplication cost; and all five catalytic relationships. Condition-specific ancestral phases ranged from 10N to 60N generations, with 80N used for identified ridge-evolving treatments. Post-duplication phases were 10N generations, with a 20N duration sensitivity for ridge treatments.

Production estimates should be reproduced from the frozen design manifests and random seeds described in the article’s data and code availability statement. example_grid.csv intentionally uses smaller values and is only an execution check.

Production result sets that must remain distinct

The primary retained-duplication estimate of 56/300 combines three compensated grids: paper1_retained_stationary_r20.csv, paper1_retained_ridge_60N_r20.csv, and paper1_retained_active_add30_r50.csv. This experiment uses the validated condition-specific ancestral durations selected for the primary analysis.

The matched dosage control of 61/1,140 uses paper1_retained_stationary_r20.csv, paper1_retained_ridge_80N_r20.csv, and paper1_retained_active_add30_r50.csv, expanded across the full matched dosage design. It is paired with paper1_dosage_additive_retained.csv. The 60N primary ridge treatment and 80N dosage-matched ridge treatment answer different declared comparisons and must not be pooled.

The single-origin compensated analysis combines paper1_single_origin_r20.csv with paper1_single_origin_expansion_add4740.csv; the additive matched treatment is in paper1_dosage_additive_single_origin.csv.

CSV interface

The launcher requires these columns:

run_set, relationship, replicate, seed, population_size, generations, output_every, event_check_every, mutation_rate, mutation_step_sd, recombination_rate, base_activity, selection_strength, burnin_generations, post_duplication_generations, duplication_intro_generation, duplication_intro_copies, duplication_cost, establishment_frequency, fixation_frequency, specialization_threshold, persistence_generations, and target_fitness_fraction.

Optional columns in the example activate boundary and dosage treatments, ancestral-state reuse, early stopping, and origin identifiers. Mutation-fate tracking requires the additional fields checked in scripts/run_invasion_row.R.

Reproducibility safeguards

  • The model stops when incompatible phase lengths, boundary modes, dosage modes, or state-file options are supplied.
  • The launcher blocks production-pattern grid names unless a stationarity-calibration identifier is present.
  • Saved ancestral states are paired with a sidecar containing mutation effects, which SLiM population files do not otherwise preserve.
  • The same seed and ancestral state can be used across dosage treatments for exact paired contrasts.
  • Each run writes a log and the launcher fails if trajectory, event, or summary output is missing or empty.
  • FILE_MANIFEST.tsv provides checksums for archive-integrity checks.

Citation and reuse

Please cite the associated article when using this model. The scripts are released under the MIT license in LICENSE. The simulation design is documented in the manuscript and Online Resource 1; this archive provides the executable implementation. File-level SHA-256 values in FILE_MANIFEST.tsv can be used to verify that the canonical model, runners, and production grids have not changed.