[R] stack overflow
William Noble
noble at gs.washington.edu
Fri Sep 5 21:40:42 CEST 2003
Hello,
I am trying to do an ANOVA on a microarray data set consisting of
22690 elements. The ANOVA is fine, but when I try to put the data in
a frame in order to exporting it, I get a stack overflow. I have
found documentation on dynamic memory in R, but not on how to increase
the stack size. The code I'm using is below. If anyone has any
suggestions for a workaround here, I'd appreciate it.
Thank you.
Bill Noble
------------
R : Copyright 2003, The R Development Core Team
Version 1.7.1 (2003-06-16)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type `license()' or `licence()' for distribution details.
R is a collaborative project with many contributors.
Type `contributors()' for more information.
Type `demo()' for some demos, `help()' for on-line help, or
`help.start()' for a HTML browser interface to help.
Type `q()' to quit R.
> invisible(options(echo = TRUE))
> sdata <- read.table("../../data/02-09-03/data.mtx", header=T, row.names=1)
> infection <- gl(2,8,16, label=c("no infection", "infection"))
> labor <- gl(2,4,16, label=c("no labor", "labor"))
> aof <- function(x) {
+ m <- data.frame(infection, labor, x);
+ anova(aov(x ~ infection + labor + infection*labor, m))
+ }
> anovaresults <- apply(sdata, 1, aof)
> pvalues <- data.frame(lapply(anovaresults, function(x) { x["Pr(>F)"][1:3,] }))
Error: protect(): stack overflow
> anovaresults[[1]]
Analysis of Variance Table
Response: x
Df Sum Sq Mean Sq F value Pr(>F)
infection 1 9082 9082 0.2315 0.63907
labor 1 98722 98722 2.5164 0.13865
infection:labor 1 143262 143262 3.6517 0.08019 .
Residuals 12 470776 39231
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
> temp <- lapply(anovaresults, function(x) { x["Pr(>F)"][1:3,] })
> length(temp)
[1] 22690
> temp[1]
$"AFFX-BioB-5_at"
1 2 3
0.63906707 0.13865289 0.08018914
> gc(verbose=TRUE)
Garbage collection 62 = 23+6+33 (level 2) ...
1430471 cons cells free (28%)
17.4 Mbytes of heap free (32%)
used (Mb) gc trigger (Mb)
Ncells 3249183 86.8 4953636 132.3
Vcells 4749443 36.3 7025348 53.6
> pvalues <- data.frame(temp)
Error: protect(): stack overflow
> gc(verbose=TRUE)
Garbage collection 63 = 23+6+34 (level 2) ...
1636368 cons cells free (33%)
19.5 Mbytes of heap free (34%)
used (Mb) gc trigger (Mb)
Ncells 3317268 88.6 4953636 132.3
Vcells 4794917 36.6 7353029 56.1
More information about the R-help
mailing list