Skip to content

USCbiostats/jsPhyloSVG

Repository files navigation

jsPhyloSVG htmlwidget

The jsPhyloSVG javascript library provides a neat visualization tool for phylogenetic trees. This R package, which has the same name, is a wrapper that builds an htmlwidget that allows its use in R, including RMarkdown and Shiny. This is still work in progress.

Installation

You can install jsPhyloSVG from github with:

# install.packages("devtools")
devtools::install_github("USCBiostats/jsPhyloSVG")

Example

In the following, we present an example of usage of the widget. First, using the ape package, we create a random phylogenetic tree.

library(ape)
library(jsPhyloSVG)
x <- rtree(10)

Using the plot.ape method, we can get a nice tree drawn with ape:

plot(x)

Using the jsPhyloSVG function, we can visualize the same tree but using the Javascript library of the same name, jsPhyloSVG:

jsPhyloSVG(write.tree(x), width = 500)
<script type="application/json" data-for="htmlwidget-fa82ef2c1df40f596eb4">{"x":{"tree":"((((t5:0.711618749,t2:0.7536709285):0.3014811072,t9:0.006679591257):0.7295579859,(((t3:0.04991230788,t1:0.7695334381):0.1482843969,t4:0.5517065248):0.1085545681,(t7:0.4611449852,(t10:0.9377868853,t8:0.1973150689):0.6746723582):0.4731857351):0.3594574758):0.1177950753,t6:0.3163426858);","layout":"circular"},"evals":[],"jsHooks":[]}</script>