画热图遇到图例显示不完全 如下
image.pngcode:
for 循环批量画热图
for(i in 1:2){
heatdata=data6%>%
subset(cluster==t[i])
class <- c(rep("OMEN",52),rep("PRI",52))
annotation_col <- data.frame(class)
rownames(annotation_col) <- colnames(heatdata)[1:104]
tiff(file = paste("heatmap",t[i],".tiff"), width = 4400, height = 2500, units = "px", res = 300)
p[i]=pheatmap(heatdata[1:104], #热图的数据
cluster_rows = TRUE,#行聚类
cluster_cols = F,#列聚类,可以看出样本之间的区分度
annotation_col =annotation_col, #标注样本分类
#annotation_legend=TRUE, # 显示注释
show_rownames = F,# 显示行名
scale = "row", #以行来标准化,这个功能很不错
color=colorRampPalette(c("navy", "white", "firebrick3"))(100),
#color=colorRampPalette(c("green","black","red"))(100),
#color =colorRampPalette(c("blue", "white","red"))(100),#调色
#filename = paste("heatmap",t[i],".pdf")#是否保存
#cellwidth = 8# 格子比例
#fontsize = 10
)
dev.off()
}
这种情况下,需要设定单元格长度 比如我把 cellwidth = 8# 格子比例
for(i in 1:2){
heatdata=data6%>%
subset(cluster==t[i])
class <- c(rep("OMEN",52),rep("PRI",52))
annotation_col <- data.frame(class)
rownames(annotation_col) <- colnames(heatdata)[1:104]
tiff(file = paste("heatmap",t[i],".tiff"), width = 4400, height = 2500, units = "px", res = 300)
p[i]=pheatmap(heatdata[1:104], #热图的数据
cluster_rows = TRUE,#行聚类
cluster_cols = F,#列聚类,可以看出样本之间的区分度
annotation_col =annotation_col, #标注样本分类
#annotation_legend=TRUE, # 显示注释
show_rownames = F,# 显示行名
scale = "row", #以行来标准化,这个功能很不错
color=colorRampPalette(c("navy", "white", "firebrick3"))(100),
#color=colorRampPalette(c("green","black","red"))(100),
#color =colorRampPalette(c("blue", "white","red"))(100),#调色
#filename = paste("heatmap",t[i],".pdf")#是否保存
cellwidth = 8# 格子比例
#fontsize = 10
)
dev.off()
}
得到下图
image.png白色可以理解为图床
网友评论