fitness: Fitness function

View source: R/glads_funcs.R

fitnessR Documentation

Fitness function


This function computes a fitness value (ω) depending on the phenotype (z) of individuals. The relationship between both variables is assumed to be Gaussian.


fitness(z, N, b0, b1, b2, b3, d.v, add.loci)



A data.frame with the phenotype value ('z') and the sex of each individual in a population.


Population size of the population.


A numerical value defining the maximum number of offspring that may be generated by a breeding pair.


A numerical value defining the phenotypic optima of a given population (see Details).


A numerical value defining the variance of the Gaussian curve.


A numerical value defining the intensity of the density-dependence on the fitness of individuals in a population of size 'N'.


A numerical value defining a stochastic demographic variant in the fitness of individuals.


An integer with the total number of additive loci participating in the computation of phenotypes.


This function is used internally in the function evolve() of type 'selection' in order to compute the fitness value of individuals.

The value of 'b1' represents the z value expected to produce the maximum number of offspring. The difference in phenotypic optima between the populations drives the strength of 'divergent selection'. Populations exposed to equal phenotypic optima are considered to be under 'concordant selection'.

This fitness function (ω) has the following form:

ω = b_0 \exp^{ -\frac{1}{2} ≤ft ( \frac{4z - b_1n_a}{b_2n_a} \right )^2} - b_3N + \varepsilon_d(0, σ_d )

Where n_a is equal to 'add.loci', N is the population size and σ_d is equal to 'd.v'. The demographic variant \varepsilon_d is assumed to be stochastic and normally distributed, with a mean of 0 and standard variation 'd.v'.


A vector with the fitness value (ω) for each individual.


Quilodrán, C. S., Ruegg, K., Sendell-Price, A. T., Anderson, E., Coulson, T. and Clegg, S. (2019). The multiple population genetic and demographic routes to islands of genomic divergence. bioRxiv. doi: 10.1101/673483.

See Also

evolve phenotype


## We first create a random population with 100 individuals and 10 loci
N <- 100  # Population size
nl <- 10  # Number of additive loci
na <- 4  # Number of alleles per locus
G <- initial.struct(N,nl,na)

## Additional parameters are needed for the computation of phenotypes
bvs <- t(array( seq(0,1, length = na) ,c(na, nl)))
sex.ratio <- 0.5

## Now we compute the additive phenotype value of individuals
phen <- phenotype(G, bvs, nl, sex.ratio, e.v)

## Additional parameters are needed for the fitness function
b0 <- 6
b1 <- 0.25
b2 <- 0.5
b3 <- 0.01
d.v = 1

## The fitness values of individuals are computed as follows:
fitness(phen, N, b0, b1, b2, b3, d.v, nl)

eriqande/glads documentation built on April 12, 2022, 9:18 a.m.