These functions generate a hierarchy tree using taxonomic information from a
SummarizedExperiment
object and add this hierarchy tree into the rowTree
.
getHierarchyTree(x, ...)
# S4 method for class 'SummarizedExperiment'
getHierarchyTree(x, ...)
addHierarchyTree(x, ...)
# S4 method for class 'SummarizedExperiment'
addHierarchyTree(x, ...)
addHierarchyTree
: a TreeSummarizedExperiment
whose
phylo
tree represents the hierarchy among available taxonomy
information.
getHierarchyTree
: a phylo
tree representing the
hierarchy among available taxonomy information.
addHierarchyTree
calculates a hierarchy tree from the available
taxonomic information and add it to rowTree
.
getHierarchyTree
generates a hierarchy tree from the available
taxonomic information. Internally it uses
toTree
and
resolveLoop
to sanitize
data if needed.
Please note that a hierarchy tree is not an actual phylogenetic tree. A phylogenetic tree represents evolutionary relationships among features. On the other hand, a hierarchy tree organizes species into a hierarchical structure based on their taxonomic ranks.
# Generate a tree based on taxonomic rank hierarchy (a hierarchy tree).
data(GlobalPatterns)
tse <- GlobalPatterns
getHierarchyTree(tse)
#> Warning: 16909 duplicated rows are removed
#> Warning: The root is added with label 'ALL'
#>
#> Phylogenetic tree with 1645 tips and 1089 internal nodes.
#>
#> Tip labels:
#> Species:Cenarchaeumsymbiosum, Species:pIVWA5, Species:CandidatusNitrososphaeragargensis, Species:SCA1145, Species:SCA1170, Species:Sulfolobusacidocaldarius, ...
#> Node labels:
#> root:ALL, Kingdom:Archaea, Phylum:Crenarchaeota, Class:C2, Class:Sd-NA, Class:Thaumarchaeota, ...
#>
#> Rooted; includes branch lengths.
# Add a hierarchy tree to a TreeSummarizedExperiment.
# Please note that any tree already stored in rowTree() will be overwritten.
tse <- addHierarchyTree(tse)
#> Warning: 16909 duplicated rows are removed
#> Warning: The root is added with label 'ALL'
#> Warning: Multiple nodes are found to have the same label.
tse
#> class: TreeSummarizedExperiment
#> dim: 19216 26
#> metadata(0):
#> assays(1): counts
#> rownames(19216): 549322 522457 ... 200359 271582
#> rowData names(7): Kingdom Phylum ... Genus Species
#> colnames(26): CL3 CC1 ... Even2 Even3
#> colData names(7): X.SampleID Primer ... SampleType Description
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):
#> rowLinks: a LinkDataFrame (19216 rows)
#> rowTree: 1 phylo tree(s) (1645 leaves)
#> colLinks: NULL
#> colTree: NULL