Package 'mergeTrees'

Title: Aggregating Trees
Description: Aggregates a set of trees with the same leaves to create a consensus tree. The trees are typically obtained via hierarchical clustering, hence the hclust format is used to encode both the aggregated trees and the final consensus tree. The method is exact and proven to be O(nqlog(n)), n being the individuals and q being the number of trees to aggregate.
Authors: Audrey Hulot [aut, cre], Julien Chiquet [aut] , Guillem Rigaill [aut]
Maintainer: Audrey Hulot <[email protected]>
License: GPL (>= 2)
Version: 0.1.3
Built: 2025-03-06 04:02:53 UTC
Source: https://github.com/audreh/mergetrees

Help Index


Merge a set of hclust objet into a single tree

Description

The consensus tree is built from top to bottom. Trees from hc.list argument are transformed into a list of possible splits. Each split is characterized by its heights in the tree and the two clusters it is creating. If the trees are non-binary trees (i.e. create more than two clusters in one split, or equivalently, if they merge more than two clusters), the method creates as many splits as there are clusters created. All the splits from the trees are then ordered by decreasing height. The method follow the list to find the active splits, and create a consensus tree. The method can be summarized with this property: "At height h, if elements i and j are groupes in the same clusters in all the trees, then they are in the same cluster in the consensus tree", or, equivalently: "At height h, if elements i and j are not in the same clusters in at least one of the trees, then they are not in the same cluster in the consensus tree".

Usage

mergeTrees(hc.list, standardize = FALSE)

Arguments

hc.list

a list with at least one hclust object to be merge in a single consensus tree. No other tree format is supported. The trees should have the same leaves labels, otherwise the function will stop.

standardize

a boolean indicating wether the heights of the different trees should be normalized before merged. Normalization is done by divinding the heights of fusion by their maximum in each tree.

Value

A list of class hclust, being the consensus tree, with the following components: height, merge, method, order, and, if any, labels. For more information about these components, please see hclust function help page.

Author(s)

Audrey Hulot, [email protected], Julien Chiquet, Guillem Rigaill

Examples

library(mergeTrees)
  M1 = matrix(c(0,2,3,4,2,0,1,5,3,1,0,7,4,5,7,0), ncol = 4, nrow = 4)
  M2 = matrix(c(0,1,5,6,1,0,7,9,5,7,0,2,6,9,2,0), ncol = 4, nrow = 4)
  h1 = hclust(as.dist(M1))
  h2 = hclust(as.dist(M2))
  MT = mergeTrees(list(h1, h2))
  oldpar <- par(mfrow = c(1,3))
  plot(h1)
  plot(h2)
  plot(MT)
  par(oldpar)