Repository navigation
fix: compute test metrics once over the complete test set - #3
Merged
Merged
Conversation
Test metrics were logged as the mean of per-batch values. They are now accumulated in fp32 and computed once per test source in on_test_epoch_end, so Varformer.evaluate() returns metrics over the complete test set. Also shorten code comments to describe the current behaviour.
The benchmark negatives are selected by geneticConstraint, so the feature is no longer a model input by default. Checkpoint loading reads the setting from the checkpoint, so models trained with the feature still load.
The paper models train with 32-bit precision and the variant head (loss weight 0.1), without Weights & Biases logging. Training with the defaults now needs variant_labels_path.
Trained weights are not distributed. The README now describes local checkpoints and the new defaults.
aaronwtr
commented
Oct 16, 2026
| use_pvc: bool = True | ||
| shuffle_pvc_across_genes: bool = False | ||
| gc_exclude_features: list[str] = Field(default_factory=list) | ||
| gc_exclude_features: list[str] = Field(default_factory=lambda: ["geneticConstraint"]) |
Owner
Author
There was a problem hiding this comment.
why do we hardcode geneticConstraint here? we pass the features to exclude in the config right?
aaronwtr
commented
Oct 16, 2026
| [](https://github.com/aaronwtr/Varformer/actions/workflows/ci.yml) | ||
| [](#) | ||
| [](#) | ||
|
|
Owner
Author
There was a problem hiding this comment.
change title to also include "...drug target and variant prioritization"
aaronwtr
commented
Oct 16, 2026
| The paper trains separate models for four variant catalogues: African/African-American (AFR), Admixed American (AMR), Non-Finnish European (NFE), and South Asian (SAS, via the Genes & Health British Bangladeshi and Pakistani cohort). | ||
|
|
||
| <p align="center"> | ||
| <img src="docs/figures/overview_figure.png" alt="Varformer architecture overview" width="780"/> |
Owner
Author
There was a problem hiding this comment.
we need to update the overview figure in accordance with the latest version
aaronwtr
commented
Oct 16, 2026
|
|
||
| To train without the variant head, set `"variant_head": False` and `"variant_loss_weight": 0.0`. | ||
|
|
||
| The gene-level results in the paper come from models with these settings and the default gene features. The variant scores used in the Genes & Health analyses come from SAS models that were trained with the same settings and with `geneticConstraint` as an additional gene input (`"gc_exclude_features": []`). `from_pretrained` and `from_checkpoint` read this setting from the checkpoint. |
default.yml is the source of the defaults; the Python model no longer repeats the feature name.
…w figure Remove the README paragraph on the gene-level and Genes & Health models.
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.
What changes
varformer/training/lightning_module.py: the test branch of_logno longer logs one value per batch. It stores probabilities, calls and labels in fp32 for each test source.on_test_epoch_endcomputes accuracy, AUROC, Spearman, recall, precision, F1 and AUPRC once over the complete test set and logs them under the same names (test_<metric>_<source>).Varformer.evaluate()therefore returns metrics over the complete test set.lightning_module.pyanddata/loaders.pyare shortened to describe the current behaviour.Behaviour change
Before this change, each test metric was the batch-size-weighted mean of per-batch values, computed on the precision of the model output. The values of
test_*metrics change for test sets that are larger than one batch.Tests
test_test_metrics_are_computed_once_over_the_complete_test_set.pyteston the tracked tests: 83 passed, 1 skipped.ruff checkpasses on the changed files.Second commit: genetic constraint is not a default model input
gc_exclude_featuresnow defaults to["geneticConstraint"](varformer/config.pyand bothdefault.ymlfiles). The paper selects the benchmark negatives by this feature, so the models in the paper do not use it as an input. The benchmark construction still reads the value as metadata.Varformer.from_pretrainedandfrom_checkpointreadgc_exclude_featuresfrom the checkpoint. Checkpoints that were trained with the feature therefore still load. A checkpoint that was saved before the option existed loads with all features.README.md: the model section and the variant head section state which gene features the paper models use.Behaviour change
A new training run has nine Open Targets features instead of ten. Pass
config_overrides={"gc_exclude_features": []}to train with all ten.Tests
test_genetic_constraint_is_not_a_default_model_inputandtest_saved_gc_exclusions.pyteston the tracked tests: 85 passed, 1 skipped.ruff checkpasses on the changed files.Merge of
mainmainis merged into this branch (e5672d5), so the branch includes the removal ofscores/gene_scores.tsv.gz(5f6bbc6).Third commit: the paper settings are the defaults
varformer/config.pyand bothdefault.ymlfiles now use the settings of the paper models:precision16-mixed32-truevariant_headFalseTruevariant_loss_weight0.00.1wandbTrueFalseThe other defaults already matched the training settings in the paper (batch size 128, 100 epochs, AdamW, weight decay 3e-4, cosine annealing with warm restarts every 200 steps between 1e-4 and 1e-5, gradient clipping at 1.0, maximum norm 20 for the mutation embeddings, dropout 0.3).
Behaviour change
Training with the defaults now needs
variant_labels_path(or theVARFORMER_VARIANT_LABELSenvironment variable). Without it, training stops with the existing error "set variant_labels_path". To train without the variant head, passconfig_overrides={"variant_head": False, "variant_loss_weight": 0.0}.Tests
test_defaults_match_the_paper_models.Fourth commit: no Hugging Face release in the README
Trained weights are not distributed.
README.md:from_pretrainedloads local checkpoints;variant_labels_pathto the training example;pyteston the tracked tests: 86 passed, 1 skipped.ruff check varformer testspasses.