initialise_population: Initialise population

View source: R/initialise_population.R

initialise_populationR Documentation

Initialise population

Description

This creates a population of individuals as a 2D matrix of coordinates in a torus and a list of genotypes.

Usage

initialise_population(
  n_starting_genotypes,
  population_size,
  box_limit,
  pop_structure = "uniform",
  mixing = NULL,
  sample_spacing = 5,
  habitat_labels = NULL,
  var_w = 0
)

Arguments

n_starting_genotypes

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

population_size

Integer > 1. Calculated by sim_population based on the length of the transect and plant density.

box_limit

Float >1 giving half the circumference of the torus. Ignored if pop_structure is a vector.

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.

sample_spacing

Positive integer giving the distance between sampling points if pop_structure='hardcoded'

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).

Value

A list with two elements: geno, a vector of genotype labels; coords, a 2D matrix of coordinate positions.


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