tracerer versus Tracer demo

  collapse = TRUE,
  comment = "#>"

tracerer: 'Tracer for R' is an R package that does the same as Tracer does, from within R.

To use tracerer, it needs to be loaded:


When loading beast2_example_output.log in Tracer, the following is displayed:

Tracer output

Most prominently, at the left, the effective sample sizes (ESSes) are shown.

The show the ESSes using tracerer:

estimates <- parse_beast_tracelog_file(
estimates <- remove_burn_ins(estimates, burn_in_fraction = 0.1)
esses <- calc_esses(estimates, sample_interval = 1000)
table <- t(esses)
colnames(table) <- c("ESS")

At the top-right, some measures of the variable posterior is shown. To reproduce these measures in tracerer:

sum_stats <- calc_summary_stats(
  sample_interval = 1000
table <- t(sum_stats)
colnames(table) <- c("sum_stat")

Unlike Tracer, in tracerer all summary statistics can be obtained at once:

sum_stats <- calc_summary_stats(
  sample_interval = 1000

At the bottom-right, a histogram of the posterior estimates is shown. To reproduce these measures in tracerer:

  data = remove_burn_ins(estimates, burn_in_fraction = 0.1),
) + ggplot2::geom_histogram(binwidth = 0.21) +
  ggplot2::scale_x_continuous(breaks = seq(-75, -68))

Tracer can also show the trace of each estimated variable:

Tracer shows the trace of the posterior likelihood

Same can be done with tracerer:

  data = remove_burn_ins(estimates, burn_in_fraction = 0.1),
  ggplot2::aes(x = Sample)
) + ggplot2::geom_line(ggplot2::aes(y = posterior))

tracerer can also use part of DensiTree's functionality. Here is beast2_example_output.trees displayed by DensiTree:

DensiTree output

The same is achieved in tracerer with:

trees <- parse_beast_trees(
phangorn::densiTree(trees, width = 2)

Try the tracerer package in your browser

Any scripts or data that you put into this service are public.

tracerer documentation built on Sept. 27, 2023, 5:09 p.m.