r - Error in heatmap.2 (gplots) -
ive moved on new server , installed r version 3.0 on it. (gplots library no longer available 2.14)
using script worked version 2.14 encounter problem generating heatmap.
in r version 3 error:
error in lapply(args, is.character) : node stack overflow error in dev.flush() : node stack overflow error in par(op) : node stack overflow in r version 2.14 error:
error: evaluation nested deeply: infinite recursion / options(expressions=)? which can resolve increasing options(expressions=500000)
in r version 3 increasing option not resolve issue. , im still stuck same error.
the script same both:
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() where "test" tdl file headers , row names , 40*5000 0/1 matrix
any appreciated
ps: when reduce data set 2000 lines no longer error.
pss: increasing dataset 2500 lines resulted in same error; however, removing non-informative lines (all 1s) left me 3700 lines. using data set did not result in error.
i'm author of gplots package. 'node stack overflow' error occurs when byte-compiled function has many recursive calls.
in case, occurs because function plots dendrogram objects (stats:::plotnode) implemented using recursive algorithm , dendrogram object nested.
ultimately, correct solution modify plotnode use iterative algorithm, prevent recursion depth error occuring.
in short term, possible force stats:::plotnode run interpreted code rather byte-compiled code via nasty hack.
here's recipe:
## convert byte-compiled function interpreted-code function unbytecode <- function(fun) { fun <- eval(parse(text=deparse(fun))) environment(fun) <- environment(fun) fun } ## replace function definition inside of 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 locked environment 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 above functions convert stats:::plotnode interpreted-code: unbytecodeassign(stats:::plotnode) ## raise interpreted code recursion limit (you may need adjust this, ## decreasing if uses memory, increasing if recursion depth error ). options(expressions=5e4) ## heatmap.2 should work heatmap.2( ... )
Comments
Post a Comment