用R画heatmap

这算是我用R的第一个作品。

example

方法见:http://learnr.wordpress.com/2010/01/26/ggplot2-quick-heatmap-plotting/

主要的步骤:
1. 读取csv数据:
> obj <- read.csv(“…..”)
2. 做数据转换
> obj.m <- melt(obj)
这一步将一个matrix转换成 ‘rowname, columnname, value’这样形式的数据
3. 画图
(p <- ggplot(obj.m, aes(variable, Name)) + geom_tile(aes(fill = rescale), colour = “white”) + scale_fill_gradient())

做这些事情,R确实好用。

Advertisements
相册 | 此条目发表在R分类目录,贴了, 标签。将固定链接加入收藏夹。

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s