Get posterior samples of networks of interactions of extant lineages at given time points in the past
Source:R/get_networks.R
get_sampled_networks.Rd
Get posterior samples of networks of interactions of extant lineages at given time points in the past
Arguments
- at_ages
List of lists, with samples and posterior probabilities for each interaction of extant lineages at given ages. Usually calculated
posterior_at_ages
, see example.- state
Which state? Default is 2. For analyses using the 3-state model, choose
1
,2
or both usingc(1, 2)
(where 1 is a potential host and 2 an actual host). Note that this is also applied to the extant network.- ages
Vector of ages (time points in the past) at which samples were retrieved. By default, uses all ages present in
pp_at_ages
.
Examples
# 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 <- ape::read.tree(paste0(data_path,"/host_tree_pieridae.phy"))
history <- read_history(paste0(data_path,"/history_thin_pieridae.txt"), burnin = 0)
# choose ages
ages <- c(60, 50, 40, 0)
# calculate posterior probability of interactions
at_ages <- posterior_at_ages(history, ages, tree, host_tree)
#> Warning: Returning more (or less) than 1 row per `summarise()` group was deprecated in
#> dplyr 1.1.0.
#> ℹ Please use `reframe()` instead.
#> ℹ When switching from `summarise()` to `reframe()`, remember that `reframe()`
#> always returns an ungrouped data frame and adjust accordingly.
#> ℹ The deprecated feature was likely used in the evolnets package.
#> Please report the issue at <https://github.com/maribraga/evolnets/issues>.
# get sampled networks
sampled_nets <- get_sampled_networks(at_ages)