Skip to content

Individual-based simulation of a facilitated plant in a semi-arid landscape

License

Notifications You must be signed in to change notification settings

rscherrer/brachypode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

104 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

brachypode

This is the repository for a program simulating the evolution of an annual grass species in a semi-arid patchy environment.

Build Tests Coverage DOI Zenodo

Description

The model is an agent-based simulation where sessile individuals dwel in a metapopulation consisting of multiple demes, and each deme contains a facilitated and an unfactilitated habitat patch (facilitated patches are basically the undergrowth of nurse shrubs). The individuals possess genes that determine some level of tolerance against the harsh conditions encountered outside of the shrubs, which trade off with reproductive output. See manuscript for more details.

Installation

This program must be compiled. It is written in C++ and can be built using any modern C++ compiler and build system. Here we provide an example setup to build the program on several platforms using CMake.

Usage

This program has a command-line interface. Assuming the name of the compiled executable is brachypode, use the following command in the terminal from the working directory to run a simulation with default parameter values:

./brachypode

To run a simulation with custom parameters, use:

./brachypode parameters.txt

where parameters.txt is a text file containing a list of parameter names and values.

Parameters

The parameter file should look like this:

ndemes 3
popsize 10
pgood 0.8 0.6 0.5
pgoodEnd 0.8 0.6 0.5
stress 4 0
stressEnd 4 0
capacities 100 1000
capacities 100 1000
maxgrowth 2
steep 2
dispersal 0.1
mutation 0.0001
nloci 50
effect 0.1
allfreq 0.5
tradeoff 1
selfing 0.95
recombination 1
tend 100
tsave 20
seed 12345
sow 1
loadarch 0
savepars 1
savelog 0
savearch 1
choose 0

In the parameter file, each line should contain a parameter name followed by its value(s). If there are several values, they should be separated by spaces. Invalid parameter names or values will result in an error, and lines starting with # will be treated as comments. Click here for a description of the available parameters and their meaning.

Genetic Architecture

The genetic architecture refers to parameters of the genotype-phenotype map. They are on a per locus basis and may take a lot of space, especially if there are many loci, hence storing them in a special parameter file called an architecture file.

Providing a genetic architecture is not necessary, as it will by default be generated anew based on genetic hyperparameters given in the parameter file such as nloci or effect. However, it is possible to supply a custom genetic architecture by providing an architecture file, as explained here.

Output

The user can choose which variables to save from the simulation. Those have to be encoded in the whattosave.txt file provided that parameter choose is set to 1 within the parameters.txt file, as explained here. Output data are saved into binary files with the .dat extension. Those files can be read by any utility capable of reading binary, provided that the data type and byte size is known (e.g. doubles taking 8 bytes). We recommend using the R package readsim for that, as it was specifically designed to read and assemble into tables the kind of data generated by this program.

Tests

This program was tested using the Boost.Test library. All the tests can be found in the tests/ folder. Here we show how we tested the program locally using our own custom setup.

About

This code is written in C++20. It was developed on Ubuntu Linux 24.04 LTS, making mostly use of Visual Studio Code 1.99.0 (C/C++ Extension Pack 1.3.1). CMake 3.28.3 was used as build system, with g++ 13.3.0 as compiler. GDB 15.0.50.20240403 was used for debugging. Tests (see here) were written with Boost.Test 1.87, itself retrieved with Git 2.43.0 and vcpkg 2025.04.09. Memory use was checked with Valgrind 3.22.0. Code coverage was analyzed with gcov v13.3.0, LCOV 2.0-1 and the Coverage Gutters extension for Visual Studio Code 2.13.0. Profiling was performed with gprof 2.42. (See the dev/ folder and this page for details about the checks performed.) During development, occasional use was also made of ChatGPT and GitHub Copilot.

Links

Notes

  • A version of this repository has been archived at Zenodo and can be accessed via the following link.
  • The associated manuscript is publicly available on the preprint server EcoEvoRxiv, accessible here.

Permissions

Copyright (c) 2024-2026, Raphaël Scherrer.

This code is licensed under the MIT license. See license file for details. This program was inspired by discussions with Richèl Bilderbeek. This code comes with no guarantee whatsoever.