你好,网上看到你发布的文章“R 数据可视化 01 | 聚类热图”,按你给的代码做出的热图,右侧显示这个“matrix_24”怎么去掉?
非常感谢。
rm(list=ls())
library(pheatmap)
setwd("E:/software/R/heatmap")
dataset <- read.table('DXW.txt',header = TRUE, row.names = 1)
exp_ds = dataset[c(1:30),c(1:5)]
Group=c(rep('ori',1),
rep('R',4))
annotation_c <- data.frame(Group)
rownames(annotation_c) <- colnames(exp_ds)
pheatmap(exp_ds,
cluster_rows = T,
cluster_cols = F,
annotation_col =annotation_c,
annotation_legend=TRUE,
show_rownames = T,
show_colnames = T,
scale = "row",
color =colorRampPalette(c("#8854d0", "#ffffff","#fa8231"))(100)
)
【以下回答由 GPT 生成】
要去掉热图右侧显示的"matrix_24"这个标签,可以通过设置参数show_rownames
为FALSE
来实现。以下是修改后的代码示例:
rm(list=ls())
library(pheatmap)
setwd("E:/software/R/heatmap")
dataset <- read.table('DXW.txt', header = TRUE, row.names = 1)
exp_ds <- dataset[c(1:30),c(1:5)]
Group <- c(rep('ori',1),
rep('R',4))
annotation_c <- data.frame(Group)
rownames(annotation_c) <- colnames(exp_ds)
pheatmap(exp_ds,
cluster_rows = T,
cluster_cols = F,
annotation_col = annotation_c,
annotation_legend = TRUE,
show_rownames = F, # 设置为FALSE
show_colnames = T,
scale = "row",
color = colorRampPalette(c("#8854d0", "#ffffff", "#fa8231"))(100)
)
运行以上修改后的代码,热图右侧的"matrix_24"标签将会被去掉。
【相关推荐】