Host-Parasite Coevolution in Continuous Space Leads to Variation in Local Adaptation Across Spatial Scales
Description
This repository contains code to reproduce figures and some results associated with the manuscript titled "Host-Parasite Coevolution in Continuous Space Leads to Variation in Local Adaptation Across Spatial Scales".
FIGURE 1:
Figure 1 can be reproduced using the Julia script <fig1-defs.jl>, as illustrated by the Julia script <fig1.jl>. These scripts have been tested using Julia version 1.8 and depend on the Julia packages:
- Distributions
- SpecialFunctions
- FFTW
- LinearAlgebra
- DataFrames
- CSV
- RCall
- Interpolations
- Optim
- Parameters
Additionally, for plotting, the Julia scripts above depend on R (tested on version 4.3.0) and the R packages:
- grid
- gridExtra
- viridis
- ggplot2
The default parameters result in a low resolution version of Figure 1. To produce Figure 1 at the same resolution as in the main text, insert p.n = 600 on line 6 of <fig1.jl>. Before attempting this, please note that such resolution requires over 250Gb of memory. Also note that Figure 1 cannot be reproduced exactly because the algorithm used is stochastic.
To learn more about Julia, including how to install it, please visit the documentation: https://docs.julialang.org/en/v1/
To learn more about R, see: https://www.r-project.org/about.html
Figure 2:
Figure 2 can be reproduced using the R script <fig2.R>. This script has been tested on R version 4.3.0 and requires the R packages:
- geoR
- ggplot2
- viridis
- grid
- gridExtra
Again, the default parameters of the script result in a low resolution version compared to the main text. Increasing the resolution is possible by adjusting the num_pts parameter on line 7, but the amount of memory required is rather large for even modest resolutions.
Figure 3:
Figure 3 can be reproduced by first running the Python script <fig3.py> followed by the R script <fig3.R>. These scripts were tested for Python version 3.10.6 and R version 4.3.0.
Figure 4:
Figure 4 can be reproduced by running the R script <fig4.R>, making sure that the files <fig4a-vals.csv>, <fig4a-pars.csv>, <fig4b-vals.csv>, <fig4b-pars.csv>, and <xcov-xrng.csv> are all in the working directory. The data stored in these csv files were generated using the Python script <fig4.py>, which produces the file <fig4.csv> containing measurements of parasite local adaptation across a range of spatial distances and many combinations of model parameters. We chose the two most exaggerated examples from this file to form the csv files used to create Figure 4. These scripts were tested for Python version 3.10.6 and R version 4.3.0.
Power Spectra:
Analytical expressions for the power spectra of our model (equations S.11a-S.11b in Supplementary Material section S3) can reproduced by running the Mathematica notebook <freq-sp.nb>. This notebook was written using Mathematica version 13.2.
Co-Located Interspecific Covariance:
The expression for the co-located interspecific covariance (equation S.13 in Supplementary Material section S3) can be reproduced by running the Mathematica notebook <Chp0.nb>. This notebook was written using Mathematica version 13.2.
Files
fig4a-pars.csv
Files
(23.3 kB)
Name | Size | Download all |
---|---|---|
md5:b4e372c8e913a43d2c4a96528ab7329f
|
5.6 kB | Download |
md5:592dea20657440acac40e6bcde37cf0c
|
164 Bytes | Download |
md5:322f1e52f038eca63c367d6272413aa6
|
1.6 kB | Download |
md5:6e22a49d6204af355c3fa0fab7eced13
|
1.9 kB | Download |
md5:e80e0fc1e63c09c1d441587ce6f6d313
|
399 Bytes | Download |
md5:82d8994ea9269a0e3d37053ed7e4b3dd
|
2.1 kB | Download |
md5:7dd254d0a01a5c7cb6ff990b4ec26162
|
1.3 kB | Download |
md5:5b7298fc3477a408a02f9711e091ec8a
|
250 Bytes | Preview Download |
md5:38298fe60ee02d3287e00c4733c5e63f
|
3.3 kB | Preview Download |
md5:94b354d8f2664736dc9658546b355272
|
250 Bytes | Preview Download |
md5:3be2f43c420949c4faaaa6d21f489fb3
|
3.2 kB | Preview Download |
md5:357f4c908361e38dead4273709f19228
|
3.2 kB | Preview Download |