Trick in the heatmap cluster chart

Source: Internet
Author: User

Today, we are doing genetic Clustering Analysis and have encountered unexpected situations.

Library ('gplots') mydist = function (x) {dist (x, method = 'euclidean ')} myclust = function (y) {hclust (Y, method = 'ward ')} mycol = greenred (24) Hm = heatmap.2 (exp_data_diff_max_probes, scale = 'row', distfun = mydist, hclustfun = myclust, trace = 'none ', col = mycol) However, when comparing the clustering tree chart in the heat map (HM) with the tree Chart drawn by the function, we find that it is not the same! Plot (. hclust (HM $ coldendrogram) plot (colclust <-myclust (mydist (T (exp_data_diff_max_probes) Find the source code, and finally find that the tree sequence in the heat map function has a step more: reorder colv = colmeans (exp_data_diff_max_probes, Na. rm = T) DDC = reorder (. dendrogram (colclust), colv) colind = order. dendrogram (DDC) colind # The reordered cluster has the same order of heatmap

The role of reorder is described in the help document of R: "a dendrogram where each node has a further attribute value with its corresponding weight. "" There're using different orderings of a dendrogram that are consistent with the structure imposed. this function takes a dendrogram and a vector of values and reorders the dendrogram in the order of the supplied vector, maintaining the constraints on the dendrogram. "Indeed, reorder does not change the tree The clusters in the graph only reorder the elements in the clusters and clusters!

In the help document of reorder, type in the example codes:

require(graphics)set.seed(123)x <- rnorm(10)hc <- hclust(dist(x))dd <- as.dendrogram(hc)dd.reorder <- reorder(dd, 10:1)op <- par(mfrow = c(1,3))plot(dd, main = "random dendrogram 'dd'")plot(dd.reorder, main = "reorder(dd, 10:1)")plot(reorder(dd, 10:1, agglo.FUN = mean), main = "reorder(dd, 10:1, mean)")par(op)

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.