Learn R Programming

phybreak (version 0.2.0)

get.phybreak: Accessing a phybreak object

Description

Accessing a phybreak object

Usage

get.tree(phybreak.object, samplenr = 0)

get.parameters(phybreak.object, samplenr = 0, whichpars = "posterior")

get.mcmc(phybreak.object, thin = 1, nkeep = Inf)

get.phylo(phybreak.object, samplenr = 0, simmap = FALSE)

get.multiPhylo(phybreak.object, thin = 1, nkeep = Inf)

get.seqdata(phybreak.object)

Arguments

phybreak.object

An object of class phybreak.

samplenr

The posterior tree sample to choose. If samplenr = 0, the current state is used.

whichpars

Which parameters to return. Either a vector with parameter names, or "all" for all parameters, or "posterior" for parameters for which a posterior is sampled.

thin

Thinning interval.

nkeep

Number of samples to keep, counting from tail of the chain.

simmap

Whether to include class "simmap" elements (package phytools), colouring the branches on the tree to indicate hosts. Is used by plotPhylo.

Functions

  • get.tree: A data.frame with current (samplenr = 0) or sampled infectors and infection times.

  • get.parameters: A named vector with current (samplenr = 0) or sampled parameter values.

  • get.mcmc: An object of class "mcmc" (package coda), with sampled parameters, infection times, and infectors.

  • get.phylo: Returns an object of class phylo ans optionally of class "simmap" (package phytools).

  • get.multiPhylo: Returns an object of class multiphylo.

  • get.seqdata: The sequence data in class "phyDat" (package phangorn).

References

Klinkenberg et al. (2017) Simultaneous inference of phylogenetic and transmission trees in infectious disease outbreaks. PLoS Comput Biol, 13(5): e1005495.

Examples

Run this code
# NOT RUN {
#First build a phybreak-object.
simulation <- sim.phybreak(obsize = 5)
MCMCstate <- phybreak(data = simulation)
MCMCstate <- burnin.phybreak(MCMCstate, ncycles = 20)
MCMCstate <- sample.phybreak(MCMCstate, nsample = 50, thin = 2)

get.tree(MCMCstate)
get.parameters(MCMCstate)
codaobject <- get.mcmc(MCMCstate, thin = 2)
plot.phylo(get.phylo(MCMCstate))
get.seqdata(MCMCstate)

#function from package phangorn:
phangorn::parsimony(get.phylo(MCMCstate), get.seqdata(MCMCstate))

tree0 <- get.phylo(MCMCstate)
seqdata <- get.seqdata(MCMCstate)
phangorn::pml(tree0, seqdata, 
              rate = 0.75*get.parameters(MCMCstate)["mu"]) 
logLik(MCMCstate, genetic = TRUE, withinhost = FALSE, 
       sampling = FALSE, generation = FALSE) 
              #should give the same result as 'pml'
# }

Run the code above in your browser using DataLab