Browse code

Added the possibility of doing the ECDF estimation using parallel calculations.

Robert Castelo authored on 29/11/2019 12:12:34
Showing 5 changed files

... ...
@@ -1,14 +1,13 @@
1 1
 Package: GSVA
2
-Version: 1.35.1
2
+Version: 1.35.2
3 3
 Title: Gene Set Variation Analysis for microarray and RNA-seq data
4 4
 Authors@R: c(person("Justin", "Guinney", role=c("aut", "cre"), email="justin.guinney@sagebase.org"),
5 5
              person("Robert", "Castelo", role="aut", email="robert.castelo@upf.edu"),
6 6
              person("Joan", "Fernandez", role="ctb", email="joanfernandez1331@gmail.com"))
7 7
 Depends: R (>= 3.5.0)
8 8
 Imports: methods, BiocGenerics, Biobase, GSEABase (>= 1.17.4),
9
-         geneplotter, shiny, shinythemes
10
-Suggests: limma, RColorBrewer, genefilter,
11
-          edgeR, snow, parallel, GSVAdata
9
+         parallel, BiocParallel, geneplotter, shiny, shinythemes
10
+Suggests: limma, RColorBrewer, genefilter, edgeR, snow, GSVAdata
12 11
 Description: Gene Set Variation Analysis (GSVA) is a non-parametric, unsupervised method for estimating variation of gene set enrichment through the samples of a expression data set. GSVA performs a change in coordinate systems, transforming the data from a gene by sample matrix to a gene-set by sample matrix, thereby allowing the evaluation of pathway enrichment for each sample. This new matrix of GSVA enrichment scores facilitates applying standard analytical methods like functional enrichment, survival analysis, clustering, CNV-pathway analysis or cross-tissue pathway analysis, in a pathway-centric manner.
13 12
 License: GPL (>= 2)
14 13
 LazyLoad: yes
... ...
@@ -9,11 +9,17 @@ importClassesFrom(GSEABase, GeneSetCollection)
9 9
 
10 10
 importMethodsFrom(Biobase, featureNames,
11 11
                            phenoData,
12
-                           experimentData)
12
+                           experimentData,
13
+                           esApply,
14
+                           exprs,
15
+                           annotation)
13 16
 
14 17
 importMethodsFrom(GSEABase, geneIds,
15 18
                             incidence)
16 19
 
20
+importMethodsFrom(BiocParallel, bpiterate,
21
+                                "bpworkers<-")
22
+
17 23
 importFrom(graphics, plot)
18 24
 importFrom(stats, ecdf,
19 25
                   na.omit)
... ...
@@ -21,11 +27,14 @@ importFrom(utils, setTxtProgressBar,
21 27
                   txtProgressBar,
22 28
                   read.csv,
23 29
                   write.csv)
24
-importFrom(Biobase, exprs,
25
-                    annotation)
26 30
 importFrom(GSEABase, AnnoOrEntrezIdentifier,
27 31
                      mapIdentifiers,
28 32
                      getGmt)
33
+importFrom(parallel, splitIndices)
34
+importFrom(BiocParallel, SerialParam,
35
+                         MulticoreParam,
36
+                         multicoreWorkers,
37
+                         bpnworkers)
29 38
 importFrom(geneplotter, multidensity)
30 39
 importFrom(shinythemes, shinytheme)
31 40
 
... ...
@@ -12,18 +12,19 @@ setMethod("gsva", signature(expr="ExpressionSet", gset.idx.list="list"),
12 12
   abs.ranking=FALSE,
13 13
   min.sz=1,
14 14
   max.sz=Inf,
15
-  parallel.sz=0, 
15
+  parallel.sz=1L, 
16 16
   parallel.type="SOCK",
17 17
   mx.diff=TRUE,
18 18
   tau=switch(method, gsva=1, ssgsea=0.25, NA),
19 19
   ssgsea.norm=TRUE,
20
-  verbose=TRUE)
20
+  verbose=TRUE,
21
+  BPPARAM=SerialParam(progressbar=verbose))
21 22
 {
22 23
   method <- match.arg(method)
23 24
   kcdf <- match.arg(kcdf)
24 25
 
25 26
   ## filter out genes with constant expression values
26
-  sdGenes <- Biobase::esApply(expr, 1, sd)
27
+  sdGenes <- esApply(expr, 1, sd)
27 28
   if (any(sdGenes == 0) || any(is.na(sdGenes))) {
28 29
     warning(sum(sdGenes == 0 | is.na(sdGenes)),
29 30
             " genes with constant expression values throuhgout the samples.")
... ...
@@ -62,7 +63,8 @@ setMethod("gsva", signature(expr="ExpressionSet", gset.idx.list="list"),
62 63
   }
63 64
 
64 65
   eSco <- .gsva(exprs(expr), mapped.gset.idx.list, method, kcdf, rnaseq, abs.ranking,
65
-                parallel.sz, parallel.type, mx.diff, tau, kernel, ssgsea.norm, verbose)
66
+                parallel.sz, parallel.type, mx.diff, tau, kernel, ssgsea.norm,
67
+                verbose, BPPARAM) 
66 68
 
67 69
   eScoEset <- new("ExpressionSet", exprs=eSco, phenoData=phenoData(expr),
68 70
                   experimentData=experimentData(expr), annotation="")
... ...
@@ -79,18 +81,19 @@ setMethod("gsva", signature(expr="ExpressionSet", gset.idx.list="GeneSetCollecti
79 81
   abs.ranking=FALSE,
80 82
   min.sz=1,
81 83
   max.sz=Inf,
82
-  parallel.sz=0, 
84
+  parallel.sz=1L, 
83 85
   parallel.type="SOCK",
84 86
   mx.diff=TRUE,
85 87
   tau=switch(method, gsva=1, ssgsea=0.25, NA),
86 88
   ssgsea.norm=TRUE,
87
-  verbose=TRUE)
89
+  verbose=TRUE,
90
+  BPPARAM=SerialParam(progressbar=verbose))
88 91
 {
89 92
   method <- match.arg(method)
90 93
   kcdf <- match.arg(kcdf)
91 94
 
92 95
   ## filter out genes with constant expression values
93
-  sdGenes <- Biobase::esApply(expr, 1, sd)
96
+  sdGenes <- esApply(expr, 1, sd)
94 97
   if (any(sdGenes == 0) || any(is.na(sdGenes))) {
95 98
     warning(sum(sdGenes == 0 | is.na(sdGenes)),
96 99
             " genes with constant expression values throuhgout the samples.")
... ...
@@ -107,8 +110,10 @@ setMethod("gsva", signature(expr="ExpressionSet", gset.idx.list="GeneSetCollecti
107 110
     cat("Mapping identifiers between gene sets and feature names\n")
108 111
 
109 112
   ## map gene identifiers of the gene sets to the features in the chip
110
-  mapped.gset.idx.list <- GSEABase::mapIdentifiers(gset.idx.list,
111
-                                                   GSEABase::AnnoOrEntrezIdentifier(Biobase::annotation(expr)))
113
+  ## Biobase::annotation() is necessary to disambiguate from the
114
+  ## 'annotation' argument
115
+  mapped.gset.idx.list <- mapIdentifiers(gset.idx.list,
116
+                                         AnnoOrEntrezIdentifier(Biobase::annotation(expr)))
112 117
   
113 118
   ## map to the actual features for which expression data is available
114 119
   tmp <- lapply(geneIds(mapped.gset.idx.list),
... ...
@@ -133,7 +138,8 @@ setMethod("gsva", signature(expr="ExpressionSet", gset.idx.list="GeneSetCollecti
133 138
   }
134 139
 
135 140
   eSco <- .gsva(exprs(expr), mapped.gset.idx.list, method, kcdf, rnaseq, abs.ranking,
136
-                parallel.sz, parallel.type, mx.diff, tau, kernel, ssgsea.norm, verbose)
141
+                parallel.sz, parallel.type, mx.diff, tau, kernel, ssgsea.norm,
142
+                verbose, BPPARAM)
137 143
 
138 144
   eScoEset <- new("ExpressionSet", exprs=eSco, phenoData=phenoData(expr),
139 145
                   experimentData=experimentData(expr), annotation="")
... ...
@@ -150,12 +156,13 @@ setMethod("gsva", signature(expr="matrix", gset.idx.list="GeneSetCollection"),
150 156
   abs.ranking=FALSE,
151 157
   min.sz=1,
152 158
   max.sz=Inf,
153
-  parallel.sz=0, 
159
+  parallel.sz=1L, 
154 160
   parallel.type="SOCK",
155 161
   mx.diff=TRUE,
156 162
   tau=switch(method, gsva=1, ssgsea=0.25, NA),
157 163
   ssgsea.norm=TRUE,
158
-  verbose=TRUE)
164
+  verbose=TRUE,
165
+  BPPARAM=SerialParam(progressbar=verbose))
159 166
 {
160 167
   method <- match.arg(method)
161 168
   kcdf <- match.arg(kcdf)
... ...
@@ -180,8 +187,8 @@ setMethod("gsva", signature(expr="matrix", gset.idx.list="GeneSetCollection"),
180 187
     if (verbose)
181 188
       cat("Mapping identifiers between gene sets and feature names\n")
182 189
 
183
-    mapped.gset.idx.list <- GSEABase::mapIdentifiers(gset.idx.list,
184
-                                                     GSEABase::AnnoOrEntrezIdentifier(annotation))
190
+    mapped.gset.idx.list <- mapIdentifiers(gset.idx.list,
191
+                                           AnnoOrEntrezIdentifier(annotation))
185 192
   }
186 193
   
187 194
   ## map to the actual features for which expression data is available
... ...
@@ -211,7 +218,8 @@ setMethod("gsva", signature(expr="matrix", gset.idx.list="GeneSetCollection"),
211 218
   }
212 219
 
213 220
   rval <- .gsva(expr, mapped.gset.idx.list, method, kcdf, rnaseq, abs.ranking,
214
-                parallel.sz, parallel.type, mx.diff, tau, kernel, ssgsea.norm, verbose)
221
+                parallel.sz, parallel.type, mx.diff, tau, kernel, ssgsea.norm,
222
+                verbose, BPPARAM)
215 223
 
216 224
   rval
217 225
 })
... ...
@@ -223,12 +231,13 @@ setMethod("gsva", signature(expr="matrix", gset.idx.list="list"),
223 231
   abs.ranking=FALSE,
224 232
   min.sz=1,
225 233
   max.sz=Inf,
226
-  parallel.sz=0, 
234
+  parallel.sz=1L, 
227 235
   parallel.type="SOCK",
228 236
   mx.diff=TRUE,
229 237
   tau=switch(method, gsva=1, ssgsea=0.25, NA),
230 238
   ssgsea.norm=TRUE,
231
-  verbose=TRUE)
239
+  verbose=TRUE,
240
+  BPPARAM=SerialParam(progressbar=verbose))
232 241
 {
233 242
   method <- match.arg(method)
234 243
   kcdf <- match.arg(kcdf)
... ...
@@ -272,7 +281,8 @@ setMethod("gsva", signature(expr="matrix", gset.idx.list="list"),
272 281
   }
273 282
 
274 283
   rval <- .gsva(expr, mapped.gset.idx.list, method, kcdf, rnaseq, abs.ranking,
275
-                parallel.sz, parallel.type, mx.diff, tau, kernel, ssgsea.norm, verbose)
284
+                parallel.sz, parallel.type, mx.diff, tau, kernel, ssgsea.norm,
285
+                verbose, BPPARAM)
276 286
 
277 287
   rval
278 288
 })
... ...
@@ -282,25 +292,49 @@ setMethod("gsva", signature(expr="matrix", gset.idx.list="list"),
282 292
   kcdf=c("Gaussian", "Poisson", "none"),
283 293
   rnaseq=FALSE,
284 294
   abs.ranking=FALSE,
285
-  parallel.sz=0, 
295
+  parallel.sz=1L,
286 296
   parallel.type="SOCK",
287 297
   mx.diff=TRUE,
288 298
   tau=1,
289 299
   kernel=TRUE,
290 300
   ssgsea.norm=TRUE,
291
-  verbose=TRUE)
292
-{
293
-	if(length(gset.idx.list) == 0){
294
-		stop("The gene set list is empty!  Filter may be too stringent.")
301
+  verbose=TRUE,
302
+  BPPARAM=SerialParam(progressbar=verbose)) {
303
+
304
+	if (length(gset.idx.list) == 0) {
305
+		stop("The gene set list is empty! Filter may be too stringent.")
295 306
 	}
307
+
308
+  parallel.sz <- as.integer(parallel.sz)
309
+  if (parallel.sz < 1L)
310
+    parallel.sz <- 1L
296 311
 	
312
+  ## because we keep the argument 'parallel.sz' for backwards compatibility
313
+  ## we need to harmonize it with the contents of BPPARAM
314
+  if (parallel.sz > 1L && class(BPPARAM) == "SerialParam") {
315
+    BPPARAM=MulticoreParam(progressbar=verbose, workers=parallel.sz, tasks=100)
316
+    if (verbose)
317
+      message(sprintf("Setting parallel calculations through a multicore back-end with workers=%d and tasks=100.",
318
+              parallel.sz))
319
+  } else if (parallel.sz == 1L && class(BPPARAM) != "SerialParam") {
320
+    parallel.sz <- bpnworkers(BPPARAM)
321
+    if (verbose)
322
+      message(sprintf("Setting parallel calculations through a %s back-end with %d workers.",
323
+              class(BPPARAM), parallel.sz))
324
+  } else if (parallel.sz > 1L && class(BPPARAM) != "SerialParam") {
325
+    bpworkers(BPPARAM) <- parallel.sz
326
+    if (verbose)
327
+      message(sprintf("Setting parallel calculations through a %s back-end with %d workers.",
328
+              class(BPPARAM), parallel.sz))
329
+  }
330
+
297 331
   if (method == "ssgsea") {
298 332
 	  if(verbose)
299 333
 		  cat("Estimating ssGSEA scores for", length(gset.idx.list),"gene sets.\n")
300 334
 
301 335
     return(ssgsea(expr, gset.idx.list, alpha=tau, parallel.sz=parallel.sz,
302 336
                   parallel.type=parallel.type, normalization=ssgsea.norm,
303
-                  verbose=verbose))
337
+                  verbose=verbose, BPPARAM=BPPARAM))
304 338
   }
305 339
 
306 340
   if (method == "zscore") {
... ...
@@ -310,7 +344,8 @@ setMethod("gsva", signature(expr="matrix", gset.idx.list="list"),
310 344
 	  if(verbose)
311 345
 		  cat("Estimating combined z-scores for", length(gset.idx.list),"gene sets.\n")
312 346
 
313
-    return(zscore(expr, gset.idx.list, parallel.sz, parallel.type, verbose))
347
+    return(zscore(expr, gset.idx.list, parallel.sz, parallel.type,
348
+                  verbose, BPPARAM=BPPARAM))
314 349
   }
315 350
 
316 351
   if (method == "plage") {
... ...
@@ -320,7 +355,8 @@ setMethod("gsva", signature(expr="matrix", gset.idx.list="list"),
320 355
 	  if(verbose)
321 356
 		  cat("Estimating PLAGE scores for", length(gset.idx.list),"gene sets.\n")
322 357
 
323
-    return(plage(expr, gset.idx.list, parallel.sz, parallel.type, verbose))
358
+    return(plage(expr, gset.idx.list, parallel.sz, parallel.type,
359
+                 verbose, BPPARAM=BPPARAM))
324 360
   }
325 361
 
326 362
 	if(verbose)
... ...
@@ -335,11 +371,12 @@ setMethod("gsva", signature(expr="matrix", gset.idx.list="list"),
335 371
 	rownames(es.obs) <- names(gset.idx.list)
336 372
 	
337 373
 	if (verbose)
338
-    cat("Computing observed enrichment scores\n")
374
+    cat("Computing GSVA enrichment scores\n")
339 375
 	es.obs <- compute.geneset.es(expr, gset.idx.list, 1:n.samples,
340
-                               rnaseq=rnaseq, abs.ranking=abs.ranking, parallel.sz=parallel.sz,
341
-                               parallel.type=parallel.type, mx.diff=mx.diff, tau=tau,
342
-                               kernel=kernel, verbose=verbose)
376
+                               rnaseq=rnaseq, abs.ranking=abs.ranking,
377
+                               parallel.sz=parallel.sz, parallel.type=parallel.type,
378
+                               mx.diff=mx.diff, tau=tau, kernel=kernel,
379
+                               verbose=verbose, BPPARAM=BPPARAM)
343 380
 	
344 381
 	colnames(es.obs) <- colnames(expr)
345 382
 	rownames(es.obs) <- names(gset.idx.list)
... ...
@@ -377,8 +414,9 @@ compute.gene.density <- function(expr, sample.idxs, rnaseq=FALSE, kernel=TRUE){
377 414
 }
378 415
 
379 416
 compute.geneset.es <- function(expr, gset.idx.list, sample.idxs, rnaseq=FALSE,
380
-                               abs.ranking, parallel.sz=0, parallel.type="SOCK",
381
-                               mx.diff=TRUE, tau=1, kernel=TRUE, verbose=TRUE){
417
+                               abs.ranking, parallel.sz=1L, parallel.type="SOCK",
418
+                               mx.diff=TRUE, tau=1, kernel=TRUE,
419
+                               verbose=TRUE, BPPARAM=SerialParam(progressbar=verbose)) {
382 420
 	num_genes <- nrow(expr)
383 421
 	if (verbose) {
384 422
     if (kernel) {
... ...
@@ -392,7 +430,7 @@ compute.geneset.es <- function(expr, gset.idx.list, sample.idxs, rnaseq=FALSE,
392 430
   if (parallel.sz > 0 && length(sample.idxs > 100) && nrow(expr) > 100) {
393 431
     cat(sprintf("Using %d cores in parallel for ECDFs estimation\n", parallel.sz))
394 432
     iter <- function(Y, n_chunks=BiocParallel::multicoreWorkers()) {
395
-      idx <- parallel::splitIndices(nrow(Y), min(nrow(Y), n_chunks))
433
+      idx <- splitIndices(nrow(Y), min(nrow(Y), n_chunks))
396 434
       i <- 0L
397 435
       function() {
398 436
         if (i == length(idx))
... ...
@@ -401,13 +439,12 @@ compute.geneset.es <- function(expr, gset.idx.list, sample.idxs, rnaseq=FALSE,
401 439
         Y[idx[[i]], , drop=FALSE]
402 440
       }
403 441
     }
404
-    gene.density <- BiocParallel::bpiterate(iter(expr, 100),
405
-                        GSVA:::compute.gene.density,
406
-                        sample.idxs=sample.idxs, rnaseq=rnaseq, kernel=kernel,
407
-                        REDUCE=rbind, reduce.in.order=TRUE,
408
-                        BPPARAM=BiocParallel::MulticoreParam(workers=parallel.sz,
409
-                                                             progressbar=TRUE,
410
-                                                             tasks=100))
442
+    gene.density <- bpiterate(iter(expr, 100),
443
+                              compute.gene.density,
444
+                              sample.idxs=sample.idxs,
445
+                              rnaseq=rnaseq, kernel=kernel,
446
+                              REDUCE=rbind, reduce.in.order=TRUE,
447
+                              BPPARAM=BPPARAM)
411 448
   } else 
412 449
 	  gene.density <- compute.gene.density(expr, sample.idxs, rnaseq, kernel)
413 450
 	
... ...
@@ -613,7 +650,8 @@ setCores <- function(nCores, parallel.sz) {
613 650
 }
614 651
 
615 652
 ssgsea <- function(X, geneSets, alpha=0.25, parallel.sz,
616
-                   parallel.type, normalization=TRUE, verbose) {
653
+                   parallel.type, normalization=TRUE,
654
+                   verbose=TRUE, BPPARAM=SerialParam(progressbar=verbose)) {
617 655
 
618 656
   p <- nrow(X)
619 657
   n <- ncol(X)
... ...
@@ -704,7 +742,8 @@ ssgsea <- function(X, geneSets, alpha=0.25, parallel.sz,
704 742
 
705 743
 combinez <- function(gSetIdx, j, Z) sum(Z[gSetIdx, j]) / sqrt(length(gSetIdx))
706 744
 
707
-zscore <- function(X, geneSets, parallel.sz, parallel.type, verbose) {
745
+zscore <- function(X, geneSets, parallel.sz, parallel.type,
746
+                   verbose=TRUE, BPPARAM=SerialParam(progressbar=verbose)) {
708 747
 
709 748
   p <- nrow(X)
710 749
   n <- ncol(X)
... ...
@@ -788,7 +827,8 @@ rightsingularsvdvectorgset <- function(gSetIdx, Z) {
788 827
   s$v[, 1]
789 828
 }
790 829
 
791
-plage <- function(X, geneSets, parallel.sz, parallel.type, verbose) {
830
+plage <- function(X, geneSets, parallel.sz, parallel.type,
831
+                  verbose=TRUE, BPPARAM=SerialParam(progressbar=verbose)) {
792 832
 
793 833
   p <- nrow(X)
794 834
   n <- ncol(X)
... ...
@@ -929,7 +969,7 @@ setMethod("computeGeneSetsOverlap", signature(gSets="list", uniqGenes="character
929 969
 
930 970
 setMethod("computeGeneSetsOverlap", signature(gSets="list", uniqGenes="ExpressionSet"),
931 971
           function(gSets, uniqGenes, min.sz=1, max.sz=Inf) {
932
-  uniqGenes <- Biobase::featureNames(uniqGenes)
972
+  uniqGenes <- featureNames(uniqGenes)
933 973
   totalGenes <- length(uniqGenes)
934 974
 
935 975
   ## map to the actual features for which expression data is available
... ...
@@ -958,9 +998,11 @@ setMethod("computeGeneSetsOverlap", signature(gSets="GeneSetCollection", uniqGen
958 998
 setMethod("computeGeneSetsOverlap", signature(gSets="GeneSetCollection", uniqGenes="ExpressionSet"),
959 999
           function(gSets, uniqGenes, min.sz=1, max.sz=Inf) {
960 1000
   ## map gene identifiers of the gene sets to the features in the chip
961
-  gSets <- GSEABase::mapIdentifiers(gSets, GSEABase::AnnoOrEntrezIdentifier(Biobase::annotation(uniqGenes)))
1001
+  ## Biobase::annotation() is necessary to disambiguate from the
1002
+  ## 'annotation' argument
1003
+  gSets <- mapIdentifiers(gSets, AnnoOrEntrezIdentifier(Biobase::annotation(uniqGenes)))
962 1004
   
963
-  uniqGenes <- Biobase::featureNames(uniqGenes)
1005
+  uniqGenes <- featureNames(uniqGenes)
964 1006
 
965 1007
   gSetsMembershipMatrix <- incidence(gSets)
966 1008
   gSetsMembershipMatrix <- t(gSetsMembershipMatrix[, colnames(gSetsMembershipMatrix) %in% uniqGenes])
... ...
@@ -43,6 +43,6 @@ install_github("rcastelo/GSVA")
43 43
 
44 44
 For questions and bug reports regarding the __release__ version of **GSVA**
45 45
 please use the [Bioconductor support site](https://support.bioconductor.org "Bioconductor support site").
46
-For bug reports and issues regarding this __development__ version of **GSVA**
46
+For feature requests or bug reports and issues regarding this __development__ version of **GSVA**
47 47
 please use the GitHub issues link at the top-right of this page
48 48
 ([https://github.com/rcastelo/GSVA/issues](https://github.com/rcastelo/GSVA/issues)).
... ...
@@ -20,48 +20,52 @@ Estimates GSVA enrichment scores.
20 20
     abs.ranking=FALSE,
21 21
     min.sz=1,
22 22
     max.sz=Inf,
23
-    parallel.sz=0,
23
+    parallel.sz=1L,
24 24
     parallel.type="SOCK",
25 25
     mx.diff=TRUE,
26 26
     tau=switch(method, gsva=1, ssgsea=0.25, NA),
27 27
     ssgsea.norm=TRUE,
28
-    verbose=TRUE)
28
+    verbose=TRUE,
29
+    BPPARAM=SerialParam(progressbar=verbose))
29 30
 \S4method{gsva}{ExpressionSet,GeneSetCollection}(expr, gset.idx.list, annotation,
30 31
     method=c("gsva", "ssgsea", "zscore", "plage"),
31 32
     kcdf=c("Gaussian", "Poisson", "none"),
32 33
     abs.ranking=FALSE,
33 34
     min.sz=1,
34 35
     max.sz=Inf,
35
-    parallel.sz=0,
36
+    parallel.sz=1L,
36 37
     parallel.type="SOCK",
37 38
     mx.diff=TRUE,
38 39
     tau=switch(method, gsva=1, ssgsea=0.25, NA),
39 40
     ssgsea.norm=TRUE,
40
-    verbose=TRUE)
41
+    verbose=TRUE,
42
+    BPPARAM=SerialParam(progressbar=verbose))
41 43
 \S4method{gsva}{matrix,GeneSetCollection}(expr, gset.idx.list, annotation,
42 44
     method=c("gsva", "ssgsea", "zscore", "plage"),
43 45
     kcdf=c("Gaussian", "Poisson", "none"),
44 46
     abs.ranking=FALSE,
45 47
     min.sz=1,
46 48
     max.sz=Inf,
47
-    parallel.sz=0,
49
+    parallel.sz=1L,
48 50
     parallel.type="SOCK",
49 51
     mx.diff=TRUE,
50 52
     tau=switch(method, gsva=1, ssgsea=0.25, NA),
51 53
     ssgsea.norm=TRUE,
52
-    verbose=TRUE)
54
+    verbose=TRUE,
55
+    BPPARAM=SerialParam(progressbar=verbose))
53 56
 \S4method{gsva}{matrix,list}(expr, gset.idx.list, annotation,
54 57
     method=c("gsva", "ssgsea", "zscore", "plage"),
55 58
     kcdf=c("Gaussian", "Poisson", "none"),
56 59
     abs.ranking=FALSE,
57 60
     min.sz=1,
58 61
     max.sz=Inf,
59
-    parallel.sz=0,
62
+    parallel.sz=1L,
60 63
     parallel.type="SOCK",
61 64
     mx.diff=TRUE,
62 65
     tau=switch(method, gsva=1, ssgsea=0.25, NA),
63 66
     ssgsea.norm=TRUE,
64
-    verbose=TRUE)
67
+    verbose=TRUE,
68
+    BPPARAM=SerialParam(progressbar=verbose))
65 69
 }
66 70
 \arguments{
67 71
   \item{expr}{Gene expression data which can be given either as an \code{ExpressionSet}
... ...
@@ -99,14 +103,9 @@ Estimates GSVA enrichment scores.
99 103
             enriched on either extreme (high or low) will be regarded as 'highly' activated.}
100 104
   \item{min.sz}{Minimum size of the resulting gene sets.}
101 105
   \item{max.sz}{Maximum size of the resulting gene sets.}
102
-  \item{parallel.sz}{Number of processors to use when doing the calculations in parallel.
103
-                     This requires to previously load either the \code{parallel} or the
104
-                     \code{snow} library. If \code{parallel} is loaded and this argument
105
-                     is left with its default value (\code{parallel.sz=0}) then it will use
106
-                     all available core processors unless we set this argument with a
107
-                     smaller number. If \code{snow} is loaded then we must set this argument
108
-                     to a positive integer number that specifies the number of processors to
109
-                     employ in the parallel calculation.}
106
+  \item{parallel.sz}{Number of threads of execution to use when doing the calculations in parallel.
107
+                     The argument \code{BPPARAM} allows one to set the parallel back-end and fine
108
+                     tune its configuration.}
110 109
   \item{parallel.type}{Type of cluster architecture when using \code{snow}.}
111 110
   \item{mx.diff}{Offers two approaches to calculate the enrichment statistic (ES)
112 111
                  from the KS random walk statistic. \code{mx.diff=FALSE}: ES is calculated as
... ...
@@ -122,6 +121,7 @@ Estimates GSVA enrichment scores.
122 121
                      the minimum and the maximum, as described in their paper. When \code{ssgsea.norm=FALSE}
123 122
                      this last normalization step is skipped.}
124 123
   \item{verbose}{Gives information about each calculation step. Default: \code{FALSE}.}
124
+  \item{BPPARAM}{An object of class \code{\link[BiocParallel]{BiocParallelParam}} specifiying parameters related to the parallel execution of some of the tasks and calculations within this function.}
125 125
 }
126 126
 
127 127
 \details{