Skip to content

Instantly share code, notes, and snippets.

@mlandis
Created November 30, 2016 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlandis/570a3844d7688bc3cbb1a4abe774c58e to your computer and use it in GitHub Desktop.
Save mlandis/570a3844d7688bc3cbb1a4abe774c58e to your computer and use it in GitHub Desktop.
Johan's K80+I model
# read in the data
data <- readDiscreteCharacterData(data_filename)
# read in a tree (this could also be a stochastic tree variable)
tree <- readTrees(tree_filename)[1]
# assign a lognormal prior to the transition/transversion rate
kappa_sd <- 1.0
kappa_mean <- -0.5 * kappa_sd^2
kappa ~ dnLognormal(kappa_mean, kappa_sd)
moves[1] = mvScale(kappa)
# construct the K80 rate matrix
Q := fnK80(kappa)
# assign a uniform prior to the proportion of invariant sites
p_invar ~ dnUniform(0,1)
moves[2] = mvSlide(p_invar, delta=0.1)
# create the phylogenetic substitution model using K80 and +I
seq ~ dnPhyloCTMC(tree=tree,
Q=Q,
pInv=p_invar,
type="DNA",
nSites=data.nchar())
# treat the data as observed
seq.clamp(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment