Errors are now caught by discordantRun() rather
than only being caught by discordant.cpp which
leads to more helpful error messages
... | ... |
@@ -145,10 +145,10 @@ discordantRun <- function(v1, v2, x, y = NULL, transform = TRUE, |
145 | 145 |
} |
146 | 146 |
|
147 | 147 |
if (repeats >= floor(iter * .1)) { |
148 |
- stop("Insufficient data for subsampling. Increase number of |
|
149 |
- features, reduce number of components used, or increase |
|
150 |
- subSize if not at default value. Alternatively, set |
|
151 |
- subsampling=FALSE.") |
|
148 |
+ stop(paste0("\nInsufficient data for subsampling. Increase number of", |
|
149 |
+ "\nfeatures, reduce numberof components used, or increase", |
|
150 |
+ "\nsubSize if not at default value. Alternatively, set", |
|
151 |
+ "\nsubsampling=FALSE.")) |
|
152 | 152 |
} |
153 | 153 |
|
154 | 154 |
mu <- total_mu / iter |
... | ... |
@@ -162,7 +162,13 @@ discordantRun <- function(v1, v2, x, y = NULL, transform = TRUE, |
162 | 162 |
zTable <- finalResult$z |
163 | 163 |
classVector <- finalResult$class |
164 | 164 |
} else { |
165 |
- pd <- em.normal.partial.concordant(pdata, class, components) |
|
165 |
+ pd <- tryCatch({em.normal.partial.concordant(pdata, class, components)}, |
|
166 |
+ error = function(unused) return(NULL)) |
|
167 |
+ if (is.null(pd)) { |
|
168 |
+ stop( |
|
169 |
+ paste0("\nInsufficient data for component estimation. Increase", |
|
170 |
+ "\nnumber of features or reduce number of components used.")) |
|
171 |
+ } |
|
166 | 172 |
zTable <- pd$z |
167 | 173 |
classVector <- pd$class |
168 | 174 |
} |
... | ... |
@@ -184,7 +190,7 @@ em.normal.partial.concordant <- function(data, class, components) { |
184 | 190 |
|
185 | 191 |
zx <- .unmap(class[,1], components = components) |
186 | 192 |
zy <- .unmap(class[,2], components = components) |
187 |
- .checkForMissingComponents(zx, zy) |
|
193 |
+ # .checkForMissingComponents(zx, zy) |
|
188 | 194 |
zxy <- sapply(1:dim(zx)[1], yl.outer, zx, zy) |
189 | 195 |
|
190 | 196 |
pi <- double(g*g) |
... | ... |
@@ -320,15 +326,15 @@ em.normal.partial.concordant <- function(data, class, components) { |
320 | 326 |
# Internal function that checks whether all types of component are present |
321 | 327 |
# in given vectors. If a certain component is not present, we run into a |
322 | 328 |
# divide-by-zero error that crashes R |
323 |
-.checkForMissingComponents <- function(zx, zy) { |
|
324 |
- sumZx <- colSums(zx) |
|
325 |
- sumZy <- colSums(zy) |
|
326 |
- if(any(c(sumZx, sumZy) == 0)) { |
|
327 |
- stop("Insufficient data for component estimation. Increase number of |
|
328 |
- features or reduce number of components used. If subsampling=TRUE, |
|
329 |
- you may need set subsampling=FALSE.") |
|
330 |
- } |
|
331 |
-} |
|
329 |
+# .checkForMissingComponents <- function(zx, zy) { |
|
330 |
+# sumZx <- colSums(zx) |
|
331 |
+# sumZy <- colSums(zy) |
|
332 |
+# if(any(c(sumZx, sumZy) == 0)) { |
|
333 |
+# stop("Insufficient data for component estimation. Increase number of |
|
334 |
+# features or reduce number of components used. If subsampling=TRUE, |
|
335 |
+# you may need set subsampling=FALSE.") |
|
336 |
+# } |
|
337 |
+# } |
|
332 | 338 |
|
333 | 339 |
# Internal function to set sub size based on data |
334 | 340 |
.setSubSize <- function(x, y, subSize) { |