git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/GSVA@125962 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -299,7 +299,7 @@ setMethod("gsva", signature(expr="matrix", gset.idx.list="list"), |
299 | 299 |
|
300 | 300 |
if(parallel.sz > 0 && no.bootstraps > 0){ |
301 | 301 |
if((no.bootstraps %% parallel.sz) != 0){ |
302 |
- stop("'parrallel.sz' must be an integer divisor of 'no.bootsraps'" ) |
|
302 |
+ stop("'parallel.sz' must be an integer divisor of 'no.bootsraps'" ) |
|
303 | 303 |
} |
304 | 304 |
} |
305 | 305 |
n.samples <- ncol(expr) |
... | ... |
@@ -332,7 +332,7 @@ setMethod("gsva", signature(expr="matrix", gset.idx.list="list"), |
332 | 332 |
es.bootstraps <- array(NaN, c(n.gset, n.samples, no.bootstraps)) |
333 | 333 |
if(parallel.sz > 1){ |
334 | 334 |
|
335 |
- if(!.isPackageLoaded("snow")) { |
|
335 |
+ if(!.isPackageLoaded("snow")) { ## FIXME: should also open parallelism via 'parallel' |
|
336 | 336 |
stop("Please load the 'snow' library") |
337 | 337 |
} |
338 | 338 |
## copying ShortRead's strategy, the calls to the 'get()' are |
... | ... |
@@ -344,15 +344,16 @@ setMethod("gsva", signature(expr="matrix", gset.idx.list="list"), |
344 | 344 |
stopCl <- get("stopCluster", mode="function") |
345 | 345 |
|
346 | 346 |
cl <- makeCl(parallel.sz, type = parallel.type) |
347 |
- .GlobalEnv[["expr"]] <- expr |
|
348 |
- .GlobalEnv[["bootstrap.nsamples"]] <- bootstrap.nsamples |
|
349 |
- .GlobalEnv[["n.samples"]] <- n.samples |
|
350 |
- .GlobalEnv[["gset.idx.list"]] <- gset.idx.list |
|
351 |
- clExport(cl,"expr") |
|
352 |
- clExport(cl,"bootstrap.nsamples") |
|
353 |
- clExport(cl, "n.samples") |
|
354 |
- clExport(cl, "gset.idx.list") |
|
355 |
- clExport(cl, "compute.geneset.es") |
|
347 |
+ clExport(cl,"expr", envir=environment()) |
|
348 |
+ clExport(cl,"bootstrap.nsamples", envir=environment()) |
|
349 |
+ clExport(cl, "n.samples", envir=environment()) |
|
350 |
+ clExport(cl, "gset.idx.list", envir=environment()) |
|
351 |
+ clExport(cl, "rnaseq", envir=environment()) |
|
352 |
+ clExport(cl, "abs.ranking", envir=environment()) |
|
353 |
+ clExport(cl, "mx.diff", envir=environment()) |
|
354 |
+ clExport(cl, "tau", envir=environment()) |
|
355 |
+ clExport(cl, "kernel", envir=environment()) |
|
356 |
+ clExport(cl, "verbose", envir=environment()) |
|
356 | 357 |
clEvalQ(cl, library(GSVA)) |
357 | 358 |
|
358 | 359 |
clSetupRNG(cl) |
... | ... |
@@ -362,10 +363,10 @@ setMethod("gsva", signature(expr="matrix", gset.idx.list="list"), |
362 | 363 |
n.cycles <- floor(no.bootstraps / parallel.sz) |
363 | 364 |
for(i in 1:n.cycles){ |
364 | 365 |
if(verbose) cat("bootstrap cycle ", i, "\n") |
365 |
- r <- clEvalQ(cl, compute.geneset.es(expr, gset.idx.list, |
|
366 |
+ r <- clEvalQ(cl, GSVA:::compute.geneset.es(expr, gset.idx.list, |
|
366 | 367 |
sample(n.samples, bootstrap.nsamples, replace=T), |
367 | 368 |
rnaseq=rnaseq, abs.ranking=abs.ranking, mx.diff=mx.diff, |
368 |
- tau=tau, kernel=kernel, verbose=verbose)) |
|
369 |
+ tau=tau, kernel=kernel, verbose=FALSE, parallel.sz=1)) |
|
369 | 370 |
for(j in 1:length(r)){ |
370 | 371 |
es.bootstraps[,,(parallel.sz * (i-1) + j)] <- r[[j]] |
371 | 372 |
} |
... | ... |
@@ -377,7 +378,7 @@ setMethod("gsva", signature(expr="matrix", gset.idx.list="list"), |
377 | 378 |
es.bootstraps[,,i] <- compute.geneset.es(expr, gset.idx.list, |
378 | 379 |
sample(n.samples, bootstrap.nsamples, replace=T), |
379 | 380 |
rnaseq=rnaseq, abs.ranking=abs.ranking, mx.diff=mx.diff, |
380 |
- tau=tau, kernel=kernel, verbose=verbose) |
|
381 |
+ tau=tau, kernel=kernel, verbose=verbose, parallel.sz=1) |
|
381 | 382 |
} |
382 | 383 |
} |
383 | 384 |
|
... | ... |
@@ -469,7 +470,7 @@ compute.geneset.es <- function(expr, gset.idx.list, sample.idxs, rnaseq=FALSE, |
469 | 470 |
stop("In order to run calculations in parallel either the 'snow', or the 'parallel' library, should be loaded first") |
470 | 471 |
} |
471 | 472 |
|
472 |
- if (!haveParallel) { ## use snow |
|
473 |
+ if (haveSnow) { ## use snow |
|
473 | 474 |
## copying ShortRead's strategy, the calls to the 'get()' are |
474 | 475 |
## employed to quieten R CMD check, and for no other reason |
475 | 476 |
makeCl <- get("makeCluster", mode="function") |
... | ... |
@@ -498,7 +499,7 @@ compute.geneset.es <- function(expr, gset.idx.list, sample.idxs, rnaseq=FALSE, |
498 | 499 |
cat("Cleaning up\n") |
499 | 500 |
stopCl(cl) |
500 | 501 |
|
501 |
- } else { ## use parallel |
|
502 |
+ } else if (haveParallel) { ## use parallel |
|
502 | 503 |
|
503 | 504 |
mclapp <- get('mclapply', envir=getNamespace('parallel')) |
504 | 505 |
detCor <- get('detectCores', envir=getNamespace('parallel')) |
... | ... |
@@ -525,7 +526,8 @@ compute.geneset.es <- function(expr, gset.idx.list, sample.idxs, rnaseq=FALSE, |
525 | 526 |
if (verbose) { |
526 | 527 |
close(get("progressBar", envir=globalenv())) |
527 | 528 |
} |
528 |
- } |
|
529 |
+ } else |
|
530 |
+ stop("In order to run calculations in parallel either the 'snow', or the 'parallel' library, should be loaded first") |
|
529 | 531 |
|
530 | 532 |
} else { |
531 | 533 |
if (verbose) { |