将实验结果呈现出来—使用R语言绘制漂亮的热图
install.packages("pheatmap")#安装
library(pheatmap)#导入
test<-read.csv("C:/Users/Cheng/Desktop/资料/笔记/R学习/test.csv",header=TRUE,row.names = 1,check.names = F)
pheatmap(test)
大家可以看到图中 横纵坐标 的顺序是不是跟我excel中的不同? 相似的聚在了一起。这是因为我使用了 聚类功能(就是将相似的数据聚集成一类)。这个聚类平时是用于我们基因上的,这里不需要,我们修改一下。
pheatmap(test, scale = "row",cluster_row = FALSE,cluster_col = FALSE)
pheatmap(test,scale = "row", cluster_row = FALSE,cluster_col = TRUE,
clustering_method = "ward")
pheatmap(test, scale = "row",cluster_row = FALSE,cluster_col = FALSE,
cellwidth = 40, cellheight = 40, fontsize = 10)
pheatmap(test,scale = "row",cluster_row = FALSE,cluster_col = FALSE,
cellwidth = 40, cellheight = 40,fontsize = 10,legend_breaks = c(1:2), legend_labels = c("1","2"),
color = colorRampPalette(colors = c("navy", "white", "firebrick3"))(100))
pheatmap(test,scale = "row",cluster_row = FALSE,cluster_col = TRUE,display_numbers = TRUE, cellwidth = 40, cellheight = 40,fontsize = 10, color = colorRampPalette(colors = c("firebrick3","white"))(50), angle_col = "0", gaps_row = c(3, 6), gaps_col = c(5,10))
pheatmap(test,scale = "row",cluster_row = FALSE,cluster_col = FALSE,
cellwidth = 40, cellheight = 40,fontsize = 10,legend_breaks = c(1:2), legend_labels = c("1","2"), color = colorRampPalette(colors = c("navy", "white", "firebrick3"))(100),
angle_col = "0")
test<-read.csv("C:/Users/Cheng/Desktop/资料/笔记/R学习/test.csv",header=TRUE,row.names = 1,check.names = F)library(pheatmap)pheatmap(test,scale = "row",cluster_row = FALSE,cluster_col = FALSE, cellwidth = 40, cellheight = 40, fontsize = 10,color = colorRampPalette(colors = c("navy", "white", "firebrick3"))(100),angle_col = "0")
#legend_breaks设定legend范围,legend_labels设定legend数值
pheatmap(test, legend_breaks = c(1:2), legend_labels = c("1.0","2.0"))
#不要legend
pheatmap(test,legend = FALSE)
pheatmap(test, border=FALSE)#去掉边界线
pheatmap(test, border_color = "blue")#边界线改成蓝色
pheatmap(test, display_numbers = TRUE,number_color = "blue")#显示数字,数字颜色设定为蓝色
pheatmap(test,scale = "row",cluster_row = FALSE,cluster_col = FALSE,
cellwidth = 40, cellheight = 40,fontsize = 10,legend_breaks = c(1:2), legend_labels = c("1","2"), color = colorRampPalette(colors = c("navy", "white", "firebrick3"))(100),angle_col = "0",
gaps_row = c(3, 6), gaps_col = c(5,10))
幸苦码字加截图,不说打赏,给个关注转发不过分吧?