Browse code

Fixing a bug in delayed zscore method and getting back tests

pablo-rodr-bio2 authored on 25/01/2021 17:51:59
Showing 6 changed files

... ...
@@ -1,18 +1,18 @@
1 1
 Package: GSVA
2
-Version: 1.39.12
2
+Version: 1.39.13
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("Alexey", "Sergushichev", role="ctb", email="alsergbox@gmail.com"),
7 7
              person("Pablo Sebastian", "Rodriguez", role="ctb", email="pablosebastian.rodriguez@upf.edu"))
8 8
 Depends: R (>= 3.5.0)
9
-Imports: methods, stats, utils, graphics, BiocGenerics, S4Vectors,
9
+Imports: methods, stats, utils, graphics, S4Vectors,
10 10
          Biobase, SummarizedExperiment, GSEABase, Matrix,
11 11
          parallel, BiocParallel, fastmatch, SingleCellExperiment, 
12 12
          sparseMatrixStats, DelayedArray, DelayedMatrixStats,
13 13
          HDF5Array, BiocSingular
14 14
 Suggests: 
15
-    RUnit, limma, RColorBrewer, genefilter, edgeR, GSVAdata,
15
+    RUnit, BiocGenerics, limma, RColorBrewer, genefilter, edgeR, GSVAdata,
16 16
     shiny, shinythemes, ggplot2, data.table, plotly
17 17
 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.
18 18
 License: GPL (>= 2)
... ...
@@ -1,7 +1,6 @@
1 1
 useDynLib(GSVA)
2 2
 
3 3
 import(methods)
4
-import(BiocGenerics)
5 4
 
6 5
 importClassesFrom(Biobase, ExpressionSet)
7 6
 importClassesFrom(SummarizedExperiment, SummarizedExperiment)
... ...
@@ -33,7 +32,8 @@ importMethodsFrom(BiocParallel, bpiterate,
33 32
 
34 33
 importFrom(graphics, plot)
35 34
 importFrom(stats, ecdf,
36
-                  na.omit)
35
+                  na.omit,
36
+                  sd)
37 37
 importFrom(utils, installed.packages,
38 38
                   setTxtProgressBar,
39 39
                   txtProgressBar,
... ...
@@ -58,8 +58,10 @@ importFrom(DelayedArray, rowAutoGrid,
58 58
 			  read_block, 
59 59
 			  viewportReduce,
60 60
 			  write_block,
61
-			  close)
62
-importFrom(HDF5Array, HDF5RealizationSink)
61
+			  close,
62
+			  t)
63
+importFrom(HDF5Array, HDF5RealizationSink,
64
+                      writeHDF5Array)
63 65
 importFrom(DelayedMatrixStats, rowSds)
64 66
 importFrom(BiocSingular, runRandomSVD)
65 67
 
... ...
@@ -116,15 +116,13 @@ zscoreDelayed <- function(X, geneSets, parallel.sz, verbose=TRUE,
116 116
   
117 117
   Z <- t(DelayedArray::scale(t(X)))
118 118
   
119
-  es <- bplapply(geneSets, h5BackendRealization, combinezDelayed,
120
-                 Z, BPPARAM = BPPARAM)
121
-  
122
-  es <- do.call(rbind, es)
123
-  rownames(es) <- names(geneSets)
124
-  colnames(es) <- colnames(X)
125
-  
119
+  es <- bplapply(geneSets, function(gSetIdx, Z){
120
+    x <- combinezDelayed(gSetIdx, Z)
121
+    x <- matrix(x, 1, length(x))
122
+    x <- writeHDF5Array(x)
123
+  }, Z, BPPARAM = BPPARAM)
124
+  es <- do.call(DelayedArray::rbind, es)
126 125
   es <- as(es, "HDF5Array")
127
-  
128 126
   es
129 127
 }
130 128
 
... ...
@@ -183,7 +181,7 @@ ssgseaDelayed <- function(X, geneSets, alpha=0.25, parallel.sz,
183 181
     res
184 182
   }, BPPARAM=BPPARAM)
185 183
   
186
-  es <- do.call(cbind, es)
184
+  es <- do.call(DelayedArray::cbind, es)
187 185
   es
188 186
   
189 187
   if (normalization) {
190 188
similarity index 64%
191 189
rename from inst/unitTests/test_delayedMethods.R
192 190
rename to inst/unitTests/test_delayed.R
... ...
@@ -1,11 +1,12 @@
1
-test_delayedMethods <- function(){
1
+test_delayed <- function(){
2 2
   
3
-  m <- matrix(runif(100000), 10000, 1000)
4
-  rownames(m) <- paste0("gene_", 1:10000)
5
-  colnames(m) <- paste0("cell_", 1:1000)
3
+  set.seed(1001)
4
+  m <- matrix(runif(10000), 1000, 100)
5
+  rownames(m) <- paste0("gene_", 1:1000)
6
+  colnames(m) <- paste0("cell_", 1:100)
6 7
   
7
-  gene.sets <- list("my_list1"= paste0("gene_", 1:1000),
8
-                    "my_list2"= paste0("gene_", 4001:5000))
8
+  gene.sets <- list("my_list1"= paste0("gene_", 1:100),
9
+                    "my_list2"= paste0("gene_", 401:500))
9 10
   
10 11
   h5 <- as(m, "HDF5Array")
11 12
   
12 13
similarity index 100%
13 14
rename from inst/unitTests/test_sparseMethods.R
14 15
rename to inst/unitTests/test_sparse.R
15 16
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+BiocGenerics:::testPackage("GSVA")