Code from: Pathogens pull hardest in the coevolutionary arms-race to determine innate age-specific transmission biases
Data files
Sep 17, 2026 version files 2.63 MB
-
figures_main.ipynb
767.82 KB
-
figures_supplementary.ipynb
1.83 MB
-
model_tools.py
6.32 KB
-
model.py
6.42 KB
-
raster.py
2.20 KB
-
rasters.json
6.88 KB
-
README.md
1.67 KB
Abstract
Across a wide range of species, juveniles are more susceptible to pathogenic infection than their adult conspecifics, often driving epidemic spread. Theory has shown that high innate juvenile susceptibility can be favoured by natural selection given a trade-off with other host fitness traits such as reproduction, facilitating pathogen persistence. However, most research on age-specific infection has focused solely on host evolutionary dynamics, and the effect of coevolution on juvenile infection rates has not been explored. Here, we developed a coevolutionary adaptive dynamics model, loosely based on a model plant disease system, to investigate age-specific infectivity and contrast the outcome of coevolution with host evolution and pathogen evolution alone. We found strong differences in the evolutionary dynamics of hosts and pathogens in the absence of coevolution. While host evolution often favoured genotypes with intermediate levels of juvenile and adult resistance, pathogen evolution selected for extreme specialists. When hosts and pathogens were allowed to coevolve, the dynamics more closely resembled the pathogen dynamics; pathogens rapidly evolved to specialize on infecting a specific age class, and this drove reciprocal specialization in host resistance. Furthermore, we found that the form of specialist favoured by selection can depend on the starting host and pathogen genotypes, but only with coevolution. Our results underscore the importance of understanding both the host and pathogen contributions to age-specific infection rates.
Dataset DOI: 10.5061/dryad.51c59zwrc
Description of the data and file structure
This repository contains the code used to generate the data referenced in our manuscript. The code used to make each figure is also included. For the manuscript, all code was run using Python 3.16 and requires the following libraries: numpy, matplotlib, scipy, tqdm, PIL, and pickle.
The models themselves and the basic tools for them are contained in the model.py file. The code for running particular analyses and generating figures is contained in figures_main.ipynb and figures_supplementary.ipynb.
model.py contains the main model class.
Modelis the primary model. With this class, you can define a model, define its parameters, and run a simulation.
model_tools.py contains helper classes and functions for analyzing models and rasters.
RasterAnalysisis a class that handles simulation rasters and generates data that can be used to create figures.ModelAnalysisis a class that can be used to create individual simulations and generate summary statistics.make_imageCreates an image raster based on two-dimensional simulation data.
raster.pyRuns a two-dimensional series of simulations, with variation across two parameters. This method runs simulation arrays defined in rasters.json
figures_main.ipynb and is used to generate all figures that appear in the main text.
figures_supplementary.ipynb is used to generate all figures that appear in the supplementary materials.
