NatSelSim | R Documentation |
NatSelSim
simulates natural selection in a bi-allelic gene through
n.gen
generations.
NatSelSim(
w11 = 1,
w12 = 1,
w22 = 0.9,
p0 = 0.5,
n.gen = 10,
plot.type = "animateall",
print.data = FALSE,
knitr = FALSE
)
w11 |
Number giving the fitness of genotype A1A1. Values will be normalized if any genotype fitness exceeds one. |
w12 |
Number giving the fitness of genotype A1A2. Values will be normalized if any genotype fitness exceeds one. |
w22 |
Number giving the fitness of genotype A2A2. Values will be normalized if any genotype fitness exceeds one. |
p0 |
Initial (time = 0) allelic frequency of A1.
A2's initial allelic frequency is |
n.gen |
Number of generation that will be simulated. |
plot.type |
String indicating if plot should be animated.
The default, "animateall" animate all possible panels.
Other options are "static" (no animation), "animate1", "animate3", or
"animate4". Users can animate each panel individually (using
|
print.data |
Logical indicating whether all
simulation results should be returned as a |
knitr |
Logical indicating if plot is intended to show up in RMarkdown files made by the |
If any value of fitness (i.e., w11
, w12
,
w22
) is larger than one, fitness is interpreted as absolute fitness
and values are re-normalized.
If print.data = TRUE
, it returns a data.frame
containing the number of individuals for each genotype through time. The
plots done by the function shows (1) Allele frequency change through time.
(2) The adaptive landscape (which remains static during the whole simulation,
so can't be animated), (3) Time series of mean population fitness,
and (4) Time series of genotypic population frequencies.
Matheus Januario, Jennifer Auler, Dan Rabosky
Fisher, R. A. (1930). The Fundamental Theorem of Natural Selection. In: The genetical theory of natural selection. The Clarendon Press
Plutynski, A. (2006). What was Fisher’s fundamental theorem of natural selection and what was it for?. Studies in History and Philosophy of Science Part C: Studies in History and Philosophy of Biological and Biomedical Sciences, 37(1), 59-82.
#using the default values (w11=1, w12=1, w22=0.9, p0=0.5, n.gen=10)
NatSelSim()
# Continuing a simulation for extra time:
# Run the first simulation
sim1=NatSelSim(w11 = .4, w12 = .5, w22 = .4, p0 = 0.35,
n.gen = 5, plot.type = "static", print.data = TRUE, knitr = TRUE)
# Then take the allelic frequency form the first sim:
new_p0 <- (sim1$AA[nrow(sim1)] + sim1$Aa[nrow(sim1)]*1/2)
# and use as p0 for a second one:
NatSelSim(w11 = .4, w12 = .5, w22 = .4, p0 = new_p0, n.gen = 5, plot.type = "static", knitr = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.