/two_locus_selection_moments

Two-locus selection moments (scripts to create figures in manuscript)

Primary LanguagePython

two_locus_selection_moments

This repository contains the code associated with "A numerical framework for genetic hitchhiking in populations of variable size" by Eric Friedlander and Matthias Steinrücken. A brief guide to this repository is as follows:

  • momlink - This folder contains the code implementing the method outlined in the manuscript.
    • ode.py contains code which defines the TwoLocMomOde object which computes the time derivative of the moment ODEs and stores the state of the moments. This object is the main way to interact with the moments.
    • integrator.py implements a Runge-Kutta 4(5) ODE solver which is modified to ensure the solution is a probability measure.
    • help_funcs.py contains helpful functions and objects that do things like interpolation and downsampling of moments.
    • demography.py contains code necessary for defining and working with populations of variable size.
  • paperImages - This folder contains the code necessary to generate the data and figures in the manuscript. We highly recommend that any of the code other than that in auxImages but run in parallel using a cluster. While all of it will run on a computer it will take a prohibitively long amount of time.
    • auxImages contains the scripts betaPlots.py and demographicModel.py which generate Figures 1 and 2 in the main text, respectively.
    • fixedImages contains the code necessary to generate Figures 4-7 in the main text, Figures S1-S3 in the supplement, and the data used in Tables 2 and 3 in the main text. In order to generate these just run the snakemake.snakefile script. For completeness, the script will generate several figures not included in the manuscript and will also create many intermediate files in the data and ode_output folders. The code to recreate Tables 2 and 3 is included in a Jupyter notebook stored in the analysis folder of the main repo. run_snakemake.sh contains code for running the code in parallel on a cluster which is highly recommended. This will need to be adjusted (along with the cluster/cluster.json depending on the cluster being used). In order to run this code one will need to download and install Snakemake and simuPOP.
    • stationaryImages contains the code to generate Figures 8 and 9 in the main text, and Figures S4-S7 in the supplement . The images can be generated by running the snakemake file in the same way as in the fixed Images folder. Once again the code in this folder requires simuPOP.
    • slimImages contains the code to generate Figure 10 in the main text, and Figures S8-S10 in the supplement. The images can be generated by running the snakemake file in the same way as in the fixed Images folder. This time one will need to have SLiM installed in order to run the code.
  • analysis - This folder contains the Jupyter notebook performanceAnalysis.ipybn necessary to generate the numbers in Tables 2 and 3, as well as Figure 3 in the main text. In order to run the notebook make sure that odePerformance_all.csv is in the analysis folder. This file will be generated after running the snakefile in paperImages/fixedImages and be stored in paperImages/fixedImages/data.
  • JackKnife.nb - This is a Mathematica notebook which defines moments in terms of a second order polynomial. This is necessary for implementing the JackKnife method proposed in Jouganous et al. (2017) and Ragsdale and Gravel (2019).