# simulated tree
phy <- ape::rtree(10)
# simulate characters along the branches of the tree
morpho_data <- sim.morpho(tree = phy,
k = c(2,3,4),
trait.num = 20,
partition = c(10,5,5),
ACRV = "gamma",
ACRV.ncats = 4,
variable = TRUE,
ancestral = TRUE,
define.Q = NULL)
# To simulate ordered characters:
# First define a Q-matrix. The following is for ordered characters where transitions can only occur
# between states 0 and 1 and 1 and 2
ord_Q <- matrix(c(
-0.5, 0.5, 0.0,
0.3333333, -0.6666667, 0.3333333,
0.0, 0.5, -0.5
), nrow = 3, byrow = TRUE)
# This Q matrix can be then used to simulate character data.
morpho_data <- sim.morpho(tree = phy,
k = 3,
trait.num = 20,
ancestral = TRUE,
ACRV = "gamma",
variable = TRUE,
ACRV.ncats = 4,
define.Q = ord_Q)
Run the code above in your browser using DataLab