【问题标题】:Labeling Row Names as Leaf Nodes Dendrogram Names in R将行名称标记为 R 中的叶节点树形图名称
【发布时间】:2017-08-21 12:21:41
【问题描述】:

我正在尝试使用我的数据集中指定的行名来标记我的树状图。

我正在使用包:hybridHclust,代码如下。

示例表(DATASET,我希望我使用了正确的格式)

  UID Condition1 Condition2 Condition3
1 Gene1 0.46 0.47 -0.02
2 Gene2 0.8 0.93 0.08
3 Gene3 0.45 0.89 1.04

DATASET_1 <- DATASET[,-1] # removes UID column which is not needed
  Gene Condition1 Condition2 Condition3

现在我删除了原始 excel 工作表所需的 UID 列,而不是聚类分析:

  Condition1 Condition2 Condition3
1 0.46 0.47 -0.02
2 0.8 0.93 0.08
3 0.45 0.89 1.04

DATASETMatrix <- as.matrix.data.frame(DATASET_2) # converts df to matrix
DATASETMatrix_R <- t(DATASETMatrix) #flips along diagonal for clustering

现在桌子是

             v1 v2 v3
Condition1 0.46 0.8 0.45
Condition2 0.47 0.93 0.89
Condition3 -0.02 0.08 1.04

并且行号名称 (1, 2, 3) 在 R studio 中消失并替换为列出的条件。

DATASETClust <- as.dendrogram((eisenCluster(DATASETMatrix_R, method = "uncentered.correlation",
                                        compatible = TRUE)), hang = -0.1) #uses uncentered Pearson correlation which is not present in hclust

library(dendextend)
DATASETClust %>% set("labels_cex", 0.25) %>% 
plot(horiz = T) # got his from somewhere online

当我运行此程序时,我将行号作为树形图上的标签,但我需要行名称(Conition1、Condition2、Condition3)并且它们需要对应于它们各自的数据(不应该只是按数字顺序)。这可能还不错,但我的实际数据集有 400 多个条件进行比较,每个条件有 4000 多个变量,并且列表将继续增长,因此手动输入名称是不可行的。

谢谢大家,我欢迎在发布到本网站时就任何格式问题提供反馈。

【问题讨论】:

    标签: r label dendrogram dendextend


    【解决方案1】:

    您可以使用 dendextend 包更改 DATASETClust(类树状图的对象)的标签(名称)。

    查看here的用法示例

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-27
      • 2020-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-23
      • 1970-01-01
      • 2016-08-05
      相关资源
      最近更新 更多