Constant pure-birth (Yule) process (CPB)
The simplest diversification model assumes no extinction ($\mu = 0$) and a constant speciation rate $\lambda$, also known as, the pure-birth or Yule model.
Simulations
To simulate a pure-birth tree one can use sim_cb. For instance, for a period of $10$ time units and a speciation rate of $\lambda = 0.5$:
tr = sim_cb(10.0, 0.5)Inference
To perform inference on a tree (of type sT_label), we can use the insane_cb function (cb = constant pure-birth).
r, tv = insane_cb(tree,
nburn = 500,
niter = 1_000,
nthin = 2,
nflush = nthin,
ofile = "<directory>")that For this specific CPB model, where the sampling fraction, $\rho$, is $1$, there are no unobserved components since we assume no extinction and that all species have been sampled. In this case, all the trees in the tree vector will be exactly the same.
In the following example, we now specify a global sampling fraction of 0.8.
r, tv = insane_cb(tree,
nburn = 500,
niter = 1_000,
nthin = 2,
nflush = nthin,
ofile = "<directory>",
tρ = Dict("" => 0.8))This time, the DA trees are different from one another since they have data augmented lineages that represent that proportion of species not included in the tree. The position change from tree to tree because we are integrating over their unknown placement. You can check this by plotting the trees (check Insane plots). For instance, to plot the first tree in the vector:
plot(tv[1])Insane uses Gibbs sampling across most parameter updates in INSANE. So, the prior for speciation in the CPB is a Gamma prior, and its parameters can be specified with argument λ_prior, The default is λ_prior = (1.0, 1.0).
Constant birth-death process (CBD)
We now consider that species have an instantaneous constant rate of extinction, $\mu$, besides the constant rate of speciation $\lambda$.
Simulations
To simulate under the CBD model, say, for a period of $10$, with speciation rate of $0.5$, and extinction rate of $0.3$, a one can use
tr = sim_cbd(10.0, 0.5, 0.3)Inference
To perform inference on the CBD model, we can use
r, tv = insane_cbd(tree,
nburn = 1_000,
niter = 100_000,
nthin = 100,
ofile = "<out file directory>",
λ_prior = (1.0, 1.0),
μ_prior = (1.0, 1.0),
survival = true,
tρ = Dict("" => 1.0))where we now have a Gamma prior for the extinction $\mu$, and we can also specify if we want to condition on survival of the process with survival.
Full documentation
Tapestree.INSANE.sim_cb — Functionsim_cb(t::Float64, λ::Float64)Simulate a constant pure-birth iTree of height t with speciation rate λ.
sim_cb(t::Float64, λ::Float64, na::Int64)Simulate a constant pure-birth iTree of height t with speciation rate λ.
Tapestree.INSANE.sim_cbd — Functionsim_cbd(t::Float64, λ::Float64, μ::Float64)Simulate a constant birth-death iTree of height t with speciation rate λ and extinction rate μ.
sim_cbd(t ::Float64,
λ ::Float64,
μ ::Float64,
na::Int64)Simulate a constant birth-death iTree of height t with speciation rate λ and extinction rate μ.
Tapestree.INSANE.insane_cb — Functioninsane_cb(tree ::sT_label;
λ_prior ::NTuple{2,Float64} = (1.0, 1.0),
niter ::Int64 = 1_000,
nthin ::Int64 = 10,
nburn ::Int64 = 200,
nflush ::Int64 = nthin,
ofile ::String = string(homedir(), "/cb"),
λi ::Float64 = NaN,
pupdp ::NTuple{2,Float64} = (0.2, 0.2),
prints ::Int64 = 5,
tρ ::Dict{String, Float64} = Dict("" => 1.0))Run insane for constant pure-birth.
Tapestree.INSANE.insane_cbd — Functioninsane_cbd(tree ::sT_label;
λ_prior ::NTuple{2,Float64} = (1.0, 1.0),
μ_prior ::NTuple{2,Float64} = (1.0, 1.0),
niter ::Int64 = 1_000,
nthin ::Int64 = 10,
nburn ::Int64 = 200,
nflush ::Int64 = nthin,
ofile ::String = string(homedir(), "/cbd"),
ϵi ::Float64 = 0.4,
λi ::Float64 = NaN,
μi ::Float64 = NaN,
pupdp ::NTuple{3,Float64} = (1e-4, 1e-4, 0.2),
prints ::Int64 = 5,
survival::Bool = true,
mxthf ::Float64 = 0.1,
tρ ::Dict{String, Float64} = Dict("" => 1.0))Run insane for constant birth-death.