Parallel PopGen Package
Simulation Models: Selection Group

Functions that model selection coefficients (s) across populations and over time. More...

Classes

struct  Sim_Model::selection_constant
 functor: models selection coefficient s as a constant across populations and over time More...
 
struct  Sim_Model::selection_linear_frequency_dependent
 functor: models selection coefficient as linearly dependent on frequency More...
 
struct  Sim_Model::selection_sine_wave
 functor: models selection as a sine wave through time More...
 
struct  Sim_Model::selection_population_specific< Functor_sel, Functor_sel_pop >
 functor: one population, pop, has a different, selection function, s_pop, all other have function s More...
 
struct  Sim_Model::selection_piecewise< Functor_sel1, Functor_sel2 >
 functor: selection function changes from s1 to s2 at generation inflection_point More...
 

Detailed Description

Functions that model selection coefficients (s) across populations and over time.

Selection coefficients are defined by:

AA Aa aa
1 1+hs 1+s

where h is the dominance coefficient and AA, Aa, aa represent the various alleles. Thus Effective Selection, gamma, is defined by N_chromosome_e*s which for outbreeding diploids is 2*N*s and haploid is N*s where N is the number of individuals (as returned by demography functions). Diploids with inbreeding, F, will have an effective strength of selection, gamma, of 2*N*s/(1+F). See Simulation Models: Demography Group for more about effective population size in the simulation. Side note: if gamma is set to some float, S*(1+F), h=0.5 (co-dominant), and the population size is similarly scaled (i.e. N*(1+F)), then the effective selection in the simulation will be invariant with respect to inbreeding.

Minimum selection is s >= -1 (lethal). Currently the program will not throw an error if the selection is less than -1, but will simply take the max(s,-1).

Writing your own Selection functions

These can be functions or functors (or soon, with C++11 support, lambdas). However, the selection function must be of the form:

__device__ float your_function(int population, int generation, float freq){ ... return selection_coeff; }

This returns the selection coefficient in population population at generation generation for a mutation at frequency freq. The __device__ flag is to ensure the nvcc compiler knows the function must be compiled for the device (GPU). Because of this flag, the function must be defined in CUDA source file (*.cu) or declared/defined header file (*.h, *.hpp, *.cuh, etc...) which is included in a CUDA source file. Since this code will be compiled on the GPU, do not use dynamically allocated arrays in your function (e.g. float * f = new float[5]) unless you know CUDA. And even then avoid them as they will slow the code down (parameters have to be pulled from the GPU's global memory (vRAM), which is slow). Statically allocated arrays (e.g. float f[5]) are fine.