Skip to content

Commit

Permalink
added additional check in subset method
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Weine committed Aug 22, 2024
1 parent c6f9b4f commit 49ebe86
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
14 changes: 14 additions & 0 deletions R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,21 @@ fit_glmpca_pois <- function(
size = ceiling(ncol(Y) * control$training_frac)
)

browser()
Y_train <- Y[, train_idx]

if (any(Matrix::rowSums(Y_train) == 0) || any(Matrix::colSums(Y_train) == 0)) {

stop(
"After subsetting, the remaining values of \"Y\" ",
"contain a row or a column where all counts are 0. This can cause ",
"problems with optimization. Please either remove rows / columns ",
"with few non-zero counts from \"Y\", or set \"training_frac\" to ",
"a larger value."
)

}

FF_train <- FF[, train_idx]
FF_test <- FF[, -train_idx]
Y_test <- Y[, -train_idx]
Expand Down
Binary file added inst/.DS_Store
Binary file not shown.
6 changes: 4 additions & 2 deletions inst/scratch/test_projection_method.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
library(fastglmpca)

set.seed(1)
cc <- pbmc_facs$counts[Matrix::rowSums(pbmc_facs$counts) > 10, ]

fit1 <- fit_glmpca_pois(
Y = pbmc_facs$counts,
Y = cc,
K = 2,
control = list(training_frac = 1, maxiter = 10)
control = list(training_frac = 0.99, maxiter = 10)
)

# for some reason the calculated log-likelihood and the expected
Expand Down

0 comments on commit 49ebe86

Please sign in to comment.