Skip to contents

Write otu_tree or taxa_tree from a microbiome_dataset to a tree file for use in external tools.

Usage

export_tree(
  object,
  file,
  tree = c("otu_tree", "taxa_tree"),
  format = c("newick", "nexus")
)

Arguments

object

A microbiome_dataset object.

file

Output tree path.

tree

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

format

Tree format, one of "newick" or "nexus".

Value

Invisibly returns file.

Examples

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

x0 <- prune_taxa(global_patterns, variable_id = global_patterns@variable_info$variable_id[1:80])
x <- microbiomedataset::convert2microbiome_dataset(
  microbiomedataset::convert2phyloseq(x0)
)
#> 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_file <- tempfile(fileext = ".nwk")
export_tree(x, file = tree_file, tree = "taxa_tree", format = "newick")
file.exists(tree_file)
#> [1] TRUE