Repository navigation
Conversation
When pp.neighbors recorded an explicit use_rep="X_pca" (or use=A.obsm["X_pca"]), rather than inferring the representation from a recorded n_pcs, Ingest never set _n_pcs. _same_rep() then tried to read X_pca straight off the new AnnData (which has none yet, since computing it is the whole point of ingest), caught the resulting KeyError/ValueError, and silently fell back to raw .X -- a representation with the wrong number of dimensions, which then crashes the knn query with a shape mismatch against an index built on the PCA-space reference. Set _n_pcs in this branch too, like the two branches below it already do, so adata_new is correctly re-projected through the stored PCA basis. Signed-off-by: Siddhardha Nanda <[email protected]>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Signed-off-by: Siddhardha Nanda <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4508 +/- ##
=======================================
Coverage 85.14% 85.15%
=======================================
Files 138 138
Lines 12255 12257 +2
=======================================
+ Hits 10435 10437 +2
Misses 1820 1820
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Checking in. Green and mergeable, open about a week with no review yet. |
|
Two failing checks here, neither a code issue:
|
Summary
Ingesthandles a recordeduse_rep/usein three ways depending on howpp.neighborswas called:n_pcs-> slices the storedX_pcause_rep/usenorn_pcsrecorded (then_pcs=Nonedefault) -> uses the full storedX_pca(fixed in fix: have ingest no longer truncate to settings.N_PCS #4401)use_rep="X_pca"oruse=A.obsm["X_pca"]-> only this branch never setsself._n_pcsWithout
_n_pcsset,Ingest._same_rep()tries to readX_pcastraight offadata_new— which doesn't have one yet, since computing it is the whole point ofingest— catches the resultingKeyError/ValueError, and silently falls back to raw.X. That's a representation with the wrong number of dimensions, which then crashes the knn query with a shape mismatch against the index built on the PCA-space reference (or, for smaller gene counts, just a silently wrong - but not dimension-colliding - representation).The existing
test_representation_acctest didn't catch this because it manually pre-populatedadata_new.obsm["X_pca"]with (incidentally wrong) data copied straight fromadata_ref, which the old fallback path happened to read back verbatim without erroring.Fix
Set
self._n_pcsin the explicit-use_rep/usebranch too, exactly like the two branches below it already do, soadata_newis correctly re-projected through the stored PCA basis instead of silently falling back to raw.X.Test plan
test_representation_accto drop the test's own fallback-maskingadata_new.obsm["X_pca"]pre-population, and instead assert the explicit-usepath produces the same representation as the implicit default path (same shape, same values)main(shape(200, 765)vs(200, 50)) and passes with the fixpytest tests/test_ingest.py— 10 passedruff check/ruff format --checkon the changed files — clean