sim_population: Simulate a population

View source: R/sim_population.R

sim_populationR Documentation

Simulate a population

Description

Simulate a single population through time and sample a transect for each generation.

Usage

sim_population(
  mean_dispersal_distance,
  outcrossing_rate,
  n_generations,
  n_starting_genotypes,
  density,
  n_sample_points,
  sample_spacing,
  dormancy,
  range_limit = 1.5,
  pop_structure = "uniform",
  mixing = mean_dispersal_distance,
  habitat_labels = NULL,
  var_w = 0
)

Arguments

mean_dispersal_distance

Float >0. Mean seed dispersal distance. The reciprocal of this is used as the rate parameter to draw from the exponential distribution.

outcrossing_rate

Float between 0 and 1. Probability that an individual is outcrossed.

n_generations

Int >12. Number of generations to run the simulations.

n_starting_genotypes

Int >0. Number of initial genotypes to start with. Defaults to 50

density

Float >0. Average density of plants per square metre.

n_sample_points

Number of points to sample along the transect.

sample_spacing

Distance between sampling points.

dormancy

Float between 0 and 1. Probability that a seedling is drawn from the seed bank. Seedlings are drawn from the prior generation with probability 1-dormancy.

range_limit

Float >1 defining how much wider than the transect the width of the habitat should be. This, along with plant density, determines how many plants will be simulated. Defaults to 1.5. Ignored if pop_structure="hardcoded"

pop_structure

Character string indicating the initial population structure to be simulated. Passing "uniform" simulated a panmictic population. 'clusters' simulates clusters of identical individuals that disperse from distinct mothers via exponential dispersal set by mean_dispersal_distance. This is likely to generate very disperate clumps. Passing "mvnorm" simulates uniformly distributed coordinates for indiduals, as well as centroid positions for genotypes. Individuals are assigned a genotype in proportion to their distance to each genotype centroid based on multivariate-normal probabilities. The variance covariance matrix for this is set as sqrt(habitat_size/n_starting_genotypes) / 3 such that the tail of each genotype just about touches those of its neighbours, on average. If pop_structure='hardcoded' and a vector of genotypes is passed to n_starting_genotypes, for example observed genotypes from along all real-world transects, this simulates bands of identical genotypes by copying the vector over an evenly- spaced grid (giving horizontal but not vertical structure). There is one round of dispersal from this initial generation via exponential dispersal (controlled by mixing) and to get the population to the correct population density.

mixing

Float >0. Parameter controlling the degree of spatial clustering of genotypes. Smaller values indicate more structure populations. If pop_structure='mvnorm' this is a scaler multiplier for the variance of the multivariate normal probability density. If pop_structure="clusters" or pop_structure='hardcoded' this is the reciprocal of the rate parameter to draw dispersal distances from the exponential distribution. #' @habitat_labels Optional vector of habitat labels when ⁠pop_structure = 'hard-coded⁠, with an element for each sample given in n_starting_genotypes.

var_w

Additive variance for (log) fitness. Defaults to zero (no selection).

Details

sim_population simulates a population of annuals dispersing in continuous space following exponentially distributed seed dispersal distances.

  1. Individuals are drawn from a set of starting genotypes and randomly distributed in a square habitat Individuals are labelled by their genotype as 'g' followed by an integer label.

  2. Individuals are chosen at random to found the next generation. They move seed dispersal to new location, with distances drawn from an exponential distribution. The population exists in a square habitat; any dispersal beyond the boundaries of the population is reflected back the same distance into the habitat.

  3. A subset of the new generation are chosen to have been germinated from outcrossed seed. If so, they are given a new unique label by appending their current genotype label by the generation number plus a unique integer.

  4. At each generation a transect through the population is drawn at x=0 with sampling points at equally spaced intervals. The plant closest to each sampling point is recorded.

Plants exist within a box centred around zero with a transect going through zero. The width of the box is defined to be 1.5-fold larger than the length of the transect (but this can be changed with the argument range_limit). Total population size is then the density of plants multiplied by the squared width of the box.

Selection can be simulated by modelling fitness as log-normally distributed. Genotypes are automatically assigned a log fitness values drawn from a normal distribution with mean zero and variance var_w. Following Morrisey and Bonnet (2019; J. Heredity 110:396–402) absolute fitness is then the exponent of these values, which is then divided by the mean to get relative fitness. Seeds ar drawn in proportion to relative fitness.

Value

A list of genotypes recorded at each sampling point in each generation.

Author(s)

Tom Ellis


ellisztamas/simmiad documentation built on Dec. 12, 2023, 5:32 a.m.