r - 具有大量数据的热图

我正在尝试对数据进行聚类,然后使用来自 gplots 的 heatmap.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 来绘制他的大数据的热图?

提前致谢

最佳答案

这是一个非常古老的问题,但这里有一个使用 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 矩阵。

https://stackoverflow.com/questions/8896778/

相关文章:

math - 执行以下 1 的补码定点整数算术运算

php - 发送邮件 sh :/usr/sbin/sendmail: Permission deni

macos - 为什么 OS X 上缺少 Emacs 图标?

image-processing - 使用小波和曲波进行特征提取

maven - 使用 build-helper-maven-plugin 和 multi modul

xml - Solr DataImportHandler 不适用于 XML 文件

python - 如何使用 setuptools 和 setup.py 从包中排除单个文件

php - 如何将动态生成的 PDF 文件保存到 zip 文件中?

django-admin - Django 管理员覆盖字段集

emacs - 在 emacs(或 DDD)中使用 gdb 时无法设置断点