热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何利用热图在R中绘制一张热图。3包-HowtodrawaheatmapinRusingheatmap.3package

IveseenafewsourcestodrawaheatmapinRusingthestandardheatmapandheatmap.2packages,bu

I've seen a few sources to draw a heatmap in R using the standard heatmap and heatmap.2 packages, but I have yet to come across an example using the new heatmap.3 package. The only source I could find for this was https://www.biostars.org/p/18211/. However, even here, the author makes his own heatmap.3 package, not the standard heatmap.3 package from CRAN http://cran.r-project.org/web/packages/GMD/GMD.pdf. I tried figuring out how to make a heatmap with heatmap.3 from that CRAN documentation, but I didn't even know where to start. I immediately got lost in all the 50+ options. Can anyone get me started?

我已经见过一些利用标准的热图和热图绘制出R的热图。两个包,但是我还没有看到一个使用新的热图的例子。3包。我能找到的唯一来源是https://www.biostars.org/p/18211/。然而,即使在这里,作者也有自己的热图。3包,不是标准的热图。3包来自CRAN http://cran.r project.org/web/packages/gmd/gmd.pdf。我试着弄清楚如何用热图制作一张热图。从那个CRAN文件中,我甚至不知道从哪里开始。我立刻在50多个选项中迷失了。有人能让我开始吗?

My tab-delimited input file looks like this:

我的表分隔输入文件如下所示:

EntryA  EntryB  EntryC  EntryD  EntryE
John    48  31  57  55
Mary    88  11  89  78
Sarah   33  66  42  54

1 个解决方案

#1


1  

See below a basic example using heatmap 3 on your data (for a nicer plot, axes etc need to be edited). The critical step is to create a matrix with rownames. I turned the data.frame to a matrix as this is done in the examples provided in the GMD manual but it also works fine on data.frames.

在你的数据(为了更好的图表,坐标轴等需要编辑)中,你可以看到一个基本的例子。关键步骤是创建具有行名称的矩阵。在GMD手册中提供的示例中,我将数据a框架转换为一个矩阵,但它也适用于data.frame。

library(GMD)

dat<-data.frame(EntryA=as.numeric(c(48,88,33)), EntryB=as.numeric(c(31,11,66)), EntryC=as.numeric(c(57,89,42)), EntryD=as.numeric(c(55,78,54)))

rownames(dat)=c("John","Mary","Sarah") 

ndat<-as.matrix(dat)

heatmap.3(ndat, Rowv=FALSE, Colv=FALSE)

enter image description here


推荐阅读
author-avatar
陈雅洁惠真慧瑋
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有