Skip to contents

Convert otu_tree or taxa_tree into a tidy table for inspection, visualisation, or downstream joins.

Usage

melt_tree(object, tree = c("otu_tree", "taxa_tree"), include_tree = TRUE)

Arguments

object

A microbiome_dataset object.

tree

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

include_tree

Should the output include a tree column? Defaults to TRUE.

Value

A data frame.

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’
tree_tbl <- melt_tree(x, tree = "taxa_tree")
head(tree_tbl)
#>        tree parent node label   nodeClass nodeDepth
#> 1 taxa_tree    182    1    72 variable_id         8
#> 2 taxa_tree    182    2    73 variable_id         8
#> 3 taxa_tree    182    3    74 variable_id         8
#> 4 taxa_tree    182    4    75 variable_id         8
#> 5 taxa_tree    182    5    76 variable_id         8
#> 6 taxa_tree    182    6    77 variable_id         8