使用Pheatmap包绘制差异miRNA热图
2020-03-01 本文已影响0人
谢俊飞
说明:
测序报告中,生物公司给出的Excel文件,可以将excel另存为csv格式,便于后续分析,当然也可以安装可以直接导入excel文件的R包。
# 清除当前环境中的变量
rm(list=ls())
#设置工作路径
setwd("c:/Users/Administrator/Documents/data_analysis/2018-10-06J.F.XIE_sequencing_data/")
#载入csv文件
sign.miRNA <- read.csv("The total different expression miRNA.csv",header = TRUE)
#将'name列'当作行名
rownames(sign.miRNA) <- sign.miRNA$name
#载入用到的pheatmmap包
library(pheatmap)
#使用csv文档中的第26到37列数据(12列)
>pheatmap(sign.miRNA[,c(26:37)])
Rplot-01.png
#取log2
>pheatmap(log2(sign.miRNA[,c(26:37)]+1))
Rplot-02.png
pheatmap参数调整:
添加标题:main = "total different expression miRNA"
更改色彩搭配: color = colorRampPalette(c("navy","white","firebrick3"))(256)
设置字体大小:fontsize = 9
设定每个热图格子的边框色:border_color = "grey60"
设定行和列聚类树的高度,默认为50:treeheight_row = 20, treeheight_col =20
热图格子大小设置:cellwidth = 8, cellheight = 8
取消按行聚类:cluster_rows = FALSE
参数对行进行归一化:scale = "row"
将列聚类分为4组:cutree_cols = 4
#绘制热图
> pheatmap(log2(sign.miRNA[,c(26:37)]+1),
+ color = colorRampPalette(c("navy","white","firebrick3"))(256),
+ scale = "row", fontsize = 8, border_color = "grey60",
+ treeheight_row = 20, treeheight_col =20,
+ cellwidth = 8, cellheight = 8, cutree_cols = 4)
Rplot-03.png
构建列注释信息
# 构建列注释信息
> annotation_col = data.frame(
+ Nutrition = factor(rep(c("Sugar","Yeast"), each = 6,len=12)),
+ Microbiota = factor(rep(c("CON", "AXN"), each = 3, len = 12)))
#为注释信息添加行名
> rownames(annotation_col) = c("Sugar_1","Sugar_2","Sugar_3","Sugar_A1","Sugar_A2","Sugar_A3",
+ "Yeast_1","Yeast_2","Yeast_3","Yeast_A1","Yeast_A2","Yeast_A3")
#查看添加注释信息
> head(annotation_col)
Nutrition Microbiota
Sugar_1 Sugar CON
Sugar_2 Sugar CON
Sugar_3 Sugar CON
Sugar_A1 Sugar AXN
Sugar_A2 Sugar AXN
Sugar_A3 Sugar AXN
#添加注释信息:annotation_col = annotation_col,
#绘制热图
> pheatmap(log2(sign.miRNA[,c(26:37)]+1),
+ annotation_col = annotation_col,
+ color = colorRampPalette(c("navy","white","firebrick3"))(256),
+ scale = "row", fontsize = 8, border_color = "grey60",
+ treeheight_row = 20, treeheight_col =20,
+ cellwidth = 8, cellheight = 8, cutree_cols = 4)
Rplot-04.png
> pheatmap(log2(sign.miRNA[,c(26:37)]+1),
+ annotation_col = annotation_col,cluster_rows = FALSE,
+ color = colorRampPalette(c("navy","white","firebrick3"))(256),
+ scale = "row", fontsize = 8, border_color = "grey60",
+ treeheight_row = 20, treeheight_col =10,
+ cellwidth = 8, cellheight = 8, cutree_cols = 4, gaps_row = c(30,50))
Rplot-05.png
参考资料1:使用pheatmap包绘制热
参考资料2:热图最佳实践-pheatmap