Skip to contents

Keep or remove selected tips from otu_tree or taxa_tree without changing the abundance matrix.

Usage

prune_tree(object, tree = c("otu_tree", "taxa_tree"), tip_label, keep = TRUE)

Arguments

object

A microbiome_dataset object.

tree

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

tip_label

Tip labels to keep or remove.

keep

Should the provided tips be kept? Defaults to TRUE.

Value

A microbiome_dataset object.

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’
keep_tips <- x@variable_info$variable_id[1:5]
x <- prune_tree(x, tree = "otu_tree", tip_label = keep_tips)
class(x@otu_tree)
#> [1] "treedata"
#> attr(,"package")
#> [1] "tidytree"