Skip to contents

Export otu_tree or taxa_tree from a microbiome_dataset in the desired representation.

Usage

extract_tree_data(
  object,
  tree = c("otu_tree", "taxa_tree"),
  data_type = c("treedata", "phylo", "table")
)

Arguments

object

A microbiome_dataset object.

tree

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

data_type

Output type, one of "treedata", "phylo", or "table".

Value

A tree object or data frame depending on data_type.

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