pheatmap热图

# Create test matrix
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 = "")

Draw heatmaps

pheatmap(test) #默认行名与列名

pheatmap(test, kmeans_k = 2)

pheatmap(test, scale = "row", clustering_distance_rows = "correlation")

pheatmap(test, color = colorRampPalette(c("navy", "white", "firebrick3"))(50))

pheatmap(test, cluster_row = FALSE) #行聚类消失

pheatmap(test, legend = FALSE) #图例消失

Show text within cells

pheatmap(test, display_numbers = TRUE)

pheatmap(test, display_numbers = TRUE, number_format = "%.1e") #去掉斜杠

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

pheatmap(test, cluster_row = FALSE, legend_breaks = -1:4, legend_labels = c("0", "1e-4", "1e-3", "1e-2", "1e-1", "1"))

Fix cell sizes and save to file with correct size

画板出现问题:dev.off()

pheatmap(test, cellwidth = 15, cellheight = 12, main = "Example heatmap")

pheatmap(test, cellwidth = 15, cellheight = 12, fontsize = 8, filename = “test.pdf”)

为行和列生成注释

Display row and color annotations

annotation_col = data.frame(CellType = factor(rep(c("CT1", "CT2"), 5))

pheatmap(test, annotation_col = annotation_col) #annotation_col

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 = "")

pheatmap(test, annotation_col = annotation_col, annotation_legend = FALSE)

pheatmap(test, annotation_col = annotation_col, annotation_row = annotation_row)

Change angle of text in the columns

pheatmap(test, annotation_col = annotation_col, annotation_row = annotation_row, angle_col = “45”)
pheatmap(test, annotation_col = annotation_col, angle_col = “0”)

Specify colors

ann_colors = list(
Time = c(“white”, “firebrick”),
CellType = c(CT1 = “#1B9E77”, CT2 = “#D95F02”),
GeneClass = c(Path1 = “#7570B3”, Path2 = “#E7298A”, Path3 = “#66A61E”)
)

pheatmap(test, annotation_col = annotation_col, annotation_colors = ann_colors, main = “Title”)

pheatmap(test, annotation_col = annotation_col, annotation_row = annotation_row,
annotation_colors = ann_colors)

pheatmap(test, annotation_col = annotation_col, annotation_colors = ann_colors[2])

Gaps in heatmaps

pheatmap(test, annotation_col = annotation_col, cluster_rows = FALSE, gaps_row = c(10, 14))

pheatmap(test, annotation_col = annotation_col, cluster_rows = FALSE, gaps_row = c(10, 14),
cutree_col = 2)

Show custom strings as row/col names

labels_row = c(“”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”,
“”, “”, “Il10”, “Il15”, “Il1b”)

pheatmap(test, annotation_col = annotation_col, labels_row = labels_row)

Specifying clustering from distance matrix

drows = dist(test, method = “minkowski”)
dcols = dist(t(test), method = “minkowski”)
pheatmap(test, clustering_distance_rows = drows, clustering_distance_cols = dcols)

Modify ordering of the clusters using clustering callback option

callback = function(hc, mat){
sv = svd(t(mat))$v[,1]
dend = reorder(as.dendrogram(hc), wts = sv)
as.hclust(dend)
}

pheatmap(test, clustering_callback = callback)

Not run:

Same using dendsort package

library(dendsort)

callback = function(hc, …){dendsort(hc)}
pheatmap(test, clustering_callback = callback)

End(Not run)

制作不易,麻烦点赞

pheatmap热图相关推荐

  1. Pheatmap热图的绘制及如何调整图片

    Pheatmap热图的绘制及如何调整图片 Pheatmap包是R语言绘制热图比较强大的软件包,当然现在也有很多资料介绍这个包的使用,但是今天我写的重点不是如何使用这个包绘制热图,而是如何绘制出更好看的 ...

  2. r语言热图对列不进行聚类_R语言:手把手教你画pheatmap热图

    R语言:手把手教你画pheatmap热图 微生态 导读: pheatmap默认会对输入矩阵数据的行和列同时进行聚类,但是也可以通过布尔型参数cluster_rows和cluster_cols设置是否对 ...

  3. 获取pheatmap热图聚类后和标准化后的结果

    pheatmap是简单常用的热图绘制包,可以快速.简单.可定制的绘制漂亮热图.具体见R语言学习-热图简化和免费高颜值可定制在线绘图工具 ImageGP. 现在要解决的一个问题是图出来了,想看下转换后用 ...

  4. 热图pheatmap 热图3:热图行列分组信息注释

    热图pheatmap library(pheatmap) getwd() setwd("D:\Win10 System\Documents\WeChat Files\wxid_f27yna0 ...

  5. R:热图解释 | pheatmap包参数及详细聚类图绘制流程(一篇解决热图绘制问题)

    热图解释及pheatmap绘制热图 一.热图绘制原理 1.1 热图介绍 1.2 热图绘制准备--均一化 1.3 热图绘制方式 1.4 热图数据查看示例 二.pheatmap包简介 2.1 pheatm ...

  6. 245热图展示微生物组的物种和功能丰度或有无、距离矩阵

    245热图展示微生物组的物种和功能丰度或有无 本节作者:吴一磊 中科院微生物所 版本1.0.7,更新日期:2020年8月13日 本项目永久地址:https://github.com/YongxinLi ...

  7. R pdf大小_数据可视化 - 热图·R

    热图(如下图所示),是一种展示样本与差异变量关系的可视化方式,可以通过R/python进行绘制.本文主要分别具体介绍如何使用R实现热图绘制. R绘制热图 通常调用R的软件包"pheatmap ...

  8. r语言聚类分析_技术贴 | R语言pheatmap聚类分析和热图

    点击蓝字↑↑↑"微生态",轻松关注不迷路 本文由阿童木根据实践经验而整理,希望对大家有帮助. 原创微文,欢迎转发转载. 导读 pheatmap默认会对输入矩阵数据的行和列同时进行聚 ...

  9. 服务器画热图显示无效的变量,使用pheatmap包绘制热图

    加载所需R包 library(pheatmap) 设置工作路径 setwd("/Users/Davey/Desktop/VennDiagram/") # 清除当前环境中的变量 rm ...

最新文章

  1. 2022-2028年中国动力锂电池用橡胶密封件行业研究及前瞻分析报告
  2. 百味扶胰系假药 冒用降糖宁胶囊批号
  3. 在当今移动互联网时代_谁在提供当今最好的电子邮件体验?
  4. Java编写一个WebService并在Tomcat上发布
  5. 【LOJ2127】「HAOI2015」按位或
  6. flume avro java_flume之Avro Source和Avro Sink
  7. 1.8 Linux用户与用户组文件权限
  8. ffmpeg 自定义数据来源
  9. HBase编程api介绍(转)
  10. BlackBerry HTML5 WebWorks 平台下,让BB10应用连接上BBM
  11. 华为云weblogic10.3.6打补丁
  12. Valley Numer
  13. CSS选择器的优先级的相关介绍
  14. 《计算之魂》思考题4.4
  15. nginx的http_rewrite模块的rewrite指令
  16. 新媒体工作者必备常识
  17. 18.3 字节码指令集与解析举例 - 算数指令
  18. c语言编写u盘杀毒软件,[原创]C语言SDK U盘小偷
  19. 《南方周末》_为富求仁——积累与捐助的效率(三)
  20. 点击button按钮实现全选_全选按钮的实现及事件的处理

热门文章

  1. 学无止境,今天只是个开始
  2. 组建比较不只有箱线图,还有这些
  3. 企业自动化办公 – 请假流程(上篇)
  4. TestFlight 提交提示“处理你的请求时出错。请稍后再试”
  5. 无线通信经典文献导读
  6. HTML+CSS_第三部分(Flex弹性盒子布局、grid网格布局、移动端、移动端流式布局、移动端rem布局、响应式布局、Bootstrap框架)
  7. 【大众点评】—— 前端架构设计
  8. 深圳中学校长推荐上北大 7尖子现场决出3名额
  9. 怎么在struts中配置数据源
  10. ADB 调试手机的三种方式(USB、WLAN、WIFI)