Basic Use of Phylocanvas

Zach Chrlop-Powers

2017-10-06

Use phylocanvas to draw phylogenetic trees. Basic options to control the tree are availalbe in this top level function. The tree shape in controlled by the treetype option. Try ‘radial’ and ‘heirarchical’ as well.

library(phylocanvas)
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.2
phycanv <- phylocanvas("(A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5)F;", treetype = "rectangular", alignlabels = T)
phycircle <- phylocanvas("(A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5)F;", treetype = "circular", nodesize = 30, linewidth = 10)
phycircle

Stylize nodes

Node styling options are available. Most of the appearance of a node can be changed here. Note below that colors can be either colornames, rgb strings or hex strings.

# Note that colors are names, rgbs or hex
phycanv %>%
  style_node("A", nodesizeratio = 4, fillcolor="rgb(0, 255, 0)") %>% 
  style_node("B", fillcolor = "blue") %>%
  style_node("C", labeltextsize = 10, shape="triangle") %>%
  style_node("D", fillcolor="#ffa500", highlighted=TRUE) 

Collapse Branches

phycircle %>% collapse_branch("E")

Rotate Branches

phycircle %>% rotate_branch("E")

Select Branches

phycanv %>% select_branch("B")
phycanv %>% select_branch("E", cascade=TRUE)

Highlight Nodes

phycanv %>% highlight_node("B")

Use Plugins

Phylocanvas has a nubmer of different plugins that extend the basic tree. These include pluings ofr metadata, scale bars, svg export, context menu on the mouse, and history. We will try to add as many as reasonable. Currently this htmlwidget sis based on the phylocanvas-quickstart so we can activate the history, context, scale, and metadata features.

# Note the scalebar is active
phylocanvas("(A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5)F;", showscalebar = TRUE)