chromatophylo: Plot tree through time with coloured edges

Description Usage Arguments Details Examples

Description

Return a geom_object() of a phylogenetic tree through time. Requires tree given to be rooted, time callibrated and bifurcating.

Usage

1
2
chromatophylo(tree, edge.cols = NULL, edge.sizes = NULL,
  legend.title = "", reduce.overlap = TRUE)

Arguments

edge.cols

data.frame of values used to colour edges (see example)

edge.sizes

data.frame of sizes used to determine the size of edges

legend.title

text for legend if edge.cols provided

reduce.overlap

boolean, TRUE will prevent edges from overlapping in plot, may take longer to plot

Details

No details – see details.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Quick example without colours
tree <- rtree (50)  # random tree with fossils
plot (tree)  # ape plot
chromatophylo (tree)  # chromatophylo


# Example with collapseTips() + calcEdgeDiversity()
# generate random tree
tree <- rtree (100)
# add edge labels to track edges after collapse
tree$edge.label <- paste0 ('edge_', 1:nrow (tree$edge))
# generate edge diversity using two intervals
ed <- calcEdgeDiversity (tree, n.intervals=2)
# iteratively drop all tip edges with > 10% tree age
tree.age <- getSize (tree, 'rtt')
ctree <- collapseTips (tree, min.length=tree.age*0.1, iterative=TRUE)
# reconstruct edge diversity data frame without dropped edges
new.ed <- data.frame (edge.label=ctree$edge.label)
new.ed$edge <- 1:nrow (new.ed)
match.counts <- match (ctree$edge.label, ed$edge.label)
new.ed$count <- ed$count[match.counts]
# convert count to logged Z-score for maximum colour separation
new.ed$col <- (log (new.ed$count) - mean (log (new.ed$count))) /
  sd (log (new.ed$count))
ed$col <- (log (ed$count) - mean (log (ed$count))) /
  sd (log (ed$count))
# plot before
chromatophylo (tree, edge.cols=ed, legend.title='Diversity') + ggtitle ('Before collapse')
# plot after
chromatophylo (ctree, edge.cols=new.ed, legend.title='Diversity') + ggtitle ('After collapse')

DomBennett/MoreTreeTools documentation built on May 6, 2019, 2:51 p.m.