本文介绍了heatmap.2(gplots程序包)-如何删除某些单元格中的烦人线条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试生成一个简单的热图,其中包含每一行和每一列用黑线隔开.但是,由于某种原因,这只会发生第一种和最后一种颜色.我的colorpanel()中的中间颜色命令中有一条我想要的附加水平线和垂直线使用heatmap.2()绘制时摆脱.关于为什么我会看到这些行的任何建议?

I'm trying to generate a simple heatmap that has each row and columnseparated by a black line. However, for some reason this only happensfor the first and last color. The middle color in my colorpanel()command has an addition horizontal and vertical line that I would liketo get rid off when plotted using heatmap.2(). Any suggestions as to why I see these lines?

library(gplots)

my.matrix <- cbind(func.1 = c(1,2,2,1,1,3,1,2,3,1,1,2,2,3,1), func.2 =
c(2,2,1,1,3,3,1,1,2,2,1,3,3,2,1))

mycol <- colorpanel(n=3,"green","grey","red")

heatmap.2(my.matrix,Rowv=FALSE, Colv="Rowv", col=mycol, trace="both",
tracecol="black", key=FALSE, symm=FALSE, vline=NULL, hline=NULL)

链接到获得的图: https://dl.dropbox.com/u /8900971/heatmap.png

推荐答案

可能有一种方法可以做您想要的事情,但是当我读完您的最后一条评论时,我全神贯注于ggplot2.您没有说它必须是heatmap.2解决方案,所以这里是一个ggplot2解决方案.尽管我认为gplots版本值得关注:

There's probably a way to do what you want but when I read your last comment my mind went to ggplot2. You didn't say it has to be a heatmap.2 solution so here's a ggplot2 one. Though I'm assuming the gplots version is of mor interest:

library(reshape2, ggplot2)
dat <- melt(my.matrix)

ggplot(dat, aes(x=Var2,y=Var1))+
    geom_tile(aes(fill = value),colour='black') +
    scale_fill_gradientn(colours=c("green","gray","red"),
    values  = rescale(c(min(dat$value), 1000, max(dat$value)))) +
    coord_equal()

这篇关于heatmap.2(gplots程序包)-如何删除某些单元格中的烦人线条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-02 19:08