Quetzal-CoaTL
The Coalescence Template Library
Loading...
Searching...
No Matches
quetzal::simulator::ForwardBackwardSpatiallyExplicit< Space, DispersalPolicy, CoalescencePolicy, Memory > Class Template Reference

#include <quetzal/simulator/ForwardBackwardSpatiallyExplicit.hpp>

Detailed Description

template<typename Space, typename DispersalPolicy, typename CoalescencePolicy, typename Memory = quetzal::demography::memory_policy::on_RAM>
class quetzal::simulator::ForwardBackwardSpatiallyExplicit< Space, DispersalPolicy, CoalescencePolicy, Memory >

Discrete-time coalescence simulator in a discrete spatially explicit landscape.

This simulator consists in a forward demographic simulation of population growth and migration, after what a backward coalescent simulation is performed that traces back the ancestry of a sample of gene copies sampled in one or more populations. Most Recent Common ancestor is not always fond in the time span of the spatial history, so if the chosen CoalescencePolicy implements the required behavior, ancestry can be simulated in the more distant past using another model like the DiscreteTimeWrightFisher model, to find the MRCA. Details concerning the mergers (binary mergers, simultaneous multiple mergers) can be controlled using the relevant Merger policy class when calling a coalescence function of the class interface.

Template Parameters
Spacedeme identifiers (like the populations geographic coordinates)
Strategya template class argument (e.g. mass_based, individual_based) that indicates how dispersal should be defined in terms of demographic expansion algorithms. Strategy class implements the details (computing migrations probabilites as a function of the distance for example) whereas template specialization of the internal history_type class defines different migration algorithms.
CoalescencePolicya policy class for the demographic expansion.

Public Types

using coord_type = Space
 
using dispersal_policy_type = DispersalPolicy
 
using N_value_type = typename DispersalPolicy::value_type
 
using memory_policy = Memory
 
template<typename tree_type >
using forest_type = quetzal::coalescence::container::Forest< coord_type, tree_type >
 

Public Member Functions

 ForwardBackwardSpatiallyExplicit (coord_type x_0, N_value_type N_0, unsigned int nb_generations)
 Constructor.
 
auto distribution_area (unsigned int t) const
 Return demes with non-zero population size.
 
auto get_functor_N () const noexcept
 Read-only access to the population size history.
 
template<typename Generator , typename Growth , typename Dispersal >
void simulate_forward_demography (Growth growth, Dispersal kernel, Generator &gen)
 Simulate the forward-in-time demographic expansion.
 
template<typename Merger , typename Generator >
auto make_forest_and_coalesce_along_spatial_history (std::map< coord_type, unsigned int > sample, Generator &gen)
 Initlize a forest based on sample counts then coalesce the forest along the spatial history, then stops and return an incomplete forest.
 
template<typename Merger , typename Generator >
auto make_forest_using_sampling_time_and_coalesce_along_spatial_history (std::map< coord_type, unsigned int > sample, unsigned int sampling_time, Generator &gen)
 Initialize a forest based on sample counts, forwarding the sampling time to the forest contructor. Then coalesce the forest along the spatial history, then stops and return a possibly incomplete forest.
 
template<typename Merger , typename Generator , typename F , typename Tree , typename U >
auto coalesce_along_spatial_history (forest_type< Tree > forest, F binary_op, Generator &gen, U make_tree)
 Coalesce a forest of nodes conditionally to the simulated demography.
 
template<typename Merger = quetzal::coalescence::merger_policy::SimultaneousMultipleMerger< quetzal::coalescence::occupancy_spectrum::sampling_policy::on_the_fly>, typename Generator >
auto coalesce_to_mrca (std::map< coord_type, unsigned int > sample, unsigned int sampling_time, Generator &gen)
 Create a forest from a sample and coalesce it conditionally to the simulated demography.
 
template<typename Merger = quetzal::coalescence::merger_policy::SimultaneousMultipleMerger< quetzal::coalescence::occupancy_spectrum::sampling_policy::on_the_fly>, typename Generator >
auto coalesce_to_mrca (std::map< coord_type, unsigned int > sample, Generator &gen)
 Create a forest from a sample and coalesce it conditionally to the simulated demography.
 
template<typename Merger = quetzal::coalescence::merger_policy::SimultaneousMultipleMerger< quetzal::coalescence::occupancy_spectrum::sampling_policy::on_the_fly>, typename Generator , typename F >
auto coalesce_to_mrca (std::map< coord_type, unsigned int > sample, unsigned int sampling_time, F leaf_name, Generator &gen)
 Create a forest from a sample giving name to tips, then coalesce them conditionally to the simulated demography.
 
template<typename Merger = quetzal::coalescence::merger_policy::SimultaneousMultipleMerger< quetzal::coalescence::occupancy_spectrum::sampling_policy::on_the_fly>, typename T , typename F1 , typename F2 , typename Generator >
auto coalesce_to_mrca (std::vector< T > sample, unsigned int sampling_time, F1 get_location, F2 get_name, Generator &gen)
 Create a forest from a sample then coalesce them conditionally to the simulated demography.
 

Constructor & Destructor Documentation

◆ ForwardBackwardSpatiallyExplicit()

template<typename Space , typename DispersalPolicy , typename CoalescencePolicy , typename Memory = quetzal::demography::memory_policy::on_RAM>
quetzal::simulator::ForwardBackwardSpatiallyExplicit< Space, DispersalPolicy, CoalescencePolicy, Memory >::ForwardBackwardSpatiallyExplicit ( coord_type  x_0,
N_value_type  N_0,
unsigned int  nb_generations 
)
inline

Constructor.

Parameters
x_0Initialization coordinate.
N_0Population size at intialization
nb_generationsnumber of generations of the spatial process

Member Function Documentation

◆ coalesce_to_mrca() [1/4]

template<typename Space , typename DispersalPolicy , typename CoalescencePolicy , typename Memory = quetzal::demography::memory_policy::on_RAM>
template<typename Merger = quetzal::coalescence::merger_policy::SimultaneousMultipleMerger< quetzal::coalescence::occupancy_spectrum::sampling_policy::on_the_fly>, typename Generator >
auto quetzal::simulator::ForwardBackwardSpatiallyExplicit< Space, DispersalPolicy, CoalescencePolicy, Memory >::coalesce_to_mrca ( std::map< coord_type, unsigned int >  sample,
Generator &  gen 
)
inline

Create a forest from a sample and coalesce it conditionally to the simulated demography.

Template Parameters
Mergera coalescence merger to use
Generatora random number Generator
Parameters
samplethe number of gene copies at each location @gen a random number generator

◆ coalesce_to_mrca() [2/4]

template<typename Space , typename DispersalPolicy , typename CoalescencePolicy , typename Memory = quetzal::demography::memory_policy::on_RAM>
template<typename Merger = quetzal::coalescence::merger_policy::SimultaneousMultipleMerger< quetzal::coalescence::occupancy_spectrum::sampling_policy::on_the_fly>, typename Generator , typename F >
auto quetzal::simulator::ForwardBackwardSpatiallyExplicit< Space, DispersalPolicy, CoalescencePolicy, Memory >::coalesce_to_mrca ( std::map< coord_type, unsigned int >  sample,
unsigned int  sampling_time,
leaf_name,
Generator &  gen 
)
inline

Create a forest from a sample giving name to tips, then coalesce them conditionally to the simulated demography.

Template Parameters
Generatora random number Generator
Fa unary operation with signature equivalent to 'std::string fun(coord_type const& x, unsigned int t)'
Parameters
samplethe number of gene copies at each location
sampling_timethe time of sampling_time
leaf_namea functor assigning a name to a tip as a function of its location and of sampling time. @gen a random number generator

◆ coalesce_to_mrca() [3/4]

template<typename Space , typename DispersalPolicy , typename CoalescencePolicy , typename Memory = quetzal::demography::memory_policy::on_RAM>
template<typename Merger = quetzal::coalescence::merger_policy::SimultaneousMultipleMerger< quetzal::coalescence::occupancy_spectrum::sampling_policy::on_the_fly>, typename Generator >
auto quetzal::simulator::ForwardBackwardSpatiallyExplicit< Space, DispersalPolicy, CoalescencePolicy, Memory >::coalesce_to_mrca ( std::map< coord_type, unsigned int >  sample,
unsigned int  sampling_time,
Generator &  gen 
)
inline

Create a forest from a sample and coalesce it conditionally to the simulated demography.

Template Parameters
Mergera coalescence merger to use
Generatora random number Generator
Parameters
samplethe number of gene copies at each location
sampling_timethe time of sampling_time to build the make_forest coalescence policy function @gen a random number generator

◆ coalesce_to_mrca() [4/4]

template<typename Space , typename DispersalPolicy , typename CoalescencePolicy , typename Memory = quetzal::demography::memory_policy::on_RAM>
template<typename Merger = quetzal::coalescence::merger_policy::SimultaneousMultipleMerger< quetzal::coalescence::occupancy_spectrum::sampling_policy::on_the_fly>, typename T , typename F1 , typename F2 , typename Generator >
auto quetzal::simulator::ForwardBackwardSpatiallyExplicit< Space, DispersalPolicy, CoalescencePolicy, Memory >::coalesce_to_mrca ( std::vector< T >  sample,
unsigned int  sampling_time,
F1  get_location,
F2  get_name,
Generator &  gen 
)
inline

Create a forest from a sample then coalesce them conditionally to the simulated demography.

Template Parameters
Ttype of an individual
F1a unary operation with signature equivalent to 'coord_type fun(const T& i)'
F2a unary operation with signature equivalent to 'std::string fun(const T& i)'
Generatora random number Generator
Parameters
samplea collection of individuals (gene copies)
sampling_timethe time of sampling_time
get_locationa unary operation taking a sampled individual of type T as an argument and returning its geographic location
get_namea functor taking a sampled individual of type T as an argument and returning an identifier @gen a random number generator

◆ get_functor_N()

template<typename Space , typename DispersalPolicy , typename CoalescencePolicy , typename Memory = quetzal::demography::memory_policy::on_RAM>
auto quetzal::simulator::ForwardBackwardSpatiallyExplicit< Space, DispersalPolicy, CoalescencePolicy, Memory >::get_functor_N ( ) const
inlinenoexcept

Read-only access to the population size history.

Designed to be used for composing growth expression.

Returns
a functor with signature N_value_type fun(coord_type const& x, unsigned int t) giving the population size in deme \(x\) at time \(t\).

◆ make_forest_and_coalesce_along_spatial_history()

template<typename Space , typename DispersalPolicy , typename CoalescencePolicy , typename Memory = quetzal::demography::memory_policy::on_RAM>
template<typename Merger , typename Generator >
auto quetzal::simulator::ForwardBackwardSpatiallyExplicit< Space, DispersalPolicy, CoalescencePolicy, Memory >::make_forest_and_coalesce_along_spatial_history ( std::map< coord_type, unsigned int >  sample,
Generator &  gen 
)
inline

Initlize a forest based on sample counts then coalesce the forest along the spatial history, then stops and return an incomplete forest.

Returns
A possibly incompletely coalesced forest.

◆ make_forest_using_sampling_time_and_coalesce_along_spatial_history()

template<typename Space , typename DispersalPolicy , typename CoalescencePolicy , typename Memory = quetzal::demography::memory_policy::on_RAM>
template<typename Merger , typename Generator >
auto quetzal::simulator::ForwardBackwardSpatiallyExplicit< Space, DispersalPolicy, CoalescencePolicy, Memory >::make_forest_using_sampling_time_and_coalesce_along_spatial_history ( std::map< coord_type, unsigned int >  sample,
unsigned int  sampling_time,
Generator &  gen 
)
inline

Initialize a forest based on sample counts, forwarding the sampling time to the forest contructor. Then coalesce the forest along the spatial history, then stops and return a possibly incomplete forest.

Returns
A possibly incompletely coalesced forest.

◆ simulate_forward_demography()

template<typename Space , typename DispersalPolicy , typename CoalescencePolicy , typename Memory = quetzal::demography::memory_policy::on_RAM>
template<typename Generator , typename Growth , typename Dispersal >
void quetzal::simulator::ForwardBackwardSpatiallyExplicit< Space, DispersalPolicy, CoalescencePolicy, Memory >::simulate_forward_demography ( Growth  growth,
Dispersal  kernel,
Generator &  gen 
)
inline

Simulate the forward-in-time demographic expansion.

Template Parameters
Growtha growth functor, see param growth for details.
Dispersala dispersal kernel, see param kernel for details.
Parameters
growtha functor simulating \(\tilde{N}_{x}^{t}\). The functor can possibly make use of get_functor_N. The signature of the function should be equivalent to the following: unsigned int sim_growth(V &gen, const coord_type &x, unsigned int t);
kernela functor representing the dispersal location kernel that simulates the coordinate of the next location conditionally to the current location \(x\). The signature should be equivalent to coord_type kernel(V &gen, const coord_type &x, unsigned int t);

The documentation for this class was generated from the following file: