Set otu_tree or taxa_tree on a microbiome_dataset and optionally align
it with the current dataset.
Usage
replace_tree(
object,
tree = c("otu_tree", "taxa_tree"),
value = NULL,
align = TRUE
)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’
otu_phylo <- ape::rtree(
n = nrow(x@variable_info),
tip.label = x@variable_info$variable_id
)
x <- replace_tree(
x,
tree = "otu_tree",
value = tidytree::treedata(
phylo = otu_phylo,
data = tibble::tibble(node = seq_len(length(otu_phylo$tip.label) + otu_phylo$Nnode))
)
)
class(x@otu_tree)
#> [1] "treedata"
#> attr(,"package")
#> [1] "tidytree"
