||
# 画热图的R包
library('ComplexHeatmap')
# 调整热图颜色的包
library("circlize")
################################################################################
# 关于此图的说明,请看GitHub上ComplexHeatmap包的介绍
# 见文本的第十部分:10 Integrate with other packages
# https://jokergoo.github.io/ComplexHeatmap-reference/book/integrate-with-other-packages.html
# 开始构造一个仿真数据
test = matrix(rnorm(200), 20, 10)
test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3
test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2
test[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)] + 4
colnames(test) = paste("Test", 1:10, sep = "")
rownames(test) = paste("Gene", 1:20, sep = "")
################################################################################
# 准备行列的分组信息
annotation_col = data.frame(
CellType = factor(rep(c("CT1", "CT2"), 5)),
Time = 1:5
)
rownames(annotation_col) = paste("Test", 1:10, sep = "")
annotation_row = data.frame(
GeneClass = factor(rep(c("Path1", "Path2", "Path3"), c(10, 4, 6)))
)
rownames(annotation_row) = paste("Gene", 1:20, sep = "")
ann_colors = list(
Time = c("white", "firebrick"),
CellType = c(CT1 = "#1B9E77", CT2 = "#D95F02"),
GeneClass = c(Path1 = "#7570B3", Path2 = "#E7298A", Path3 = "#66A61E")
)
################################################################################
# 画带有显著的星图
AA = test-0
ComplexHeatmap::pheatmap(test,
col=colorRamp2(c(0, 2, 4), c("blue","white", "red")),
border_color="white",
display_numbers = matrix(ifelse(AA > 5, "*", ""), nrow(test)),
number_color = "white",
fontsize_number = 20, # 星星的大小
treeheight_row = 20, #调解聚类线的宽度
treeheight_col = 20, #调解聚类线的宽度
annotation_col = annotation_col,
annotation_row = annotation_row,
annotation_colors = ann_colors)
# pdf("Fun0.pdf", width = 5.4, height = 8.5)
# print(ht)
# dev.off()
################################################################################
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-23 00:37
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社