Skip to contents

Draw a composite phylogenetic tree + cell-by-variant heatmap for mtDNA data.

Usage

plot_tree_heatmap_teng_cw(
  gtree,
  df_var,
  draw_depth,
  branch_width = 0.25,
  root_edge = TRUE,
  dot_size = 1,
  ylim = NULL,
  clade_annot = NULL,
  tip_annot = NULL,
  title = NULL,
  label_site = FALSE,
  cell_annot = NULL,
  tip_lab = FALSE,
  node_lab = FALSE,
  layered = FALSE,
  annot_bar_height = 0.1,
  clade_bar_height = 1,
  het_max = 0.1,
  conf_min = 0.5,
  conf_max = 0.5,
  conf_label = FALSE,
  branch_length = TRUE,
  node_conf = FALSE,
  annot_scale = NULL,
  annot_legend = FALSE,
  label_group = FALSE,
  annot_legend_title = "",
  text_size = 3,
  label_size = 1,
  mut = NULL,
  post_max = FALSE,
  mark_low_cov = FALSE,
  facet_by_group = FALSE,
  flip = FALSE
)

Arguments

gtree

A phylo or tbl_graph object representing the clonal tree.

df_var

A data.frame with at least columns: cell, variant, a (alt), d (depth), or a precomputed vaf column between 0 and 1.

draw_depth

Logical; draw branch width by depth when available.

branch_width

Numeric scaling for branch width drawing.

root_edge

Logical; whether to include a root edge.

dot_size

Numeric size for node/tip dots.

ylim

Optional y limits.

clade_annot

Optional data.frame of clade annotations with columns cell, clade, and optional score.

tip_annot

Optional data.frame of tip annotations (columns: cell, annot).

title

Optional plot title.

label_site

Logical; label mutational sites on the tree.

cell_annot

Either a single data.frame (columns: cell, annot) or a named list of such data.frames; each element produces a stacked annotation bar.

tip_lab, node_lab

Logical; show tip/node labels.

layered

Logical; layered rendering for annotation bars.

annot_bar_height, clade_bar_height

Numeric heights for stacked bars.

het_max

Numeric VAF max for color scale.

conf_min, conf_max

Numeric limits for node confidence fill.

conf_label

Logical; render numeric confidence labels.

branch_length

Logical; use branch lengths if available.

node_conf

Logical; display internal node confidence.

annot_scale

Optional scaling for annotation bars.

annot_legend, label_group

Logical flags controlling annotation display.

annot_legend_title

Character legend title used when cell_annot is a single table (named list elements use their own names as titles).

text_size, label_size

Numeric text sizes.

mut

Optional column name in node data to color nodes by.

post_max, mark_low_cov, facet_by_group, flip

Additional display flags.

Value

A patchwork/ggplot object combining tree, heatmap, and optional bars.

Details

This implementation is derived from the mitodrift visualization by Teng ("plot_redeem_heatmap"), adapted and extended to support multiple stacked annotation bars and consolidated legends.