View source: R/posterior_at_ages.R
posterior_at_ages | R Documentation |
Calculate the posterior probability of ancestral host repertoires at time points in the past (ages)
posterior_at_ages(
history,
ages,
tree,
host_tree,
extant_prob = FALSE,
state = 2,
drop_empty = TRUE
)
history |
Data frame with posterior samples of interaction histories. Output from |
ages |
Vector of ages (time points in the past) at which samples will be retrieved. The
present ( |
tree |
Symbiont tree. |
host_tree |
Host tree. |
extant_prob |
Should posterior probabilities be calculated for extant network? Default to
|
state |
Which state? Default is 2. For analyses using the 3-state model, give |
drop_empty |
Logical. Remove taxa without any interactions? |
A list of three lists, containing:
"samples
" Arrays of samples x nodes x hosts, containing the state of each sample.
"post_states
" Arrays of nodes x hosts x state containing the posterior probability
for each state.
"post_repertoires
" Arrays of nodes x hosts x repertoire containing the posterior
probability for 1) the "realized"
repertoire which is defined as state 2, and 2) the
"fundamental"
repertoire which is defined as having any state (usually 1 or 2).
Each array in these lists is for one of the ages
. The number of samples is the number of
iterations in history
.
# read symbiont and host tree
data_path <- system.file("extdata", package = "evolnets")
tree <- read_tree_from_revbayes(paste0(data_path,"/tree_pieridae.tre"))
host_tree <- ape::read.tree(paste0(data_path,"/host_tree_pieridae.phy"))
# read histories sampled during MCMC
history <- read_history(paste0(data_path,"/history_thin_pieridae.txt"), burnin = 0)
# get samples at ages
ages <- c(80,70,0)
at_ages <- posterior_at_ages(history, ages, tree, host_tree)
samples_at_ages <- at_ages$samples
# get posterior probabilities of states at ages
pp_at_ages <- at_ages$post_states
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.