Description Usage Arguments Details Value Examples

View source: R/simulatepopulation.R

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

1 2 3 |

`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 |

`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 |

`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 |

`nuc` |
Initial list of mutations, if initial population should be specified. Must have same length as |

`ref.strain` |
Reference strain. By default, this is randomly generated. |

`...` |
Additional arguments to be passed to the |

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.

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 |

`librstrains` |
Vector of unique genotype IDs corresponding to the |

`obs.strain` |
If |

`obs.freq` |
List of observed genotype frequencies returned if |

`obs.time` |
Vector of observation times returned if |

`ref.strain` |
Reference strain used. |

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.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.