This vignette shows how to parse a BEAST2 posterior file using RBeast.

Load the RBeast package:

library(RBeast)

Extracting the phylogenies from the .trees file

Check if the example file can be found:

trees_file <- system.file(
    "extdata", "read_beast2_trees_example.trees", package = "RBeast"
)
testit::assert(file.exists(trees_file))

Parse the posterior:

posterior_trees <- read_beast2_trees(trees_file)

Investigating the posterior:

names(posterior_trees)
testit::assert(length(posterior_trees) == 11)

We can see that the posterior has multiple states.

Every state is a phylogeny:

testit::assert(class(posterior_trees[[1]]) == "phylo")

We can plot these all seperately:

for (p in posterior_trees) {
  graphics::plot(p)
}

Or we plot all at once:

class(posterior_trees) <- "multiPhylo"
phangorn::densiTree(
  posterior_trees, 
  type = "cladogram", 
  alpha = 1
)


beast-dev/RBeast documentation built on May 12, 2019, 10:02 a.m.