Tune the forces of evolution: mutation, migration, selection, and drift (including also non-random mating); to simulate allele frequencies under the classic population genetics equations.
You can refer to this repository as: M. Exposito-Alonso (2017) Wright-Fisher population simulations: a C++ and Shiny app implementation.
\
# Packages required
library(ggplot)
library(cowplot
library(shiny)
library(Rcpp)
# To start the app just run:
runGitHub("popgensim","MoisesExpositoAlonso")
git clone https://github.com/MoisesExpositoAlonso/popgensim.git
Note: You need to do Option 2 before.
cd popgensim
R
Then inside R:
# Packages required
library(devtools)
library(ggplot)
library(cowplot)
library(shiny)
library(Rcpp)
install(".") # install the popgensim package
# Run a simulations defining each population parameter manually:
allelesimCmat(
mu=0.001,
nu=0.001,
m=0,
wAA=0.5,
wAa=0.5,
waa=0.5,
p0=0.5,
psource=0.5,
N=1000,
tmax=100,
rep=50)
# To compare the speed of the R and C++ implementation:
library(microbenchmark)
microbenchmark(
Rimplement=allelesim(rep = 10,tmax=50),
Cimplement=allelesimCmat(rep = 10,tmax=50)
)