sim_wrightfisher: Simulate allele frequencies from Wright-Fisher model

View source: R/main.R

sim_wrightfisherR Documentation

Simulate allele frequencies from Wright-Fisher model

Description

Simulate Wright-Fisher evolution in a series of partially connected demes.

Usage

sim_wrightfisher(
  N,
  L,
  alleles,
  mu,
  mig_mat,
  t_out,
  initial_method = 1,
  initial_params = NULL,
  silent = FALSE
)

Arguments

N

number of individuals per deme. Must be the same for all demes.

L

number of loci (assumed independent).

alleles

number of alleles. Can be a single number for all loci or a vector of length L.

mu

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

mig_mat

migration matrix specifying the per-generation probability of an individual migrating from any deme (in rows) to any other deme (in columns).

t_out

vector of times at which results will be output.

initial_method, initial_params

method of initialising allele frequencies, and parameters that are used in initialisation. There are two possible options:

  1. Each deme has allele frequencies drawn independently from a symmetric Dirichlet(theta/k) distribution, where theta = 2*N*mu and k is the number of alleles. This is the analytical equilibrium distribution under the model if there was no migration between demes.

  2. All demes have the same initial allele frequencies, which are drawn once from a Dirichlet(alpha_1, ..., alpha_k) distribution, where the alpha parameters are input as initial_params. This can be a vector if the same number of alleles is used over all loci, or a list of vectors over loci to accommodate varying numbers of alleles.

silent

if TRUE then suppress output to console.

Details

Assumes a haploid population and independent loci (no linkage disequilibrium). Implements a finite-alleles mutation model with equal chance of mutating from any allele to any other. Initialises allele frequencies by drawing from a symmetric Dirichlet(theta/k) distribution, where theta = 2*N*mu, which is the analytical equilibrium distribution between drift and finite-alleles mutation, ignoring migration between demes. Migration is implemented by proposing random swaps of individuals between demes, thereby ensuring population sizes remain constant over time. For this reason, N must be the same for all demes.


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