if (FALSE) {
# A multi-type birth-death model with birth rate beta,
# death rate gamma, mutation rates m1 and m2
# and I1 and I2 the number of infected individuals of each type.
# With parameter beta varying over 2 time intervals.
reactions <- c("0 [beta1 * I1] -> I1","I1 [gamma1 * I1] -> 0",
"I1 [mu1 * I1] -> I2","0 [beta2 * I2] -> I2",
"I2 [gamma2 * I2] -> 0","I2 [mu2 * I2] -> I1")
BD_simu <- build_simulator(reactions)
initialStates <- c(I1 = 0, I2 = 1)
times <- c(1975, 1998, 2018)
theta <- list(gamma1 = c(0.2, 0.09), gamma2 = 0.1, mu1 = 0.025,
mu2 = 0.021, beta1 = c(0.26,0.37), beta2 = 0.414)
BDres <- BD_simu(paramValues = theta,
initialStates = initialStates,
times = times,
tau = 0.08,
method = "approximate",
seed = 994543)
# Let's generate 100 sampling dates from 2015 and 2018
dates_bd <- seq(from=2015, to=2018, length.out=100)
BD_tree <- simulate_tree(simuResults = BDres,
dates = dates,
deme = c("I"),
sampled = c(I=1),
root = "I",
isFullTrajectory = FALSE,
seed = 973360)
BD_tree$seed
# Plot the simulated phylogeny using the \code{ape::plot.phylo} function.
ape::plot.phylo(BD_tree)
}
Run the code above in your browser using DataLab