介绍
热图展示组间基因表达差异模式
library(pheatmap)
# 模拟数据
set.seed(123) # 为了结果可重复
data <- matrix(runif(84, -2, 2), nrow = 21, ncol = 4)
rownames(data) <- c("SNX10*", "ALOX5AP", "ARHGAP17", "TBC1D13", "KLF4", "HOXA5",
"WASF2", "TDRD7*", "PTPN18", "DKFZP586I1420", "REPIN1",
"ST3GAL5", "SLC25A37", "ZNF665*", "ZNF93", "NDRG3", "HSF2",
"CEP72", "ELMO1*", "ZNF23", "ZNF24")
colnames(data) <- c("KMS-11 CfzR", "KMS-34 CfzR", "KMS-11 Parental", "KMS-34 Parental")
# 定义列注释
annotation_col <- data.frame(
Condition = factor(c("CfzR", "CfzR", "Parental", "Parental"))
)
rownames(annotation_col) <- colnames(data)
# 定义行注释
annotation_row <- data.frame(
Differential = factor(c("Up", "Down", "Up", "Up", "Down",
"Down", "Up", "Down", "Up", "Down",
"Up", "Down", "Up", "Down", "Up",
"Down", "Up", "Down", "Up", "Down",
"NS"))
)
rownames(annotation_row) <- rownames(data)
# 颜色设置
color_palette <- colorRampPalette(c("blue", "white", "red"))(100)
# 绘制热图
pheatmap(data,
color = color_palette,
cluster_rows = TRUE,
cluster_cols = FALSE,
show_rownames = TRUE,
show_colnames = TRUE,
fontsize_row = 10,
fontsize_col = 10,
legend = TRUE,
gaps_col = 2,
border_color = "white",
annotation_col = annotation_col,
annotation_row = annotation_row)