sim_lattice_biallelic: Simulate allele frequencies from lattice model assuming two...

View source: R/main.R

sim_lattice_biallelicR Documentation

Simulate allele frequencies from lattice model assuming two allele classes

Description

Simulate evolution under the lattice model of Kimura and Weiss. Can be defined over a plane or over a torus. Outputs the raw count of the reference allele in each deme, replicated over all specified output times as a list of matrices.

Usage

sim_lattice_biallelic(
  demes_x,
  demes_y,
  N,
  mu,
  m,
  t_out,
  p_init = 0,
  torus = FALSE,
  silent = FALSE
)

Arguments

demes_x, demes_y

number of demes in each dimension.

N

number of individuals per deme. The same for all demes.

mu

mutation rate. Assumes finite-alleles model, with equal chance of mutating to each allele.

m

per-generation probability of migrating to an adjacent deme in the x- and y-dimensions. The total probability of leaving a given deme is therefore 2m.

t_out

vector of times at which results will be output.

p_init

the initial allele frequency, which is the same in all demes.

torus

if TRUE then model is defined over a torus, i.e. with period rather than reflecting boundaries. Defaults to FALSE.

silent

if TRUE then suppress output to console.

Details

Assumes a haploid population of size N and a single, biallelic locus. Implements a finite-alleles mutation model with equal chance of mutating to each allele. Initialises allele frequencies at p_init in all demes. Under the lattice model demes can only exchange migrants with other demes immediately adjacent, and do so with probability m/2 in both the x- and y-dimensions. This means the total probability of migrating is actually 2m for each individual in a deme, which seems strange but is how the lattice model was described in the original papers of Kimura and Weiss. By default, boundaries are reflecting, meaning demes at the edges have half the migration probability of demes further in. This tends to cause edge effects due to the buildup of relatedness at the boundaries. The option exists to make boundaries periodic, in which case the lattice model is defined over a torus rather than a plane. This eliminates edge effects, but leads to complex correlations over long distances.


bobverity/bobfunctions2 documentation built on July 4, 2023, 8:55 p.m.