simulatepopulation: Simulate a pathogen population

Description Usage Arguments Details Value Examples

View source: R/simulatepopulation.R

Description

Simulates a pathogen population undergoing a Wright-Fisher discrete-time evolutionary process.

Usage

1
2
3
simulatepopulation(m.rate, runtime, equi.pop, sample.times, n.samples=1, 
genomelength=100000, shape=flat, bottle.times=0, bottle.size=1, full=FALSE, 
feedback=1000, init.freq=1, libr=NULL, nuc=NULL, ref.strain=NULL, ...)

Arguments

m.rate

Mutation rate (per sequence per generation).

runtime

Number of generations for simulation to run.

equi.pop

Equilibrium effective population size of pathogens within-host.

sample.times

Vector of times at which to sample population.

n.samples

Number of samples to take at each sampling point (if deepseq=FALSE).

genomelength

Length of genome.

shape

Function describing the population growth dynamics. See Details.

bottle.times

Vector of population bottleneck times.

bottle.size

Size of population bottleneck (if bottle.times!=0).

full

Should complete samples (all genotypes and their frequencies) be returned?

feedback

Intervals between R feedback on simulation progress.

init.freq

Vector of initial frequencies of genotypes, if initial population should be specified. By default, the population grows from a single, randomly generated genotype.

libr

Initial list of genotypes, if initial population should be specified. Must have same length as init.freq.

nuc

Initial list of mutations, if initial population should be specified. Must have same length as init.freq.

ref.strain

Reference strain. By default, this is randomly generated.

...

Additional arguments to be passed to the shape function.

Details

Simulation of a bacterial population. Population is by default initially clonal, and initiated by a single genotype. Population is prevented from extinction at all times. Population can be passed through repeated bottlenecks using the arguments bottle.times and bottle.size. Population growth dynamics are defined by the function called by 'shape'. This function returns the expected population size at each time step, given the total simulation time. By default, the population is expected to grow exponentially until reaching an equilibrium level, specified by equi.pop (flat). Alternatively, the population can follow a sinusoidal growth curve, peaking at runtime/2 (hump). User-defined functions should be of the form function(time,span,equi.pop,...), where span is equal to runtime in this setting.

Value

Returns a list of sampling data;

libr

List of unique genotypes observed. Each entry is a vector of mutant loci relative to the reference strain.

nuc

List of mutation types corresponding to libr. Each entry is a vector of nucleotides mutated from the reference strain, corresponding to entries in libr.

librstrains

Vector of unique genotype IDs corresponding to the libr object.

obs.strain

If full=TRUE, list of observed genotypes, each entry corresponding to the sample.times. If full=FALSE, a vector of genotype IDs, corresponding to the returned vector obs.time.

obs.freq

List of observed genotype frequencies returned if full=TRUE.

obs.time

Vector of observation times returned if full=FALSE.

ref.strain

Reference strain used.

Examples

1
2
3
4
5
6
7
8
9
# Generate 5 genome samples at 5 time points
X <- simulatepopulation(m.rate=0.0005, runtime=10000, equi.pop=2000,
                      sample.times=(1:5)*2000, n.samples=5, 
                      genomelength=10000, full=FALSE)
	
# Generate complete observations at 5 time points
X <- simulatepopulation( m.rate=0.0005, runtime=10000, equi.pop=2000,
                      sample.times=(1:5)*2000, genomelength=10000, 
                      bottle.times=5000, bottle.size=1, full=TRUE)

seedy documentation built on May 29, 2017, 10:58 a.m.