# NOT RUN {
library(data.table)
N <- 10
L <- 100.0
tr <- ape::stree(N)
tr$edge.length <- rep(L, N)
for(epoch in seq(1, L, by = 1.0)) {
tr <- PCMTreeInsertSingletonsAtEpoch(tr, epoch)
}
model <- PCMBaseTestObjects$model_MixedGaussian_ab
PCMTreeSetPartRegimes(tr, c(`11` = 'a'), setPartition = TRUE)
set.seed(1, kind = "Mersenne-Twister", normal.kind = "Inversion")
X <- PCMSim(tr, model, X0 = rep(0, 3))
dt <- NULL
for(epoch in seq(0, L, by = 1)) {
nodes <- PCMTreeLocateEpochOnBranches(tr, epoch)$nodes
dtEpoch <- as.data.table(t(X[, nodes]))
dtEpoch[, t:=epoch]
if(epoch == 0) {
dtEpoch[, lineage:="root"]
} else {
dtEpoch[, lineage:=gsub("i.*x", "x", PCMTreeGetLabels(tr)[nodes], perl = TRUE)]
}
dt <- rbindlist(list(dt, dtEpoch))
}
# }
Run the code above in your browser using DataLab