Repository navigation
feat: hvantk training-set build — labelled, tiered ML training datasets - #484
Conversation
DatasetManifest.score_provenance carries the plugin's scores: block (score field -> trained_on sources); PluginRegistry.get_manifest returns one dataset's descriptive manifest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An atlas whose genes are Ensembl ids (e.g. a bulk Expression Atlas experiment) can now go through annotate prepare as a matrix entry with key: gene_id; version suffixes are dropped and no --hgnc is needed. key: symbol behaves as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Columns get L1-L4 from their declared trained_on (via resolve_arms against the label's sources) and explicit spec declarations; a column with neither is excluded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
label_clinvar_variants replaces apply_clinvar_training_labels: missense SNVs labelled from the primary CLNSIG (text before the first '|'), review stars from the comma-re-joined CLNREVSTAT, GENEINFO genes kept in order. label_training_set now returns that 1/0 label; its TP/TN column and gene_set/disease_terms gating are removed with the legacy training-set builder they served. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The feature spec gains label, variant, gene and gene_lists sections and a tier per layer1 axis, all optional, so annotate specs are unchanged. Cross-section checks run when the spec loads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dotted field selection with float casts and max-reduction for allele-keyed sources, PTM codon loci, and the multi-gene choice (first candidate a second source also assigns, else the first). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
build_training_set labels ClinVar rows, joins the spec's variant sources (allele columns, interval and codon flags), chooses each row's gene, joins the composed gene matrix and gene-list flags, resolves tiers and measures every column. write_training_set writes the .ht and the deterministic .tsv.gz with provenance, the feature dictionary and the manifest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The command reads the spec, checks every --input and --gene-list name against it before Hail starts, takes each axis's columns from the compose manifest and each variant source's trained_on from its plugin manifest, then builds and writes the training set. The NAME=PATH option parser is shared with annotate compose. The TSV is written through core.io.save (save_native has no .tsv.gz path). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
examples/training_sets/ now holds the ClinVar x heart spec and the commands that build it. The annotators, their composite scores and the legacy artifact loader go; docs gain the training-set page, the README row and the changelog entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hl.hadoop_open crosses into the JVM for every read: the export came back at about 0.2 MB/s and, on a 210,000 x 312 table, stalled for good after an hour. The export is now opened directly when Hail's temporary directory is local, or copied to a local temporary directory once. Output is byte-for-byte unchanged (checked against the previous reader); 20,000 x 307 takes 48 s instead of 552 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A column built from several scores (fields + reduce) and the score columns of a layer1 axis that aggregates per-variant scores now take their inputs' trained_on (union; undeclared if any input is), so a declared tier can no longer hide circularity there; the CLI fetches provenance for aggregated axes too. - The manifest lists every unmapped gene-list symbol (the mapper's report names at most 20) with counts that reconcile: symbols in, symbols mapped, genes, unmapped. - The TSV read-back treats a temp path with no scheme as local only if it exists on this disk; otherwise (Hadoop default filesystem, e.g. HDFS) it is copied once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A tier is now the higher of the one derived from trained_on and the spec's declaration, so a declaration can raise a tier but never lower it; a column trained on ClinVar and population_af is L3. The heart spec's 301 feature tiers are unchanged. - The CLI runs the input checks (now also codon fields and the HGNC fields the builder reads) before loading anything and reports a mistake as a usage error, as the docs say. - The dictionary's label description lists the classes with ', '. - The package docstring no longer mentions the removed annotators. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Documentation | 27 minor |
| CodeStyle | 1 minor |
| Complexity | 11 medium |
🟢 Metrics 251 complexity
Metric Results Complexity 251
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
- resolve_tiers takes equivalence=None instead of a dict default. - build_training_set documents spec_sha256 and legacy_names. - The example README no longer has a literal tab inside inline code.
|
Codacy triage (51477d9):
|
Summary
Adds
hvantk training-set build, which builds a labelled ML training dataset from one feature spec. Each feature column gets a leakage tier, L1 to L4. The command replaces the library-onlyhvantk/tools/training_sets/path, which read pre-plugin tables by path and added hand-weighted composite scores.Rows and labels. The rows are ClinVar GRCh38 missense SNVs:
|);import_vcfsplits it;Columns. The spec declares them:
annotate composematrix built from the same spec;is_chd_gene.Gene choice. Each row gets one gene: ClinVar GENEINFO Entrez id → HGNC → Ensembl. When ClinVar lists several genes, the first one dbNSFP also assigns to the variant wins, else the first listed.
Tiers are the higher of two:
scores: trained_on: L2 if trained on the label's sources (ClinVar, HGMD, OMIM, ...), L3 if trained onpopulation_af, otherwise L1.tier:: L4 for an allele frequency or a score that takes one as input, L3 for constraint, L2 for e.g. simulated-allele predictors.A declaration can raise a tier but never lower it, so it cannot hide circularity. That includes columns built from several scores and gene axes that aggregate scores. A column with neither a declaration nor a
trained_onis left out and listed in the manifest.Outputs:
<prefix>.ht, a deterministic<prefix>.tsv.gz,<prefix>.dictionary.tsv(one row per column with tier, level, source, version, non-null and true rates) and<prefix>.manifest.json(funnel counts, label balance, gene choice, tiers, exclusions, gene-list mapping, input provenance).Changes
hvantk/tools/training_sets/{build,training_set_cli}.pyandtraining_set_cli.tool.yaml. The NAME=PATH option parser is shared withannotate composethroughhvantk/tools/_cli_utils.py.algorithms/annotation/tiers.py, a pure-Python tier rule built onrerank/provenance.resolve_arms.algorithms/annotation/variant.py, with field selection, PTM codon loci and the multi-gene choice.label,variant,geneandgene_listssections, plus atierperlayer1axis. Existing specs are unchanged.annotate prepare: a matrix source may be keyed by Ensemblgene_id(version suffixes are dropped and no--hgncis needed).DatasetManifest.score_provenanceexposes a plugin'strained_onblock, andPluginRegistry.get_manifestis new.label_clinvar_variantsreplacesapply_clinvar_training_labels..tsv.gzexport: the export of a hail table read Hail's temporary file back line by line throughhl.hadoop_open. That ran at about 0.2 MB/s and stalled for good on a 210,867 x 312 table. The file is now read from local disk, and copied there once when the temp directory is not local. The output is byte-for-byte unchanged; a 20,000 x 307 table takes 48 s instead of 552 s.examples/training_sets/clinvar_heart.yaml, a ClinVar x heart dataset, with a README of the build commands.docs_site/tools/training-set.md, a README row and the CHANGELOG.Breaking changes
ClinVarVariantTableStreamer.label_training_set()now returns a 1/0labelwithclinvar_review_stars, for missense SNVs. Therf_labelTP/TN column and thegene_set,disease_termsandlabel_columnoptions are removed.ptm constraintstill reads a TP/TN column, and its page shows how to derive one.TrainingSetBuilderandbuild_clinvar_training_set;algorithms/annotation/annotator.py, with its composite scores;core/io/legacy_artifacts.py;examples/training_sets/generate_enhanced_training_set.py.Verification
.tsv.gzfiles.gene_id/gene_symbolon 3,020 multi-gene rows, where the new gene rule applies by design.pqtlcaplog tests fail in a full run, but they fail the same way ondev(order-dependent) and pass alone.