dendextend

Color dendrogram branches based on external labels uptowards the root until the label matches

喜欢而已 提交于 2019-12-07 14:42:31
问题 From question Color branches of dendrogram using an existing column, I can color the branches near the leaf of the dendrogram. The code: x<-1:100 dim(x)<-c(10,10) set.seed(1) groups<-c("red","red", "red", "red", "blue", "blue", "blue","blue", "red", "blue") x.clust<-as.dendrogram(hclust(dist(x))) x.clust.dend <- x.clust labels_colors(x.clust.dend) <- groups x.clust.dend <- assign_values_to_leaves_edgePar(x.clust.dend, value = groups, edgePar = "col") # add the colors. x.clust.dend <- assign

larger font and spacing between leaves in R dendrogram

∥☆過路亽.° 提交于 2019-12-07 06:51:57
问题 I have a dendrogram in R that I just can't get it right. I'll show you what the problem is, please check this: http://img.photobucket.com/albums/v699/rica01/Rplot-1.png How can I make the labels on the leaves, bigger and more spaced between them? Thanks. -Ricardo 回答1: Solution: use the set function, with the "labels_cex" parameter from the dendextend package. # install.packages("dendextend") library(dendextend) dend <- as.dendrogram(hclust(dist(USArrests[1:5,]))) # Like: # dend <- USArrests[1

Extract the hierarchical structure of the nodes in a dendrogram or cluster

强颜欢笑 提交于 2019-12-06 06:00:44
问题 I would like to extract the hierarchical structure of the nodes of a dendrogram or cluster. For example in the next example: library(dendextend) dend15 <- c(1:5) %>% dist %>% hclust(method = "average") %>% as.dendrogram dend15 %>% plot The nodes are classified according their position in the dendrogram (see figure below) (Figure extracted from the dendextend package's tutorial) I would like to get all the nodes for each final leaf as the next output: (the labels are ordered from left to right

larger font and spacing between leaves in R dendrogram

我与影子孤独终老i 提交于 2019-12-05 08:47:38
I have a dendrogram in R that I just can't get it right. I'll show you what the problem is, please check this: http://img.photobucket.com/albums/v699/rica01/Rplot-1.png How can I make the labels on the leaves, bigger and more spaced between them? Thanks. -Ricardo Solution: use the set function, with the "labels_cex" parameter from the dendextend package. # install.packages("dendextend") library(dendextend) dend <- as.dendrogram(hclust(dist(USArrests[1:5,]))) # Like: # dend <- USArrests[1:5,] %>% dist %>% hclust %>% as.dendrogram # By default, the dend has no text size to it (showing only the

Label and color leaf dendrogram (phylogeny) in R using ape package

三世轮回 提交于 2019-12-04 14:20:36
问题 Following a previous post (Label and color leaf dendrogram in r) I have a follow-up question. My questions are similar to the post mentioned but I wonder can it be done using ape (e.g., plot(as.phylo(fit), type="fan", labelCol) as it has more type of phylogeny. The mentioned post questions were: How can I show the group codes in leaf label (instead of the sample number)? I wish to assign a color to each code group and colored the leaf label according to it (it might happen that they will not

Extract the hierarchical structure of the nodes in a dendrogram or cluster

风流意气都作罢 提交于 2019-12-04 09:55:52
I would like to extract the hierarchical structure of the nodes of a dendrogram or cluster. For example in the next example: library(dendextend) dend15 <- c(1:5) %>% dist %>% hclust(method = "average") %>% as.dendrogram dend15 %>% plot The nodes are classified according their position in the dendrogram (see figure below) (Figure extracted from the dendextend package's tutorial) I would like to get all the nodes for each final leaf as the next output: (the labels are ordered from left to right and from bottom to top) hierarchical structure leaf_1: 3-2-1 leaf_2: 4-2-1 leaf_3: 6-5-1 leaf_4: 8-7-5

How to change dendrogram labels in r

为君一笑 提交于 2019-12-03 14:29:53
I have a dendrogram in R. It is based on hierachical clustering using hclust. I am colouring labels that are different in different colours, but when I try changing the labels of my dedrogram (to the rows of the dataframe the cluster is based on) using dendrogram = dendrogram %>% set("labels", dataframe$column) the labels are replaced, but in the wrong positions. As example: My dendrogram looks like this: ___|___ | _|_ | | | | 1 0 2 when I now try changing the labels like specified above, the labels are changed, but they are applied from left to right in their order in the dataframe. If we

Label and color leaf dendrogram (phylogeny) in R using ape package

自作多情 提交于 2019-12-03 09:55:51
Following a previous post ( Label and color leaf dendrogram in r ) I have a follow-up question. My questions are similar to the post mentioned but I wonder can it be done using ape (e.g., plot(as.phylo(fit), type="fan", labelCol) as it has more type of phylogeny. The mentioned post questions were: How can I show the group codes in leaf label (instead of the sample number)? I wish to assign a color to each code group and colored the leaf label according to it (it might happen that they will not be in the same clade and by that I can find more information)? And the code sample is: sample = data

Extract labels membership / classification from a cut dendrogram in R (i.e.: a cutree function for dendrogram)

你离开我真会死。 提交于 2019-12-03 06:01:19
问题 I'm trying to extract a classification from a dendrogram in R that I've cut at a certain height. This is easy to do with cutree on an hclust object, but I can't figure out how to do it on a dendrogram object. Further, I can't just use my clusters from the original hclust, becuase (frustratingly), the numbering of the classes from cutree is different from the numbering of classes with cut . hc <- hclust(dist(USArrests), "ave") classification<-cutree(hc,h=70) dend1 <- as.dendrogram(hc) dend2 <-

How to color a dendrogram's labels according to defined groups? (in R)

ぃ、小莉子 提交于 2019-12-01 06:29:39
I have a numeric matrix in R with 24 rows and 10,000 columns. The row names of this matrix are basically file names from which I have read the data corresponding to each of the 24 rows. Apart from this I have a separate factor list with 24 entires, specifying the group to which the 24 files belong. There are 3 groups - Alcohols, Hydrocarbon and Ester. The names and the corresponding group to which they belong look like this: > MS.mz [1] "int-354.19" "int-361.35" "int-368.35" "int-396.38" "int-408.41" "int-410.43" "int-422.43" [8] "int-424.42" "int-436.44" "int-438.46" "int-452.00" "int-480.48"