Add signature reversal scoring to enrichment - #1082
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1082 +/- ##
==========================================
+ Coverage 79.47% 79.95% +0.48%
==========================================
Files 53 55 +2
Lines 7556 7533 -23
==========================================
+ Hits 6005 6023 +18
+ Misses 1551 1510 -41
🚀 New features to boost your workflow:
|
|
It looks like the ReadTheDocs failure is unrelated to this PR. The warnings seem to come from external intersphinx/scvi-lightning references. |
|
After a further pass, the implementation now uses raw CMap WTCS. The remaining ReadTheDocs failure is caused by the same external issue noted above. |
|
Thanks! I'll have a look at the RTD failure soon. |
|
I think the RTD failure is related to Lightning-AI/pytorch-lightning#21915. |
Zethson
left a comment
There was a problem hiding this comment.
Please ensure that your markdown fits the style I used -> single sentences on single lines.
Same for docstrings.
Should we also already add a small section to a tutorial?
| >>> from anndata import AnnData | ||
| >>> effect_adata = AnnData(np.array([[-2.0, 1.0, 0.5]])) | ||
| >>> effect_adata.var_names = ["IL6", "CCR7", "other"] | ||
| >>> enr = pt.tl.Enrichment() |
There was a problem hiding this comment.
Is it possible to use one of the existing datasets here instead of creating one? Makes the example shorter
| For a simple single-context dataset, cell-level effects can be computed before aggregation: | ||
|
|
||
| ```python | ||
| cell_adata = sc.read_h5ad("perturbation_data.h5ad") |
There was a problem hiding this comment.
This is not copy and pastable. Every example needs to be trivial to run.
|
Thanks for the feedback. I checked the existing datasets but none appears to provide perturbation-level, control-relative signatures directly. I also noticed that the tutorials live in the separate scverse/pertpy-tutorials repository as a submodule, so I haven't included the tutorial in this PR. Would you prefer a separate PR there, followed by a submodule update here? |
|
Yes exactly, that'd be the way to go to update the tutorials. Thank you! Let me know if you need help, please. |
|
I'll be traveling next week and might not get to it but I'll get back to you for this PR. Looks pretty good already |
PR Checklist
docsis updatedDescription of changes
This adds a first CMap-style signature reversal workflow to
pt.tl.Enrichment.Given perturbation-level
AnnDatawith perturbations as observations and genes as variables, users can provide either up/down query gene sets or a signed query signature. The method scores each perturbation by how strongly it opposes the query signature and stores the results back on the AnnData object.This addresses the signature reversal part of #1036. It does not address Bliss/Loewe synergy, dose-response, or genetic interaction workflows.
Technical details
Enrichment.signature_reversaladata.obsadata.uns.X, an optional layer, and optional gene-symbol matching throughadata.varTesting
ruff check src\pertpy\tools\_enrichment.py tests\tools\test_enrichment.pyruff format --check src\pertpy\tools\_enrichment.py tests\tools\test_enrichment.pypytest tests\tools\test_enrichment.py -q -p no:cacheproviderAddresses part of #1036.