Write otu_tree or taxa_tree from a microbiome_dataset to a tree file
for use in external tools.
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
