Description Usage Arguments Value Author(s) Examples
Combine multiple allele frequency trajectories to get a consensus trajectory.
1 | consensus.traj(traj, t, cov, Ne, N.sim = 10000, bias = NA)
|
traj |
numeric matrix of allele frequency trajectories, where rows and columns correspond to individual replicates and time points, respectively. |
t |
numeric vector indicating the number of generations for each column in |
cov |
numeric matrix of sequence coverages, where columns and rows correspond to measurement time points and replicates, respectively |
Ne |
numeric specifying the effective population size |
N.sim |
numeric determining the number of simulations that should be performed to correct for bias (by default |
bias |
numeric specifying the bias correction, which is necessesary to account for conditioning on fixation. By default ( |
A list with class "ctraj" containing the following components:
af |
consensus allele frequencies. |
t |
time in generations. |
cov |
combined sequence coverages (if available). |
Thomas Taus
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # simulate allele frequency trajectories of individual loci using the Wright-Fisher model (diploid individuals)
p0 <- 0.01
s <- 0.1
h <- 0.5
Ne <- 1000
tp <- seq(0, 100, by=10)
alleleFreqs <- wf.traj(p0=rep(p0, times=100), Ne=Ne, t=tp, s=s, h=h)
# compute consensus trajectory
cTraj <- consensus.traj(alleleFreqs, t=tp, cov=NA, Ne=Ne)
# plot individual and consensus allele frequency trajectories, as well as the trajectory assuming an infinitely large population (no random drift)
plot(1, type="n", xlim=c(0, max(tp)), ylim=c(0, 1), main="Allele frequency trajectories with selection", xlab="Generation", ylab="Allele frequency")
for(r in 1:nrow(alleleFreqs)) {
lines(tp, alleleFreqs[r,])
}
lines(tp, cTraj$af, col="red", lwd=2)
lines(tp, wf.traj(p0=p0, Ne=NA, t=tp, s=s, h=h), col="green", lwd=2)
legend("topleft", legend=c("replicate", "consensus", "deterministic"), col=c("black", "red", "green"), lwd=c(1, 2, 2), bty="n")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.