Browse code

fixed bug in calculatePeakScores

chakalakka authored on 30/01/2018 11:11:57
Showing 1 changed files

... ...
@@ -45,7 +45,9 @@ calculatePeakScores <- function(maxPostInPeak) {
45 45
     peakScores <- maxPostInPeak
46 46
     for (i1 in 1:ncol(maxPostInPeak)) {
47 47
         mask <- maxPostInPeak[,i1] > 0
48
-        peakScores[mask,i1] <- stats::ecdf(maxPostInPeak[mask,i1])(maxPostInPeak[mask,i1])*1000
48
+        if (length(which(mask)) > 0) {
49
+            peakScores[mask,i1] <- stats::ecdf(maxPostInPeak[mask,i1])(maxPostInPeak[mask,i1])*1000
50
+        }
49 51
     }
50 52
     return(peakScores)
51 53
 }
... ...
@@ -54,7 +56,9 @@ calculatePeakScores <- function(maxPostInPeak) {
54 56
 calculatePeakScores.univariate <- function(maxPostInPeak) {
55 57
     peakScores <- maxPostInPeak
56 58
     mask <- maxPostInPeak > 0
57
-    peakScores[mask] <- stats::ecdf(maxPostInPeak[mask])(maxPostInPeak[mask]) * 1000
59
+    if (length(which(mask)) > 0) {
60
+        peakScores[mask] <- stats::ecdf(maxPostInPeak[mask])(maxPostInPeak[mask]) * 1000
61
+    }
58 62
     return(peakScores)
59 63
 }
60 64