Skip to content
Kamil S. Jaron edited this page May 21, 2018 · 16 revisions

Conjunction

is simulator of secondary contact based on Fisher's junction representation of genome admixture written in C++.

Install

The simulator is not using external libraries, just standard C and C++. Therefore, writing to terminal in the folder of the project

make

should compile the simulator. The binary of the simulator is now prepared to use. If you want the simulator to be installed in your system, move binary to one of folders included in environmental variable PATH, for instance

sudo make install

or alternatively add path to simulator in PATH (you have to replace <path_to_simulator> by the actual path to conjunction)

export PATH=$PATH:<path_to_simulator>

Usage

Input parameters are read from the “setting.txt” file. The filename of the setting is the only parameter that conjunction binary takes, if no parameter is provided conjunction will try to load file setting.txt.

conjunction [setting.txt] 1> sim_summary.out 2> sim_log.err

The log is printed to standard error stream (sim_log.err), the summary of simulation is printed to standard output stream (sim_summary.out). Detailed outputs can be saved to files according, check Simulation output for details.

The output can be parsed in R using package ConjunctionStats. The package is far from being perfect, especially estimation of width of hybrid zones does not work as desired, but it can be very helpful to load simulation output to R.

Several use cases and sanity tests can be found in repository ConjunctionExamples. Some of the examples are simulations with known analytical results, therefore it serves as verification of the correct implementation of Conjunction.

Principles

The initial situation of the simulation is a secondary contact of two distinct taxa with only endogenous factors acting against hybrids. The contact has three different spatial models. The simulation consists of three repetitively executed steps considered as one generation:

  1. migration
  2. selection of parents
  3. reproduction.

These three steps are executed repeatedly until the desired number of generations is reached. The output is printed/saved always after the third step. Order of events matter!

Implementation

Hierarchically ordered classes Chromosome, Individual, Deme and World are implemented as core units of the program. They are wrapped in class Simulation, that is handled directly from main of the program. Loading parameters is facilitated though class Setting Handler, which is just a lazy loader of settings.

All random numbers are generated through the standard C++ pseudo random number generator with an initial seed defined by the user, using parameter SEED. Therefore, the reproducibility of every simulation is ensured.

The test is executed by make test. It is not complete, only several tests are implemented in ./test/*.cpp. I do not require to implement a test for every function, however changes of the code should not broke tests which are currently passing and all basic functions which are repetitively used should have a test.

History

This project has started as master project called forsim (forward simulator). The body of thesis is written in English, but official pages at the beginning are according to rules of Masaryk University.

Clone this wiki locally