library(pheatmap)
data_frame = read.csv("file_path.csv",
header = T, #将第行设为列名
)
# 将第一列设为行名
rownames(data_frame) = data_frame[,1]
data_frame = data_frame[,-1] #删除第一列
pheatmap(data,
scale="row", #对行进行标准化
border=TRUE, #显示格子边框线与否
border="white", #设置边框颜色为白色
cluster_cols = F, cluster_rows = F, #行列聚类与否
clustering_method = "average", #设定不同聚类方法,默认为"complete",可以设定为‘ward‘, ‘ward.D‘, ‘ward.D2‘, ‘single‘, ‘complete‘, ‘average‘, ‘mcquitty‘, ‘median‘ or ‘centroid‘
clustering_distance_rows = "correlation", #表示行聚类使用皮尔森相关系数聚类,默认为欧氏距离"euclidean"
show_rownames = F, show_colnames = F, #行列名称的显示与否
legend = F, #图例显示与否
legend_breaks=c(-2,0,2), #设置图例范围
legend_labels = c("0", "1e-4", "1e-3", "1e-2", "1e-1", "1"), #添加图例标签
cellwidth = 15, cellheight = 12, #设置cell大小
fondsize = 2, #设置字体大小
fontsize_row = 8, fontsize_col=12, #改变横向和纵向字体大小
treeheight_col = 20, treeheight_row = 15, #设置横向纵向的树高
display_numbers = TRUE, #在每个热图格子中显示相应的数值与否
number_color = "blue", #设置热图格子中显示数值字体的颜色
number_format = "%.1e", #设置热图格子中显示数值的格式
display_numbers = matrix(ifelse(data > 5, "*", ""), nrow(data)), #设置条件展示:大于5的格子显示*
color = colorRampPalette(c("navy", "white", "firebrick3"))(50), #定义颜色
)
原文:https://www.cnblogs.com/suwen-lu/p/14492404.html