Skip to content

fix: derive PCA defaults from the selected representation - #4533

Merged
flying-sheep merged 3 commits into
scverse:mainfrom
rpinho:fix-pca-obsm-defaults
Nov 26, 2026
Merged

flying-sheep merged 3 commits into
scverse:mainfrom
rpinho:fix-pca-obsm-defaults

Conversation

@rpinho

@rpinho rpinho commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor
  • Closes #
  • Tests included or not required because:
  • Release notes not necessary because:
  • LLM or coding agent used: GPT-6.1 (OpenAI) via Codex wrote the patch and the test; Claude Opus 5.5 via Claude Code reproduced the bug separately and opened this PR
  • If one was used, I, a human, have reviewed, understood and tested every changed line

PCA on an obsm matrix can raise for n_components or return fewer components because its defaults use the dimensions and highly_variable mask of X. Call pp.pca with use='obsm.features' where features has a column count that differs from X to reproduce it. The patch derives n_comps from the selected matrix and skips the default variable mask for obsm input. The test compares embeddings, loadings and variance to PCA on that same matrix in X, with both input spellings and with or without a highly_variable annotation.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.11%. Comparing base (5c7d839) to head (2f31259).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4533   +/-   ##
=======================================
  Coverage   85.11%   85.11%           
=======================================
  Files         140      140           
  Lines       12523    12523           
=======================================
  Hits        10659    10659           
  Misses       1864     1864           
Flag Coverage Δ
hatch-test.low-vers 80.34% <ø> (ø)
hatch-test.pre 84.89% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/scanpy/preprocessing/_pca/__init__.py 92.50% <ø> (ø)

@Zethson

Zethson commented Nov 18, 2026

Copy link
Copy Markdown
Member

@rpinho we have a PR template for a reason. Please fill it out. Otherwise, I'll close all of your PRs.

@rpinho

rpinho commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Sorry about that. The template is filled in now.

@rpinho

rpinho commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Hey, I understand this is not helpful. What would be helpful? We would be glad to help in any way we can. What's a hard problem?

@flying-sheep flying-sheep added this to the 1.13.1 milestone Nov 26, 2026
@flying-sheep
flying-sheep merged commit 0083d6a into scverse:main Nov 26, 2026
6 of 11 checks passed
@flying-sheep

Copy link
Copy Markdown
Member

thanks!

flying-sheep pushed a commit that referenced this pull request Nov 26, 2026
… selected representation) (#4555)

Co-authored-by: Ricardo Pinho <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants