knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
beastier::remove_beaustier_folders() beastier::check_empty_beaustier_folders()
This step-by-step demo shows how to run the babette
pipeline in detail.
First, load babette
:
library(babette)
In all cases, this is done for a short MCMC chain length of 10K:
inference_model <- create_inference_model() inference_model$mcmc$chain_length <- 10000 inference_model$mcmc$tracelog$filename <- normalizePath( get_beautier_tempfilename( pattern = "tracelog_", fileext = ".log" ), mustWork = FALSE ) inference_model$mcmc$treelog$filename <- normalizePath( get_beautier_tempfilename( pattern = "treelog_", fileext = ".trees" ), mustWork = FALSE )
This step is commonly done using BEAUti.
With babette
, this can be done as follows:
beast2_input_file <- tempfile(pattern = "beast2_", fileext = ".xml") create_beast2_input_file_from_model( input_filename = get_babette_path("anthus_aco.fas"), inference_model = inference_model, output_filename = beast2_input_file )
print(head(readLines(beast2_input_file)))
This file can both be loaded by BEAUti and be used by 'BEAST2'.
The file can be checked if it is indeed a valid input file:
if (is_beast2_installed()) { is_beast2_input_file(beast2_input_file) }
This step is commonly done using 'BEAST2' from the command-line or using its GUI.
With babette
, this can be done as follows:
if (is_beast2_installed()) { beast2_options <- create_beast2_options( input_filename = beast2_input_file ) beastier::check_can_create_file(beast2_options$output_state_filename) beastier::check_can_create_treelog_file(beast2_options) run_beast2_from_options( beast2_options = beast2_options ) if (!file.exists(beast2_options$output_state_filename)) { stop("the filename should have been created.") } }
The .log
file contains the model parameters and parameter estimates:
if (is_beast2_installed()) { print(head(readLines(inference_model$mcmc$tracelog$filename))) print(tail(readLines(inference_model$mcmc$tracelog$filename))) }
The .trees
file contains the alignment, taxa and posterior trees:
if (is_beast2_installed()) { print(head(readLines(inference_model$mcmc$treelog$filename))) print(tail(readLines(inference_model$mcmc$treelog$filename))) }
The .xml.state
file contains the final state of the MCMC run and the
MCMC operator acceptances thus far:
if (is_beast2_installed()) { print(head(readLines(beast2_options$output_state_filename))) print(tail(readLines(beast2_options$output_state_filename))) }
This step is commonly done using Tracer.
With babette
, this can be done as follows.
Parsing .log
file to obtain the parameter estimates:
if (is_beast2_installed()) { knitr::kable( head(parse_beast_tracelog_file(inference_model$mcmc$tracelog$filename)) ) }
Parsing .trees
file to obtain the posterior phylogenies:
if (is_beast2_installed()) { plot_densitree(parse_beast_trees(inference_model$mcmc$treelog$filename)) }
Parsing .xml.state
file to obtain the MCMC operator acceptances:
if (is_beast2_installed()) { knitr::kable( head(parse_beast_state_operators(beast2_options$output_state_filename)) ) }
if (is_beast2_installed()) { bbt_delete_temp_files( inference_model = inference_model, beast2_options = beast2_options ) }
beastier::remove_beaustier_folders() beastier::check_empty_beaustier_folders()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.