We initialise the world with initial population of size ``K_0 / 9`` located on patch `5`. We keep track of individuals' ancestors by setting `ancestors=true`. Because we wish to use `Gillepsie` algorithm, we need `rates=true` as agents' internal birth and death rates are updated at every time step.
We initialise the world with initial population of size ``K_0 / 9`` located on patch `5`. `NMax` corresponds to the maximum number of individuals that can be attained. If attained, then the programm stops.
We keep track of individuals' ancestors by setting `ancestors=true`. Because we wish to use `Gillepsie` algorithm, we need `rates=true` as agents' internal birth and death rates are updated at every time step.
!!! note "Warning"
!!! note "Warning"
`rates` treatment is something we might implement in the library internals.
`rates` treatment is something we might implement in the library internals.
# [Modelling agents with a genetic structure](@id genetic_structure)
In this example, we show how to model a population which evolve on a linear geographic space, and is defined by a genotype graph. Any two connected node in the genotype graph should be thought of as two neighbour genomes, i.e that are very similar in their alleles / nucleotide.
In this example, we show how to model a population which evolve on a linear geographic space, and is defined by a genotype graph. Any two connected node in the genotype graph should be thought of as two neighbour genomes, i.e that are very similar in their alleles / nucleotide.
...
@@ -35,3 +35,9 @@ The genotype space is inspired from the article [The architecture of an empirica
...
@@ -35,3 +35,9 @@ The genotype space is inspired from the article [The architecture of an empirica
```
```
## Plotting
## Plotting
Plotting animations of graphs is a bit involved. If you want to learn about that, consult `src/examples/genetic_structure.jl`.
@@ -5,16 +5,22 @@ This script aims at reproducing the 1999 article of Doebeli [On The Origin of Sp
...
@@ -5,16 +5,22 @@ This script aims at reproducing the 1999 article of Doebeli [On The Origin of Sp
In this article, birth and death functions are defined as gaussian, with respective variance ``\sigma_b`` and ``\sigma_d``. It is shown that when ``\sigma_d < \sigma_b``, speciation in the trait space occurs. This is what we reproduce here.
In this article, birth and death functions are defined as gaussian, with respective variance ``\sigma_b`` and ``\sigma_d``. It is shown that when ``\sigma_d < \sigma_b``, speciation in the trait space occurs. This is what we reproduce here.
## Running the world
## Running the world
![]()
We need to run the simulation for a significant amount of time to observe sympatric speciation. As such, we set `ancestors=false`. The rest is pretty standard
```julia
## Plotting lineages
myspace=(RealSpace{1,Float64}(),)
A cool feature of ABMEv.jl is its ability to track agents ancestors traits (cf [Agent section](../manual/agent.md))
σ_b=.9;
σ_d=.7;
On can plot it, to get an idea of the coalescence of the population.
Some metrics are available (cf [Metrics section](../manual/metrics.md)) that summarize the divergence in trait value (or geographical position) through time).
@@ -7,9 +7,13 @@ The purpose of this package is to provide a numerical laboratory for evolutionar
...
@@ -7,9 +7,13 @@ The purpose of this package is to provide a numerical laboratory for evolutionar
- analysis tools to investigate the simulations.
- analysis tools to investigate the simulations.
## Features
## Features
Agents consist of a set of traits in some combination of vector spaces. A vector space can represent for example a geographical landscape, or trait space. Spaces can be of any dimensions, discrete or continuous, bounded or unbounded. They can equally consist of graphs.
Agents consist of sets of traits in some combination of vector spaces. A vector space can represent for example **a geographical landscape, a trait space, or genetic structure**. Spaces can be of any dimensions, discrete or continuous, bounded or unbounded. They can equally consist of graphs.
Vector spaces are used to define birth and death processes, as well as mutation processes.
Vector spaces are used to define birth and death processes, as well as mutation processes.
### Specificities
-[ABMEv.jl allows to keep track of agents' trait lineages](@ref genetic_structure)
-[ABMEv.jl enables to run evolutionary dynamics on graphs!](@ref lineages)
## Getting started
## Getting started
```@repl
```@repl
using ABMEv
using ABMEv
...
@@ -22,14 +26,14 @@ Pages = [
...
@@ -22,14 +26,14 @@ Pages = [
"examples/delta_competition_example.md",
"examples/delta_competition_example.md",
"examples/changing_environment.md",
"examples/changing_environment.md",
"examples/sympatric_speciation.md",
"examples/sympatric_speciation.md",
"examples/gradient_establishment.md",
"examples/gradient.md",
"examples/genetic_structure.md",
"examples/genetic_structure.md",
""
""
]
]
Depth = 2
Depth = 2
```
```
## How it works
## How it works
There general workflow to launch any simulation is the following
General workflow to launch any simulation is the following
-[Define the combination of vector spaces you are interested in.](manual/space.md)
-[Define the combination of vector spaces you are interested in.](manual/space.md)
- Define birth and death function, that depend on agents position in the space
- Define birth and death function, that depend on agents position in the space
...
@@ -40,9 +44,9 @@ There general workflow to launch any simulation is the following
...
@@ -40,9 +44,9 @@ There general workflow to launch any simulation is the following
### Available algorithms
### Available algorithms
As of now, three types of simulation algorithm can be used:
As of now, three types of simulation algorithm can be used:
-[Gillepsie](manual/gillepsie.md)
-[Gillepsie](manual/gillepsie.md)
-[Wright-Fisher](manual/wright_fisher.md)
-[Wright-Fisher](manual/wright_fisher.md)
-[CFM](CFM.md)
-[CFM](CFM.md)
## References
## References
-[Champagnat and Ferriere founding article](https://linkinghub.elsevier.com/retrieve/pii/S0040580905001632)
-[Champagnat and Ferriere founding article](https://linkinghub.elsevier.com/retrieve/pii/S0040580905001632)
@@ -6,5 +6,30 @@ Indeed, at every time step, only the fitness of the individual picked at random
...
@@ -6,5 +6,30 @@ Indeed, at every time step, only the fitness of the individual picked at random
In order to use it, you need to feed to the dictionary parameters `p` a constant `Cbar<:Real` that is the upperbound of the maximum of the sum of the birth and death rates (cf article).
In order to use it, you need to feed to the dictionary parameters `p` a constant `Cbar<:Real` that is the upperbound of the maximum of the sum of the birth and death rates (cf article).
`plot(world::Array{U},p;what=["x","H"],trait = 1) where U <: Union{Missing,Agent{T}} where T`.
An example to use it:
```julia
```julia
usingPlots;pyplot()
function plot(sim::Simulation;trait=1)
Plots.plot(worldall,p_default,what=["x"],trait=2)
```
```
You can specify what you want to plot in the array ```what```:
-```"x"``` returns a scatter plot `(xaxis = time, yaxis = trait)` . Geotrait corresponds to `trait=0`
-`"xs"` only works for agent type `MixedAgent`, because it needs a discrete geographical space. It returns a scatter plot `(xaxis = geographical component, yaxis = trait value)`. Very similar to a `histogram2d` plot, with nicer look.