Skip to content

feat(DIPK): make the gene list a hyperparameter - #469

Open
jfrog64 wants to merge 1 commit into
daisybio:developmentfrom
jfrog64:feat-dipk-gene-list-hyperparameter
Open

feat(DIPK): make the gene list a hyperparameter#469
jfrog64 wants to merge 1 commit into
daisybio:developmentfrom
jfrog64:feat-dipk-gene-list-hyperparameter

Conversation

@jfrog64

@jfrog64 jfrog64 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

PR Checklist for all PRs

  • This comment contains a description of changes (with reason)
  • Referenced issue is linked — no existing issue, this came out of running DIPK on a larger expression panel
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated — not needed, drevalpy.models.DIPK.dipk is already an automodule and the new hyperparameter is documented in the build_model docstring

Changes

Bug fixes

New features

DIPKModel.load_cell_line_features hard-codes the gene list:

gene_expression = load_and_select_gene_features(
    feature_type="gene_expression",
    gene_list="gene_expression_intersection",
    ...
)

so the only way to run DIPK on a different gene space is to edit the model or to subclass it and copy the
whole loader. We ended up with several near-identical DIPK subclasses that differ in exactly that one string,
which is what prompted this.

gene_list becomes a class attribute whose default is that same "gene_expression_intersection", and
build_model picks it up from the hyperparameters:

self.gene_list = hyperparameters.get("gene_list", type(self).gene_list)

This mirrors what the single-view sklearn models do (see #464), so both places behave the same way.
None loads all genes. Nothing changes for existing runs: without the hyperparameter the model loads
exactly the genes it loaded before, and hyperparameters.yaml is untouched, so the tuning grid does not grow.

The value stays in self.hyperparameters, which matters for DIPK specifically: save() dumps that dict to
hyperparameters.json and load() feeds it back into build_model, so a restored model predicts on the same
gene space it was trained on.

Tests: tests/test_dipk_gene_list.py

  • the default is the previously hard-coded list, both as class attribute and after build_model
  • the default really loads those genes, and the bionic_features view is unaffected by the gene list
  • the gene_list hyperparameter reaches the loader, stays in self.hyperparameters, and does not modify the
    class default
  • gene_list=None loads the full matrix
  • a second model built without the hyperparameter falls back to the default, i.e. nothing leaks between instances
  • the save/load round trip (JSON round trip of the hyperparameters, then build_model) restores the gene space

The fixture builds a small data directory including DIPK_features/gene_list_sel.txt and
human_ppi_features.tsv, so the bionic branch of the loader is exercised for real rather than mocked.

PharmaFormer and DrugGNN hard-code their gene list in the same way; those are follow-up PRs with the same
pattern, kept separate so this one stays small.

Maintenance

DIPK hard-coded gene_list="gene_expression_intersection" in
load_cell_line_features, so the gene space could only be changed by editing
the model. It is now a class attribute with that same value as default and
can be overridden with the "gene_list" hyperparameter, mirroring how the
single-view sklearn models handle it.

build_model stores it on the instance and it stays in self.hyperparameters,
so save()/load() carry it over and predict() sees the gene space the model
was trained on. Passing None loads all genes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jfrog64 jfrog64 closed this Aug 27, 2026
@jfrog64 jfrog64 reopened this Aug 27, 2026
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.11%. Comparing base (7d24cd6) to head (7f285fe).
⚠️ Report is 75 commits behind head on development.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@               Coverage Diff               @@
##           development     #469      +/-   ##
===============================================
+ Coverage        80.34%   82.11%   +1.77%     
===============================================
  Files              101      121      +20     
  Lines             8171     9841    +1670     
===============================================
+ Hits              6565     8081    +1516     
- Misses            1606     1760     +154     

☔ View full report in Codecov by Harness.
📢 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.

2 participants