as.phylo.EventLogger: as.phylo

View source: R/EventLogger.R

as.phylo.EventLoggerR Documentation

as.phylo

Description

An S3 method converts events stored in the EventLogger object into an inner coalescent tree w/ option to include/exclude transmission events.

Usage

## S3 method for class 'EventLogger'
as.phylo(
  eventlog,
  transmissions = FALSE,
  migrations = FALSE,
  transitions = FALSE
)

Arguments

eventlog:

EventLogger object

transmissions:

logical; if TRUE, include transmission events as singleton nodes in tree.

migrations:

logical; if TRUE, include migration events as singleton nodes in tree.

transitions:

logical, if TRUE, include transition events as singletone nodes in tree.

Value

ape::phylo object

Examples

path <- system.file('extdata', 'structSI.yaml', package='twt')
settings <- yaml.load_file(path)
structSI <- Model$new(settings)
run <- sim.outer.tree(structSI)
eventlog <- sim.inner.tree(run)
tr <- as.phylo(eventlog, transmissions=TRUE, migrations=TRUE) 
tr

# make a nice plot
require(ggfree)
l <- tree.layout(structSI, type='r') 
plot(l)
cex <- as.integer(structSI$event.type %in% c('transmission', 'migration'))
bg <- ifelse(structSI$event.type=='transmission', 'dodgerblue', 'salmon')
points(l, cex=cex, pch=21, bg=bg)


PoonLab/twt documentation built on Nov. 7, 2024, 4:18 a.m.