Description Usage Arguments Value Author(s) Examples
wf.traj
simulates allele frequency trajectories based on the Wright-Fisher model.
1 |
p0 |
numeric vector with starting allele frequencies. |
Ne |
integer specifying the desired effective population size. The unit is haploid (if |
t |
numeric vector defining for which generations allele frequencies should be returned. |
s |
numeric specifying the selection coefficient used. By default ( |
h |
numeric indicating the dominance coefficient. This parameter will be ignored if |
haploid |
logical indicating wether a population of haploid ( |
approximate |
logical. If |
wf.traj
returns either a vector (if length(p0) == 1
and length(s) == 1
and length(h) == 1
) or a matrix that contains allele frequency trajectories. Columns correspond to the time points defined in t
and rows to individual replicates. If only one replicate should be simulated a numeric vector is returned instead of a matrix.
Allele frequencies in the output are guaranteed to be ordered increasing by the number of generations.
Thomas Taus
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # simulate allele frequency trajectories of individual loci using the Wright-Fisher model (diploid individuals)
Ne <- 200
gen <- seq(0, 100, by=10)
alleleFreqs <- wf.traj(p0=rep(0.5, times=500), Ne=Ne, t=gen)
# look at a subset of the generated data
head(alleleFreqs)
# plot allele frequency trajectories
plot(1, type="n", xlim=c(0, max(gen)), ylim=c(0, 1), main="Neutral Genetic Drift", xlab="Generation", ylab="Allele frequency (%)")
for(r in 1:nrow(alleleFreqs)) {
lines(gen, alleleFreqs[r,])
}
# simulate allele frequency trajectories including selection
alleleFreqs <- wf.traj(p0=rep(0.05, times=500), Ne=Ne, t=gen, s=0.1, h=0.5)
# plot results
plot(1, type="n", xlim=c(0, max(gen)), ylim=c(0, 1), main="Positive Selection", xlab="Generation", ylab="Allele frequency (%)")
for(r in 1:nrow(alleleFreqs)) {
lines(gen, alleleFreqs[r,])
}
# add the trajectory under selection for a population of infinite size (no random genetic drift)
lines(gen, wf.traj(p0=0.05, Ne=NA, t=gen, s=0.1, h=0.5), col="red")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.