heatmap.2中的错误(咯咯声) [英] Error in heatmap.2 (gplots)

查看:93
本文介绍了heatmap.2中的错误(咯咯声)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已移至新服务器并在其上安装了R版本3.0. (gplots库在2.14版中不再可用)

Ive moved on to a new server and Installed R version 3.0 on it. (gplots library was no longer available for 2.14)

使用适用于2.14版的脚本,我现在遇到了生成热图的问题.

Using a script that worked for version 2.14 I now encounter a problem generating a heatmap.

在R版本3中,我得到一个错误:

In R version 3 I get an error:

Error in lapply(args, is.character) : node stack overflow
Error in dev.flush() : node stack overflow
Error in par(op) : node stack overflow

在R 2.14版中,我收到一个错误:

In R version 2.14 I get an error:

Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

我可以通过增加选项来解决(表达式= 500000)

Which I can resolve by increasing the options(expressions=500000)

在R版本3中,增加此选项不能解决问题. 而且我仍然遇到相同的错误.

In R version 3 increasing this option does not resolve the issue. And Im still stuck with the same error.

两个脚本都相同:

y=read.table("test", row.names=1, sep="\t", header=TRUE)
hr <- hclust(dist(as.matrix(y)))
hc <- hclust(dist(as.matrix(t(y))))
mycl <- cutree(hr, k=7); mycolhc <- rainbow(length(unique(mycl)), start=0.1, end=0.9); mycolhc     <- mycolhc[as.vector(mycl)] 

install.packages("gplots")
library("gplots", character.only=TRUE)
myheatcol <- redgreen(75)

pdf("heatmap.pdf")
heatmap.2(as.matrix(y), Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc), col=myheatcol,scale="none", density.info="none", trace="none", RowSideColors=mycolhc, labRow=FALSE)
dev.off()

其中"test"是一个带有标题和行名以及40 * 5000 0/1矩阵的tdl文件

Where "test" is a tdl file with headers and row names and a 40*5000 0/1 matrix

任何帮助将不胜感激

PS:当我将数据集减少到2000行时,我将不再收到错误消息.

PS: When I reduce my data set to 2000 lines I no longer get the error.

PSS:将数据集增加到2500行会导致相同的错误;但是,删除所有非信息行(全部为1)使我剩下3700条线.使用此数据集不会导致错误.

PSS: Increasing the dataset to 2500 lines resulted in the same error; However, removing all non-informative lines (all 1s) left me with 3700 lines. Using this data set did not result in the error.

推荐答案

我是gplots包的作者.当字节编译的函数具有过多的递归调用时,将发生节点堆栈溢出"错误.

I'm the author of the gplots package. The 'node stack overflow' error occurs when a byte-compiled function has too many recursive calls.

在这种情况下,发生这种情况是因为绘制树状图对象(stats ::: plotNode)的函数是使用递归算法实现的,并且树状图对象是深层嵌套的.

In this case, it occurs because the function that plots dendrogram objects (stats:::plotNode) is implemented using a recursive algorithm and the dendrogram object is deeply nested.

最终,正确的解决方案是修改plotNode以使用迭代算法,这将防止发生递归深度错误.

Ultimately, the correct solution is to modify plotNode to use an iterative algorithm, which will prevent the recursion depth error from occuring.

在短期内,可以通过令人讨厌的黑客强制将stats ::: plotNode运行为解释代码,而不是字节编译代码.

In the short term, it is possible to force stats:::plotNode to be run as interpreted code rather then byte-compiled code via a nasty hack.

这是食谱:

## Convert a byte-compiled function to an interpreted-code function 
unByteCode <- function(fun)
    {
        FUN <- eval(parse(text=deparse(fun)))
        environment(FUN) <- environment(fun)
        FUN
    }

## Replace function definition inside of a locked environment **HACK** 
assignEdgewise <- function(name, env, value)
    {
        unlockBinding(name, env=env)
        assign( name, envir=env, value=value)
        lockBinding(name, env=env)
        invisible(value)
    }

## Replace byte-compiled function in a locked environment with an interpreted-code
## function
unByteCodeAssign <- function(fun)
    {
        name <- gsub('^.*::+','', deparse(substitute(fun)))
        FUN <- unByteCode(fun)
        retval <- assignEdgewise(name=name,
                                 env=environment(FUN),
                                 value=FUN
                                 )
        invisible(retval)
    }

## Use the above functions to convert stats:::plotNode to interpreted-code:
unByteCodeAssign(stats:::plotNode)

## Now raise the interpreted code recursion limit (you may need to adjust this,
##  decreasing if it uses to much memory, increasing if you get a recursion depth error ).
options(expressions=5e4)

## heatmap.2 should now work properly 
heatmap.2( ... )

这篇关于heatmap.2中的错误(咯咯声)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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