繁体   English   中英

从gplots使用带有热图2功能的自定义轴顺序

[英]Use customized order of axis with heatmap.2 function from gplots

我需要使用表中排列的轴绘制热图。

我的数据是csv格式:

"X" "Mescla" "HCL" "HSL" "Kmeans" "soma"
"1" "DR" 15.33559 14.7499 14.7556 14.32343 89.78054
"2" "DA" 16.59264 14.764 14.9968 14.36513 91.08672
"3" "UMR80" 16.28646 15.88403 14.01783 15.96327 94.55977
"4" "UMR" 16.46229 15.87505 14.34763 15.87903 94.83926
"5" "MR50" 16.61305 16.04243 14.85003 16.15599 96.20576

> data
      X   merge      A1      A2    K        sum
1    DR 15.33559 14.74990 14.75560 14.32343 89.78054
2    DA 16.59264 14.76400 14.99680 14.36513 91.08672
3 UMR80 16.28646 15.88403 14.01783 15.96327 94.55977
4   UMR 16.46229 15.87505 14.34763 15.87903 94.83926
5  MR50 16.61305 16.04243 14.85003 16.15599 96.20576

我的解决方案是使用参数Rowv = FALSE和Colv = FALSE:

library(gplots)
library(RColorBrewer)

rnames <- data[,1]
mat_data <- data.matrix(data[,3:ncol(data)-1])
rownames(mat_data) <- rnames
my_palette <- colorRampPalette(c("red", "yellow", "green"))(n = 299)
col_breaks = c(seq(-1,0,length=100), # for red
seq(0,0.8,length=100),  # for yellow
seq(0.81,1,length=100)) # for green

heatmap.2(mat_data,
  main = "Rank", # heat map title
  notecol="black",      # change font color of cell labels to black
  density.info="none",  # turns off density plot inside color legend
  trace="none",         # turns off trace lines inside the heat map                                                                               
  margins =c(7,5),     # widens margins around plot
  col=my_palette,       # use on color palette defined earlier
  Rowv=FALSE,
  Colv=FALSE,
  dendrogram="none")            # turn off column clustering

热点图是: 带轴热图

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM