Description Usage Arguments Value Author(s) Examples
Convert an alignment to a BEAST2 XML input file
1 2 | alignment_to_beast_posterior(alignment, nspp, base_filename, crown_age = NA,
rng_seed = 42, beast_jar_path = find_beast_jar_path())
|
alignment |
The alignment of type DNAbin |
nspp |
The number of states in the MCMC chain BEAST2 will generate, typically one state per one thousand moves |
base_filename |
The base of the filename (the part without the extension). Must not start with '/tmp/' (in '/tmp/' the intermediate files are deleted) |
crown_age |
a positive value if the phylogeny needs a fixed crown age, NA if the crown age needs to be estimated by BEAST2 |
rng_seed |
The random number generator seed used by BEAST2 |
beast_jar_path |
Where the jar 'beast.jar' can be found |
the phylogenies of the BEAST2 posterior
Richel Bilderbeek
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | # Prepare the many filenames
base_filename <- "alignment_to_beast_posterior_example"
beast_log_filename <- paste0(base_filename, ".log")
beast_trees_filename <- paste0(base_filename, ".trees")
beast_state_filename <- paste0(base_filename, ".xml.state")
# Simulate a random phylogeny its alignment
alignment <- convert_phylogeny_to_alignment(
phylogeny = ape::rcoal(5),
sequence_length = 10,
mutation_rate = 1
)
# See if the BEAST2 .jar file is present
beast_jar_path <- find_beast_jar_path()
testit::assert(file.exists(beast_jar_path))
# Run BEAST2 and extract the phylogenies of its posterior
posterior <- alignment_to_beast_posterior(
alignment = alignment,
nspp = 10,
crown_age = 5,
base_filename = base_filename,
rng_seed = 42,
beast_jar_path = beast_jar_path
)
# Check the posterior
testit::assert(tracerer::is_posterior(posterior))
testit::assert(tracerer::is_trees_posterior(posterior$trees))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.