treePlot: Visualize the phylogenetic tree

Description Usage Arguments Details Value Author(s) Examples

Description

treePlot visualizes a phylogenetic tree.

Usage

1
2
3
4
5
6
treePlot(tree, branch = NULL, col.branch = "blue",
  col.other = "grey", point = NULL, col.point = "orange",
  size.point = 2, zoomNode = NULL, zoomLevel = NULL, zoomScale = 8,
  legend = FALSE, legend.theme = list(NULL), legend.title = c(point =
  "Title_point", branch = "Title_branch"), legend.label = NULL,
  size.line.legend = 2, size.point.legend = 3, size = 1, ...)

Arguments

tree

A phylo object

branch

A vector of node numbers labels to specify the branches to be colored. Each branch is represented by its branch node. A leaf node reprents the edge connecting the leaf and its parent.

col.branch

A vector of colors. Its length should be one or equals to the length of branch. If col.branch has the same length as branch, the branches are colored correspondingly with the col.branch. The default is blue.

col.other

A color for the branches other than those specified in branch

point

A vector of node numbers or node labels to specify the locations to add points in the tree

col.point

A color for the point. It has length equal to one.

size.point

The size for the point. It has length equal to one.

zoomNode

A vector of nodes to be zoomed in. If default (NULL), the tree is not zoomed in.

zoomLevel

A numeric vector. Its length is equal to 1 or equal to the length of zoomNode. If default (NULL), a leaf is zoomed in its direct parent level and an internal node is zoomed in its own level.

zoomScale

A numeric vector. Its length is equal to one or equal to the length of zoomNode. If zoomScale has the same length as zoomNode, the branches are zoomed in with different scales corresponding to the value of zoomScale. If default (NULL), tree is not zoomed in.

legend

TRUE or FALSE. Default is FALSE. If TRUE, the legend is created.

legend.theme

A list of arguments used for the theme in ggplot2 package (see theme ) and starting with "legend."

legend.title

A vector to specify the title of the legend. It must be named with "branch" and "point" to match with the argument branch and point.

legend.label

A list with three members: "col.branch", "col.other", and "col.point". The elements order in each member matches with the corresponding argument col.branch, col.other and col.point, and will display in the legend.

size.line.legend

The line size shown in the legend for branch

size.point.legend

The point size shown in the legend for point.

...

see also ggtree

Details

treePlot is created based on the ggtree and ggplot2. We could combine geoms from these two packages with treePlot to add geoms.

Value

A tree plot

Author(s)

Ruizhu Huang

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
data(bigTree)

# If we want to color two branches with branch node 1000 and 1400
treePlot(tree = bigTree, branch = c(1000, 1400),
 zoomNode = 1000, zoomScale = 10)


# use col.branch and col.other to specify colors
treePlot(tree = bigTree, branch = c(1000, 1400),
col.branch = c("salmon", "blue"), col.other = "grey40")

# add legend to the colored branches
treePlot(tree = bigTree, branch = c(1000, 1400),
col.branch = c("salmon", "blue"), col.other = "grey40",
legend = TRUE, legend.label = list(col.branch = c("up", "down")))

# change legend title
p <- treePlot(tree = bigTree, branch = c(1000, 1400),
col.branch = c("salmon", "blue"), col.other = "grey40",
legend = TRUE,
legend.label = list(col.branch = c("Go up", "Go down")),
legend.title = c("branch" = "Abundance"))

# change legend position (combine with ggplot2 package)
library(ggplot2)
 p + ggplot2::theme(legend.position = "bottom")

# change legend position use legend.theme
treePlot(tree = bigTree, branch = c(1000, 1400),
col.branch = c("salmon", "blue"), col.other = "grey40",
legend = TRUE,
legend.label = list(col.branch = c("Go up", "Go down")),
legend.title = c("branch" = "Truth"),
legend.theme = list(legend.position = "bottom"))


# add points
treePlot(tree = bigTree, branch = c(1000, 1400),
col.branch = c("salmon", "blue"), col.other = "grey40",
legend = TRUE,
legend.label = list(col.branch = c("Go up", "Go down")),
legend.title = c("branch" = "Truth"),
legend.theme = list(legend.position = "bottom"),
point = c(500, 5, 10))


# add points label in legend
treePlot(tree = bigTree, branch = c(1000, 1400),
col.branch = c("salmon", "blue"), col.other = "grey40",
legend = TRUE,
legend.label = list(col.branch = c("Go up", "Go down"),
col.point = "Found"),
legend.title = c("branch" = "Truth", "point"= "Estimate"),
legend.theme = list(legend.position = "bottom"),
point = c(500, 5, 10))


# add points label in legend
treePlot(tree = bigTree, branch = c(1000, 1400),
col.branch = c("salmon", "blue"), col.other = "grey40",
legend = TRUE,
legend.label = list(col.branch = c("Go up", "Go down"),
col.point = "Found", col.other = "Same"),
legend.title = c("branch" = "Truth", "point"= "Estimate"),
legend.theme = list(legend.position = "bottom"),
point = c(500, 5, 10))

markrobinsonuzh/treeAGG documentation built on May 26, 2019, 9:32 a.m.