Skip to contents

Create an interactive phylogenetic tree using the javascript heat-tree package

Usage

heat_tree(
  tree = NULL,
  metadata = NULL,
  aesthetics = NULL,
  width = NULL,
  height = NULL,
  elementId = NULL,
  ...
)

Arguments

tree

One or more trees to plot. Can be a raw newick-formatted string, a phylo object, or a list of such inputs. If a list is provided, its names will be used to name trees.

metadata

Metadata associated with tree. Can be a data.frame or tibble with a column containing IDs matching the tree labels. The ID column is detected automatically. If there are multiple trees (a list), then a list of tables of equal length is required. If a list is provided, its names will be used to name metadata tables.

aesthetics

A named character vector defining which metadata columns are initially used to color/size tree parts. If there are multiple trees (a list), then a list of equal length is required.

width

Width of the widget (CSS units or number).

height

Height of the widget (CSS units or number).

elementId

Optional element ID for the widget.

...

Options passed to options parameter of the underlying HeatTree.heatTree() javascript function to modify the initial state of the widget.

Value

An htmlwidget object of class heat_tree that renders an interactive phylogenetic tree visualization. The object contains:

  • x: A list with tree data and options passed to JavaScript

  • width, height: Dimensions of the widget

  • elementId: Optional DOM element ID

The widget can be displayed in R Markdown, Quarto, or using and IDE like RStudio.

Examples

# Create an empty tree viewer for loading data interactively
heat_tree()
# Create a tree viewer with example data included with the package data(weisberg_2020_metadata) data(weisberg_2020_mlsa) heat_tree( tree = weisberg_2020_mlsa, metadata = weisberg_2020_metadata, aesthetics = c(tipLabelColor = 'host_type') )