热图生成 [英] Heatmap generation

查看:132
本文介绍了热图生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含两个不同列的Excel文件.一列的取值范围是2到15,另一列的取值范围是正数到负数.

I have an Excel file with two different columns. One column have values ranging from 2 to 15 and other column have values ranging from positive to negative numbers.

我想以这样的方式生成热图:对于第一列,每个值应具有不同的颜色.第二列应为渐变形式.

I want to produce a heatmap in such a way that for first column each value should have a different color. Second column should be in the form of a gradient.

我尝试使用excel条件格式来做到这一点.

I tried using excel conditional formatting to do this.

但是我想知道在R中有什么方法吗?

But I want to know is there any way to do it in R?

推荐答案

R命令image()获取一个矩阵,并根据该矩阵生成热图.请参阅帮助页面:?image.还值得考虑的是heatmap函数,该函数基本上是image()并应用了一些聚类.以下是这两个绘图例程中的两个示例:

The R command image() takes a matrix and makes a heat-map from it. see the help page: ?image. Also worth considering is the heatmap function, which is basically image() with some clustering applied. Below are two examples from these two plotting routines:

image(volcano,col = terrain.colors(30))
heatmap(volcano,col = terrain.colors(30))

将数据从Excel导出到R的最简单方法可能是将其另存为.csv文件(逗号或制表符分隔的文本文件),然后使用read.table()

Probably the easiest way to export your data from Excel to R is to save it as a .csv file (comma or tab-separated text file), and then import it using read.table()

这篇关于热图生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆