To convert an alignment to a BEAST2 posterior:
library(wiritttes) library(nLTT) library(phangorn) library(testit) options(warn = 2)
Check if BEAST2 can be found:
find_beast_jar_path()
n_taxa <- 5 phylogeny <- ape::rcoal(n = n_taxa) plot(phylogeny)
alignment <- convert_phylogeny_to_alignment( phylogeny = phylogeny, sequence_length = 10 ) image(alignment)
From that alignment, create a BEAST2 posterior
base_filename <- "alignment_to_beast_posterior_test" if (file.exists(paste0(base_filename, ".log"))) { file.remove(paste0(base_filename, ".log")) } if (file.exists(paste0(base_filename, ".trees"))) { file.remove(paste0(base_filename, ".trees")) } if (file.exists(paste0(base_filename, ".xml.state"))) { file.remove(paste0(base_filename, ".xml.state")) } posterior <- alignment_to_beast_posterior( alignment, nspp = 10, base_filename = base_filename, rng_seed = 42, beast_jar_path = find_beast_jar_path() )
Here the posterior phylogenies are plotted:
# To get the densiTree function working, phylogenies must be of class multiphylo class(posterior$trees) <- "multiPhylo"
Displaying:
densiTree( posterior$trees, type = "cladogram", alpha = 1 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.