5

我知道如何使用 pheatmap 通过注释类别对行(基因)进行分组,并且我知道如何对整组行(基因)执行 Person 的相关聚类,但我想要完成的是执行聚类(并显示独立树状图)独立地在每个类别上。

这甚至可能吗?或者我是否被迫为每个类别创建单独的热图以在类别基础上进行聚类?

在下面检查我的 MWE:

set.seed(1)
library(pheatmap)

mymat <- matrix(rexp(600, rate=.1), ncol=12)
colnames(mymat) <- c(rep("treatment_1", 3), rep("treatment_2", 3), rep("treatment_3", 3), rep("treatment_4", 3))
rownames(mymat) <- paste("gene", 1:dim(mymat)[1], sep="_")

annotdf <- data.frame(row.names = paste("gene", 1:dim(mymat)[1], sep="_"), category = c(rep("CATEGORY_1", 10), rep("CATEGORY_2", 10), rep("CATEGORY_3", 10), rep("CATEGORY_4", 10), rep("CATEGORY_5", 10)))

pheatmap(mymat,
     scale="row",
     cluster_rows = FALSE,
     cluster_cols = FALSE,
     gaps_row=c(10,20,30,40),
     gaps_col=c(3,6,9),
     cellheight = 6,
     cellwidth = 20,
     border_color=NA,
     fontsize_row = 6,
     filename = "TEST1.png",
     annotation_row = annotdf
)

pheatmap(mymat,
     scale="row",
     cluster_rows = TRUE,
     cluster_cols = FALSE,
     clustering_distance_rows = "correlation",#Pearson's
     clustering_method = "average",
     gaps_col=c(3,6,9),
     cellheight = 6,
     cellwidth = 20,
     border_color=NA,
     fontsize_row = 6,
     filename = "TEST2.png",
     annotation_row = annotdf
)

产生:

测试1

测试2

4

0 回答 0