2 min read

Week08 - Interactive Phylogeny

Week08 - Interactive Phylogeny

htmlwidgets News This Week

-@HarlanH - c3 htmlwidget c3r. c3 is a really nice reusable d3.js charting library that will make for a very powerful htmlwidget. Be sure to check out the c3.js demo and all of the examples.

-@yutannihilation - two more from this prolific htmlwidget-er

  1. highstockR provides a htmlwidget for Highstock, but be careful of Highcharts licensing.
  2. dcStockR will attempt to do what has baffled me for a long time which is to build a htmlwidget for dc.js. I hope he can pull it off.

This Week’s Widget - treewidget | Interactive Phylogeny + Tree

Once again, this week I can only claim contributions, and most of the credit goes to sdwfrost and Hackout2 on the R side. For the all important JavaScript, we can thank Sergei Pond and Steven Weaver from UCSD Viral Evolution Group for some brilliant work on phylotree.js. I mentioned in this post Week03 | More Network Layouts that a phylogeny viewer has been the most requested htmlwidget on Github and Twitter. As a nice coincidence, I spotted on Github the beginning of this widget and consequently discovered phylotree.js. Now I know nothing about phylogeny, but I couldn’t resist getting this thing to work. What I have since discovered is that this little beauty works well for hclust and dendrograms also.

Examples

Since it was designed for phylogeny, let’s start with an example in this field. We can use “some cytochrome b sequences” data on some North American snakes from this example from @kueda. I highly encourage you to click on nodes, reroot, tag, and just play a lot with this widget to see all that it offers.

# devtools::install("sdwfrost/epiwidgets")

library(epiwidgets)

treewidget(
"(((Crotalus_oreganus_oreganus_cytochrome_b:0.00800,Crotalus_horridus_cytochrome_b:0.05866):0.04732,(Thamnophis_elegans_terrestris_cytochrome_b:0.00366,Thamnophis_atratus_cytochrome_b:0.00172):0.06255):0.00555,(Pituophis_catenifer_vertebralis_cytochrome_b:0.00552,Lampropeltis_getula_cytochrome_b:0.02035):0.05762,((Diadophis_punctatus_cytochrome_b:0.06486,Contia_tenuis_cytochrome_b:0.05342):0.01037,Hypsiglena_torquata_cytochrome_b:0.05346):0.00779);"
)

You might have noticed that the Newick was used in this example. treewidget also accepts phylo data from the ape package. Let’s have a look using ?ape::bird.orders.

library(ape)
data(bird.orders)
treewidget(bird.orders)

I enjoy the phylogeny stuff, but in finance, I don’t think I have ever encountered a phylogenetic tree. I don’t want anyone to feel left out. With the magic of ?ape::as.phylo, we can use this really powerful interactivity on hclust and dendrograms. Let’s use the ?hclust example.

treewidget(
  as.phylo(hclust(dist(USArrests), "ave"))
)

Thanks

Thanks so much for all the work by