Skip to contents

Draw a lightweight default tree plot for otu_tree or taxa_tree.

Usage

plot_tree(
  object,
  tree = c("otu_tree", "taxa_tree"),
  layout = "dendrogram",
  use_link = TRUE,
  color_by = NULL,
  size_by = NULL,
  abundance_method = c("sum", "mean", "median"),
  taxonomic_rank = c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species"),
  show_tip_label = TRUE,
  tip_label_size = 2.5
)

Arguments

object

A microbiome_dataset object.

tree

Tree slot to plot, either "otu_tree" or "taxa_tree".

layout

Graph layout passed to ggraph::ggraph().

Should explicit *_tree_link metadata be used before falling back to label-based matching? Defaults to TRUE.

color_by

Optional variable mapped to node color.

size_by

Optional variable mapped to node size.

abundance_method

Summary used when abundance is mapped onto nodes.

taxonomic_rank

Taxonomic rank used when mapping abundance onto taxa_tree. Ignored for otu_tree.

show_tip_label

Should tip labels be drawn? Defaults to TRUE.

tip_label_size

Text size for tip labels.

Value

A ggplot object.

Examples

data("global_patterns", package = "microbiomedataset")

x <- prune_taxa(global_patterns, variable_id = global_patterns@variable_info$variable_id[1:120])
x <- microbiomedataset::convert2microbiome_dataset(
  microbiomedataset::convert2phyloseq(x)
)
#> Found more than one class "phylo" in cache; using the first, from namespace 'phyloseq'
#> Also defined by ‘tidytree’
#> Found more than one class "phylo" in cache; using the first, from namespace 'phyloseq'
#> Also defined by ‘tidytree’
#> Found more than one class "phylo" in cache; using the first, from namespace 'phyloseq'
#> Also defined by ‘tidytree’
#> Found more than one class "phylo" in cache; using the first, from namespace 'phyloseq'
#> Also defined by ‘tidytree’
p <- plot_tree(x, tree = "taxa_tree")
class(p)
#> [1] "ggraph"          "ggplot2::ggplot" "ggplot"          "ggplot2::gg"    
#> [5] "S7_object"       "gg"