plot_ancestral_states | R Documentation |
Plot ancestral states on the phylogeny.
plot_ancestral_states(
tree,
at_nodes,
modules,
module_order = NULL,
type = "states",
state = 2,
repertoire = "fundamental",
layout = "rectangular",
threshold = 0.9,
point_size = 3,
point_shape = NULL,
dodge_width = 0.025,
legend = TRUE,
colors = NULL,
state_alpha = c(0.5, 1),
ladderize = FALSE
)
tree |
The phylogeny, a |
at_nodes |
A list of length 2, output from |
modules |
A |
module_order |
A character vector giving the order that modules should be plotted. Should contain each module only once. |
type |
One of |
state |
Which state? Default is 2. For analyses using the 3-state model, choose |
repertoire |
Either the |
layout |
One of |
threshold |
The posterior probability above which the ancestral states should be shown.
Defaults to 90% ( |
point_size |
How large the ancestral state points should be, default at 3. Play with this
and |
point_shape |
What point shape should be used for the ancestral states? When left |
dodge_width |
How far the points should be pushed apart, when there is multiple states at
a single node, default at 0.025. Play with this and |
legend |
Whether to display a legend for the colors. Logical vector of length 1. |
colors |
Override the default colors. Should be a character vector with as many color values as there are modules. |
state_alpha |
A numeric vector of length 2. Gives the alpha (transparency) values for the interaction type in the three-state model |
ladderize |
Logical. Whether to ladderize the tree. Default to FALSE. The ancestral states are automatically colored by module. To change what colors are used, you
can add color scales to the resulting |
A ggplot
object.
## Not run:
# read data that comes with the package
data_path <- system.file("extdata", package = "evolnets")
tree <- read_tree_from_revbayes(paste0(data_path,"/tree_pieridae.tre"))
host_tree <- read.tree(paste0(data_path,"/host_tree_pieridae.phy"))
history <- read_history(paste0(data_path,"/history_thin_pieridae.txt"), burnin = 0)
extant_net <- read.csv(paste0(data_path,"/interaction_matrix_pieridae.csv"), row.names = 1)
# calculate posterior probability of interactions at internal nodes
at_nodes <- posterior_at_nodes(history, tree, host_tree, 66 + 1:65)
# find modules in the extant network
mods <- mycomputeModules(extant_net)
# plot ancestral states
plot_ancestral_states(tree, at_nodes, mods)
# Manual colors
plot_ancestral_states(tree, at_nodes, mods, colors = rainbow(20))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.