feat: make the gene list of single-view sklearn models configurable - #464
Open
jfrog64 wants to merge 2 commits into
Open
feat: make the gene list of single-view sklearn models configurable#464jfrog64 wants to merge 2 commits into
jfrog64 wants to merge 2 commits into
Conversation
load_single_cell_line_view hard-coded landmark_genes_reduced for gene_expression, so the sklearn baselines could not be run on a different gene space. It now takes a gene_list argument that defaults to the previous value, and SklearnModel exposes it as the "gene_list" hyperparameter. The value is kept in self.hyperparameters so save()/load() carry it and predict() uses the same gene space the model was trained on. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
MODEL_FACTORY is typed as returning DRPModel, which has no gene_list, so mypy rejected the attribute accesses in the test. Instantiate ElasticNetModel directly and assert once that MODEL_FACTORY["ElasticNet"] really is that class, which keeps the registration covered. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## development #464 +/- ##
===============================================
+ Coverage 80.34% 82.10% +1.75%
===============================================
Files 101 121 +20
Lines 8171 9833 +1662
===============================================
+ Hits 6565 8073 +1508
- Misses 1606 1760 +154 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4 tasks
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.
PR Checklist for all PRs
docsis updated — no new module and no signature that the API docs render, so nothing to addChanges
New features
load_single_cell_line_viewhard-codes the gene list it subsetsgene_expressionwith:So every single-view sklearn baseline —
ElasticNet,RandomForest,SVR,SingleDrug*, … — islocked to the landmark genes. The other gene lists that ship with the framework
(
drug_target_genes_all_drugs,gene_list=Nonefor the full matrix) are reachable for hand-writtenmodels, but not for the baselines, even though the baselines are exactly where one wants to vary the
feature space to see how much of a model's performance comes from the gene selection rather than the
learner.
This makes it configurable in two steps, without changing any default:
load_single_cell_line_viewgainsgene_list: str | None = "landmark_genes_reduced"and forwards it.The default is the previously hard-coded value, so every existing caller behaves exactly as before.
SklearnModelgains agene_listclass attribute with the same default, andbuild_modelreads itfrom the hyperparameters:
This is the same pattern the class already uses for
cell_line_viewsanddrug_viewsone line above.The value stays in
self.hyperparameters, sosave()/load()carry it andpredict()uses the samegene space the model was trained on.
gene_listis deliberately not added tobaselines/hyperparameters.yaml, so the tuning grids areuntouched and nothing changes for existing runs. It becomes available to anyone who passes a custom
hyperparameter set.
Tests:
tests/test_sklearn_gene_list.pybuilds a temporarymeta/gene_listsdirectory with two listsand covers
gene_listreproduces the previously hard-codedlandmark_genes_reducedbehaviourgene_list=Noneloads the full expression matrixSklearnModeldefault equals the class attribute"gene_list"hyperparameter reachesload_cell_line_featuresand lands inself.hyperparametersBug fixes
Maintenance