set.seed(12345) cls <- plyr::ldply (row_order(p), data.frame) names(cls) <- c("id", "rowid") cls <- dplyr::arrange(cls, rowid) scaled_cluster_data2$cluster <- cls$id
特别注意,使用row_order提取聚类结果时,如果不set.seed,那聚类结果会不一致,为了提取的聚类结果与作图的结果一致,要set.seed
Referrence:
https://www.bioinfo-scrounger.com/archives/484/
https://stackoverflow.com/questions/50829127/inconsistent-clustering-with-complexheatmap
Inspired by Nancy‘s suggestion.
原文:https://www.cnblogs.com/lee-shinn/p/13040880.html