Skip to content

Commit

Permalink
replace small latent space error by warning
Browse files Browse the repository at this point in the history
  • Loading branch information
andrearaithel committed Jul 16, 2024
1 parent a2032ba commit ee5ee2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions R/controlForConfounders.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,12 @@ estimateBestQ <- function(ods=NULL, zScores=NULL){
if (any(sv > cutoff)){
latentDim <- max(which(sv > cutoff))
} else {
stop(paste("Latent space dimension is smaller than 2. Check your count matrix and",
warning(paste("Optimal latent space dimension is smaller than 2. Check your count matrix and",
"verify that all samples have the expected number of counts.",
"hist(colSums(counts(ods)))", collapse = "\n"))
latentDim <- 0}
cat("Target rank:", latentDim, "\n")
"(hist(colSums(counts(ods)))).",
"For now, the latent space dimension is set to 2.", collapse = "\n"))
latentDim <- 2}
cat("Optimal encoding dimension:", latentDim, "\n")
return(latentDim)
}

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test_estimateBestQ.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ test_that("Encoding dimensions are properly calculated for simulated z-scores",
set.seed(42)
latentDim <- 0
zTilde <- matrix(rnorm(numGenes * numSamples), nrow = numGenes, ncol = numSamples)
expect_error(expect_equal(estimateBestQ(zScores = zTilde),
latentDim),
expect_warning(expect_equal(estimateBestQ(zScores = zTilde), 2),
paste("Latent space dimension is smaller than 2\\. Check your count matrix and",
"verify that all samples have the expected number of counts\\.",
"hist\\(colSums\\(counts\\(ods\\)\\)\\)", collapse = "\n"))
"\\(hist\\(colSums\\(counts\\(ods\\)\\)\\)\\)\\.",
"For now\\, the latent space dimension is set to 2\\.", collapse = "\n"))
})

test_that("Encoding dimensions are properly calculated for real ODS", {
Expand Down

0 comments on commit ee5ee2e

Please sign in to comment.