Skip to content

Commit 49ebe86

Browse files
author
Eric Weine
committed
added additional check in subset method
1 parent c6f9b4f commit 49ebe86

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

R/fit.R

+14
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,21 @@ fit_glmpca_pois <- function(
248248
size = ceiling(ncol(Y) * control$training_frac)
249249
)
250250

251+
browser()
251252
Y_train <- Y[, train_idx]
253+
254+
if (any(Matrix::rowSums(Y_train) == 0) || any(Matrix::colSums(Y_train) == 0)) {
255+
256+
stop(
257+
"After subsetting, the remaining values of \"Y\" ",
258+
"contain a row or a column where all counts are 0. This can cause ",
259+
"problems with optimization. Please either remove rows / columns ",
260+
"with few non-zero counts from \"Y\", or set \"training_frac\" to ",
261+
"a larger value."
262+
)
263+
264+
}
265+
252266
FF_train <- FF[, train_idx]
253267
FF_test <- FF[, -train_idx]
254268
Y_test <- Y[, -train_idx]

inst/.DS_Store

10 KB
Binary file not shown.

inst/scratch/test_projection_method.R

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
library(fastglmpca)
22

33
set.seed(1)
4+
cc <- pbmc_facs$counts[Matrix::rowSums(pbmc_facs$counts) > 10, ]
5+
46
fit1 <- fit_glmpca_pois(
5-
Y = pbmc_facs$counts,
7+
Y = cc,
68
K = 2,
7-
control = list(training_frac = 1, maxiter = 10)
9+
control = list(training_frac = 0.99, maxiter = 10)
810
)
911

1012
# for some reason the calculated log-likelihood and the expected

0 commit comments

Comments
 (0)