Repository navigation
Ask for as many components as the data has - #10482
Merged
anashen merged 2 commits intoOct 19, 2026
Merged
Conversation
LeverageScore() sizes its decomposition to the object: nv <- ifelse(nrow(x = object) < 50, nrow(x = object) - 1, 50) and then does not use it: Z <- irlba(A = object, nv = 50, nu = 0, verbose = FALSE)$v so 50 components are always requested, and anything with fewer than 50 features or cells stops with Error: max(nu, nv) must be strictly less than min(nrow(A), ncol(A)) That takes SketchData() with it, which is how it is usually reached: SketchData() on pbmc_small fails at every size of sketch. Use nv, bounded by both dimensions, and say so when there is nothing to decompose at all. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Sep 1, 2026
Contributor
Author
|
Superseded by #10492, which groups five small independent fixes into one review. The commit is carried over unchanged; closing here to keep the queue down rather than because anything was wrong with it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SketchData()fails on any small object, at every size of sketch:Cause
LeverageScore.default()sizes its decomposition to the object, and then does not use the value:nvis computed and dropped; 50 components are always requested. Anything with fewer than 50 features or cells on the side being decomposed therefore stops insideirlba, and sinceSketchData()is howLeverageScore()is usually reached, that is where it surfaces.Fix
Use
nv, bounded by both dimensions, and say so when there is nothing to decompose at all:Behaviour is unchanged for objects with 50 or more of each, which is where the constant and the computed value agree.
Tests
tests/testthat/test_leverage_score_small.R: leverage scores onpbmc_small, sketching to 40 cells, asking for more cells than exist (all of them are kept), and the message for a matrix with nothing to decompose.Four assertions fail without the change. Full suite
NOT_CRAN=true: 1187 passing, the only 2 failures being the pre-existingRead10X_Imageones fixed in #10454.🤖 Generated with Claude Code