Browse code

fixed indx in patternMatcher and cellMatcher

Genevieve Stein-O'Brien authored on 30/03/2018 13:53:57
Showing 1 changed files

... ...
@@ -59,18 +59,18 @@ patternMatch4Parallel <- function(Ptot, nSets, cnt, minNS=NULL, maxNS=NULL,
59 59
     cc<-corcut(Ptot,minNS,cnt,cluster.method)
60 60
 
61 61
     ### split by maxNS
62
-    indx<-unlist(sapply(cc$PByClust,function(x) which(dim(x)[1]>maxNS)))
62
+    indx<-which(unlist(lapply(cc$PByClust,function(x) dim(x)[1]>maxNS)))
63 63
     while(length(indx)>0){
64 64
             icc<-corcut(cc$PByClust[[indx[1]]],minNS,2,cluster.method)
65
-            cc$PByClust[[indx[1]]]<-icc[[2]][[2]]
66
-            cc$RtoMeanPattern[[indx[1]]]<-icc[[1]][[2]]
67
-            if(is.null(icc[[2]][[1]])){ 
68
-                indx<-unlist(sapply(cc$PByClust,function(x) which(dim(x)[1]>maxNS)))
65
+            cc$PByClust[[indx[1]]]<-icc[[2]][[1]]
66
+            cc$RtoMeanPattern[[indx[1]]]<-icc[[1]][[1]]
67
+            if(is.null(icc[[2]][[2]])){ 
68
+                indx<-which(unlist(lapply(cc$PByClust,function(x) dim(x)[1]>maxNS)))
69 69
                 next
70 70
             } else {
71
-                cc$PByClust<-append(cc$PByClust,icc[[2]][1])
72
-                cc$RtoMeanPattern<-append(cc$PByClust,icc[[1]][[1]])
73
-                indx<-unlist(sapply(cc$PByClust,function(x) which(dim(x)[1]>maxNS)))
71
+                cc$PByClust<-append(cc$PByClust,icc[[2]][2])
72
+                cc$RtoMeanPattern<-append(cc$PByClust,icc[[1]][[2]])
73
+                indx<-which(unlist(lapply(cc$PByClust,function(x) dim(x)[1]>maxNS)))
74 74
             }
75 75
     }
76 76