knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
beastier::remove_beaustier_folders() beastier::check_empty_beaustier_folders()
This vignette shows some examples how to set up different inference models
in babette
.
For all examples, do load babette
:
library(babette)
All these examples check that BEAST2
is installed at the default
location at r get_default_beast2_path()
. If this is not the case,
we will use some fabricated output:
posterior <- create_test_bbt_run_output() posterior$anthus_aco_sub_trees <- posterior$anthus_aco_trees names(posterior)
All examples read the alignment from a FASTA file (usually my_fasta.fas
).
fasta_filename <- get_babette_path("anthus_aco_sub.fas")
Instead of a full run, the MCMC chain length is shortened to 10K states, with a measurement every 1K states:
mcmc <- create_test_mcmc(chain_length = 10000)
We will re-create this MCMC setup, as doing so initializes it with new filenames for temporary files. These temporary files should not exist before a run and should exist after a run. Sure, there is the option to overwrite...
Using all default settings, only specify a DNA alignment.
if (is_beast2_installed()) { inference_model <- create_inference_model( mcmc = mcmc ) beast2_options <- create_beast2_options() posterior <- bbt_run_from_model( fasta_filename = fasta_filename, inference_model = inference_model, beast2_options = beast2_options ) bbt_delete_temp_files( inference_model = inference_model, beast2_options = beast2_options ) }
All other parameters are set to their defaults, as in BEAUti.
plot_densitree(posterior$anthus_aco_sub_trees, width = 2)
An alternative is to date the node of the most recent common ancestor of all taxa.
Create the MCMC:
mcmc <- create_test_mcmc(chain_length = 10000)
if (is_beast2_installed()) { inference_model <- create_inference_model( mcmc = mcmc, mrca_prior = create_mrca_prior( taxa_names = sample(get_taxa_names(fasta_filename), size = 3), alignment_id = get_alignment_id(fasta_filename), is_monophyletic = TRUE, mrca_distr = create_normal_distr( mean = 15.0, sigma = 0.025 ) ) ) beast2_options <- create_beast2_options() posterior <- bbt_run_from_model( fasta_filename = fasta_filename, inference_model = inference_model, beast2_options = beast2_options ) bbt_delete_temp_files( inference_model = inference_model, beast2_options = beast2_options ) }
Here we use an MRCA prior with fixed (non-estimated) values of the mean and standard deviation for the common ancestor node's time.
plot_densitree(posterior$anthus_aco_sub_trees, width = 2)
if (is_beast2_installed()) { inference_model <- create_inference_model( site_model = create_jc69_site_model(), mcmc = mcmc ) beast2_options <- create_beast2_options() posterior <- bbt_run_from_model( fasta_filename = fasta_filename, inference_model = inference_model, beast2_options = beast2_options ) bbt_delete_temp_files( inference_model = inference_model, beast2_options = beast2_options ) }
plot_densitree(posterior$anthus_aco_sub_trees, width = 2)
if (is_beast2_installed()) { inference_model <- create_inference_model( clock_model = create_rln_clock_model(), mcmc = mcmc ) beast2_options <- create_beast2_options() posterior <- bbt_run_from_model( fasta_filename = fasta_filename, inference_model = inference_model, beast2_options = beast2_options ) bbt_delete_temp_files( inference_model = inference_model, beast2_options = beast2_options ) }
plot_densitree(posterior$anthus_aco_sub_trees, width = 2)
if (is_beast2_installed()) { inference_model <- create_inference_model( tree_prior = create_bd_tree_prior(), mcmc = mcmc ) beast2_options <- create_beast2_options() posterior <- bbt_run_from_model( fasta_filename = fasta_filename, inference_model = inference_model, beast2_options = beast2_options ) bbt_delete_temp_files( inference_model = inference_model, beast2_options = beast2_options ) }
plot_densitree(posterior$anthus_aco_sub_trees, width = 2)
if (is_beast2_installed()) { inference_model <- create_inference_model( tree_prior = create_yule_tree_prior( birth_rate_distr = create_normal_distr( mean = 1.0, sigma = 0.1 ) ), mcmc = mcmc ) beast2_options <- create_beast2_options() posterior <- bbt_run_from_model( fasta_filename = fasta_filename, inference_model = inference_model, beast2_options = beast2_options ) bbt_delete_temp_files( inference_model = inference_model, beast2_options = beast2_options ) }
plot_densitree(posterior$anthus_aco_sub_trees, width = 2)
Thanks to Yacine Ben Chehida for this use case
if (is_beast2_installed()) { inference_model <- create_inference_model( site_model = create_hky_site_model( gamma_site_model = create_gamma_site_model(prop_invariant = 0.5) ), mcmc = mcmc ) beast2_options <- create_beast2_options() posterior <- bbt_run_from_model( fasta_filename = fasta_filename, inference_model = inference_model, beast2_options = beast2_options ) bbt_delete_temp_files( inference_model = inference_model, beast2_options = beast2_options ) }
plot_densitree(posterior$anthus_aco_sub_trees, width = 2)
Thanks to Yacine Ben Chehida for this use case
if (is_beast2_installed()) { inference_model <- create_inference_model( clock_model = create_strict_clock_model( clock_rate_param = 0.5 ), mcmc = mcmc ) beast2_options <- create_beast2_options() posterior <- bbt_run_from_model( fasta_filename = fasta_filename, inference_model = inference_model, beast2_options = beast2_options ) bbt_delete_temp_files( inference_model = inference_model, beast2_options = beast2_options ) }
plot_densitree(posterior$anthus_aco_sub_trees, width = 2)
Thanks to Paul van Els and Yacine Ben Chehida for this use case.
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.