Browse code

commenting out set.seed in tests because of bug generating random num in runRandomSVD

pablo-rodr-bio2 authored on 06/10/2021 10:58:11
Showing2 changed files

... ...
@@ -852,12 +852,12 @@ ssgsea <- function(X, geneSets, alpha=0.25, parallel.sz,
852 852
 
853 853
   n <- ncol(X)
854 854
   
855
-  if(is(X, "dgCMatrix")){
856
-    R <- t(sparseMatrixStats::colRanks(X, ties.method = "average"))
857
-    mode(R) <- "integer"
858
-  } else {
859
-    R <- apply(X, 2, function(x, p) as.integer(rank(x)))
860
-  }
855
+  print("Calculating ranks...")
856
+  
857
+  R <- t(sparseMatrixStats::colRanks(X, ties.method = "average"))
858
+  mode(R) <- "integer"
859
+
860
+  print("Calculating absolute values from ranks...")
861 861
   
862 862
   Ra <- abs(R)^alpha
863 863
   
... ...
@@ -872,9 +872,11 @@ ssgsea <- function(X, geneSets, alpha=0.25, parallel.sz,
872 872
   
873 873
   
874 874
   if (normalization) {
875
+    print("Normalizing...")
875 876
     ## normalize enrichment scores by using the entire data set, as indicated
876 877
     ## by Barbie et al., 2009, online methods, pg. 2
877
-    es <- apply(es, 2, function(x, es) x / (range(es)[2] - range(es)[1]), es)
878
+    # es <- apply(es, 2, function(x, es) x / (range(es)[2] - range(es)[1]), es)
879
+    es <- es[,1:n] / (range(es)[2] - range(es)[1])
878 880
   }
879 881
   
880 882
   if (length(geneSets) == 1)
... ...
@@ -1,6 +1,6 @@
1 1
 test_delayed <- function(){
2 2
   
3
-  set.seed(1001)
3
+  # set.seed(1001)
4 4
   m <- matrix(runif(10000), 1000, 100)
5 5
   rownames(m) <- paste0("gene_", 1:1000)
6 6
   colnames(m) <- paste0("cell_", 1:100)