phylo.discrete_trait_heatmap: Add a discrete trait heatmap to a phylogeny

View source: R/treetools.R

phylo.discrete_trait_heatmapR Documentation

Add a discrete trait heatmap to a phylogeny

Description

This function adds a discrete trait heatmap to a phylogeny produced by phylo.discrete_trait_OTU (or any ggplot2/ggtree plot).

Usage

phylo.discrete_trait_heatmap(
  plot,
  phylo,
  trait_data_frame,
  color_palette = viridis(option = "viridis", n = length(unique(as.vector(apply(X =
    trait_data_frame, MARGIN = 2, FUN = function(x) unique(x)))))),
  font_size = 2,
  font_angle = 90,
  font_offset_y = 0,
  heatmap_width = 1,
  heatmap_offset = 0.5
)

Arguments

plot

A ggplot2/ggtree plot

phylo

phylo object which was used to construct plot.

trait_data_frame

Data frame, where each row corresponds to a tip in the phylogeny, and each column corresponds to a discrete trait. Row names should match phylogeny tip labels exactly, and column names should correspond to the trait name. Cells should contain character values corresponding to the trait(s) (equivalent values in the data frame will be assigned the same color, i.e., all cells with "0" will be the same color, all cells with "cat" will be another color, etc.).

color_palette

Vector of heatmap cell color(s). Defaults to one color per unique cell value using the viridis color scale.

font_size

Size of trait names. Defaults to 2.

font_angle

Angle of trait names. Defaults to 90.

font_offset_y

Vertical offset of trait names. Defaults to 0.

heatmap_width

Width of heatmap, compared to width of tree. Defaults to 1.

heatmap_offset

Offset of heatmap to tree. Defaults to 0.5.

Value

A ggplot2 object


lmc297/bactaxR documentation built on Feb. 6, 2024, 7:41 p.m.