R-可视化(九):简单热图

  • 创建数据
test = scale(mtcars[,3:7])
  • 绘制热图
pheatmap(test)

在这里插入图片描述

  • 修改颜色
pheatmap(test, color = colorRampPalette(c("#00AFBB", "#FC4E07", "#E7B800"))(50))

在这里插入图片描述

  • 取消行列聚类
pheatmap(test, cluster_row = FALSE, cluster_cols = FALSE)

在这里插入图片描述

  • 取消图例
pheatmap(test, legend = FALSE)

在这里插入图片描述

  • 显示文本
pheatmap(test, display_numbers = TRUE)

在这里插入图片描述

data = matrix(ifelse(test > 0.5, "*", ""),nrow = nrow(test))
pheatmap(test, display_numbers = data)

在这里插入图片描述

  • 行列注释
annotation_col = data.frame(
  group_1 =  c('KK','KK','JJ','JJ','JJ'), 
  group_2 = 1:5
)
rownames(annotation_col) = colnames(test)
annotation_row = data.frame(
  vs = factor(mtcars$vs)
)
rownames(annotation_row) = rownames(test)
pheatmap(test, annotation_col = annotation_col, annotation_legend = FALSE)
pheatmap(test, annotation_col = annotation_col, annotation_row = annotation_row)

在这里插入图片描述
在这里插入图片描述

  • 改变列名文本角度
pheatmap(test, annotation_col = annotation_col, annotation_row = annotation_row, angle_col = "45")

在这里插入图片描述

  • Gaps in heatmaps
pheatmap(test,annotation_col = annotation_col,cluster_rows = FALSE,gaps_row = c(10, 14))

在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值