Skip to content

fix: don't abort make_adata when ontology translation fails#51

Merged
jkobject merged 1 commit into
cantinilab:mainfrom
LiudengZhang:fix-translate-crash-in-make-adata
May 20, 2026
Merged

fix: don't abort make_adata when ontology translation fails#51
jkobject merged 1 commit into
cantinilab:mainfrom
LiudengZhang:fix-translate-crash-in-make-adata

Conversation

@LiudengZhang

Copy link
Copy Markdown

Summary 📝

make_adata calls translate() to populate the cosmetic conv_* columns with human-readable ontology names. translate() can raise on an id it cannot resolve — notably comma-joined CellxGene terms like self_reported_ethnicity_ontology_term_id = "HANCESTRO:0005,HANCESTRO:0008", which a model legitimately predicts because such labels are in the training vocabulary. When that happens, the entire prediction/embedding run aborts (#49).

Details

  1. Wrap the two translate() calls in make_adata so a translation failure emits a warnings.warn and skips the affected conv_* column instead of raising.
  2. The actual predictions (pred_* columns) and embeddings are untouched — only the optional human-readable convenience columns are affected.
  3. The root cause is also fixed upstream in scdataloader's translate() (fix: handle compound ontology ids in translate() jkobject/scDataLoader#33, which resolves compound ids properly). This scPRINT-side change is defense-in-depth: it keeps make_adata robust regardless of the installed scdataloader version.

Bugfixes 🐛

  • make_adata no longer crashes the whole run when an ontology id (e.g. a compound CellxGene ethnicity term) can't be translated.

Checks

make_adata calls translate() to fill the cosmetic conv_* columns with
human-readable names. translate() can raise on ids it cannot resolve
(e.g. comma-joined CellxGene ethnicity terms a model may predict),
which aborts the entire prediction/embedding run.

Wrap the translate() calls so an unresolved id warns and skips the
conv_* column instead of crashing. The actual predictions (pred_*) are
unaffected.

The root cause is also fixed upstream in scdataloader's translate()
(jkobject/scDataLoader#33); this keeps scPRINT robust regardless of the
installed scdataloader version.

Closes cantinilab#49
@jkobject jkobject merged commit 491f640 into cantinilab:main May 20, 2026
1 check passed
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 27.27273% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.28%. Comparing base (4acc1a4) to head (a8afaa8).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
scprint/model/utils.py 27.27% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #51      +/-   ##
==========================================
- Coverage   41.34%   41.28%   -0.07%     
==========================================
  Files          27       27              
  Lines        2854     2863       +9     
==========================================
+ Hits         1180     1182       +2     
- Misses       1674     1681       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Comma concatenated ontology term ID not in lamindb causes error in translate

3 participants