首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用来自gplots的自定义轴顺序和heatmap.2函数

使用来自gplots的自定义轴顺序和heatmap.2函数
EN

Stack Overflow用户
提问于 2018-02-17 00:01:52
回答 1查看 391关注 0票数 0

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

我的数据是csv格式:

代码语言:javascript
复制
"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
EN

回答 1

Stack Overflow用户

发布于 2018-02-17 00:01:52

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

代码语言:javascript
复制
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

热图是:

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48830539

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档