Skip to contents

Collapse OTU-level abundance using the topology of otu_tree.

Usage

agglomerate_tree(
  object,
  k,
  h,
  what = c("sum_intensity", "mean_intensity", "median_intensity")
)

Arguments

object

A microbiome_dataset object.

k

Number of clusters used to cut the tree.

h

Height used to cut the tree.

what

Aggregation method.

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:80])
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’
#> 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@otu_tree <- tidytree::treedata(
  phylo = otu_phylo,
  data = tibble::tibble(node = seq_len(length(otu_phylo$tip.label) + otu_phylo$Nnode))
)
x <- agglomerate_tree(x, k = 6)
dim(x@expression_data)
#> [1]  6 26