热图与巨大的数据

时间:2012-01-17 14:57:08

标签: r heatmap

我正在尝试对数据进行聚类,然后使用来自gplotsheatmap.2绘制热图,该脚本可以完美地处理多达30000行的矩阵,问题是我使用的矩阵是500000行(data_sel),当我尝试群集时,我收到此错误:

heatmap.2(as.matrix(data_sel),col=greenred(10), trace="none",cexRow=0.3, cexCol=0.3,  ColSideColors=fenot.colour, margins=c(20,1), labCol="", labRow="",distfun=function(x) dist(x,method="manhattan"))
Error in vector("double", length) : vector size specified is too large

是否有任何近似使用R来绘制热图以及他的大数据?

提前致谢

1 个答案:

答案 0 :(得分:0)

这是一个非常老的问题,但这是一个使用python的解决方案,它将按比例扩展到该大小的数据:

import seaborn as sns
import pandas as pd
from matplotlib import pyplot as plt

df = pd.read_table('file.txt', header=0)
df = df.set_index('ID')
del df.index.name
df

sns.set(font_scale=0.1)

cm = sns.clustermap(df, metric="euclidean", standard_scale=1, method="ward", cmap="viridis", robust='TRUE', yticklabels=1)
cm.cax.set_visible(False)
cm.savefig('heatmap.pdf')

可能要花几个小时才能运行,但它在〜1000 *〜36000的矩阵上对我有用。