Pharmacogenomic guideline import — scope
Status: Draft scope (not yet approved for build) Date: 2026-07-29
Problem
pgxAnnotations is selected on the genetics page, included in the JSON archive
export, and deleted when its variant is deleted. No application code path
writes to it — there is no action and no importer.
One thing does: seed-genetics.mjs, which the public demo runs. It inserts a
single row — CYP2C19 *1/*2, intermediate metaboliser, clopidogrel, "consider
alternative antiplatelet", attributed to CPIC at evidence level A.
That is worse than an empty panel. A visitor to the demo sees a working pharmacogenomics feature, complete with a diplotype the application has no means of calling and a CPIC recommendation with no importer behind it, and no sequence of actions available to any user reproduces it. ADR-0010 discloses that demo data is invented, which covers invented values; it does not cover a panel that demonstrates a capability the code does not have. Whatever else this scope does, it should end with the seed row being something the import path could actually have produced.
This is the one genomics gap where the missing piece is a data source rather than a design. The columns are right: gene, diplotype, phenotype, drug, recommendation, guideline, evidence level, source.
The licence decides the architecture
The prior-art workspace ships a PharmGKB download alongside its licence file, which is CC BY-SA 4.0 with two additions that matter:
ShareAlike: If you alter, amend, reuse or otherwise change PharmGKB data you agree that if you distribute such product, all recipients shall first agree to be subject to this license. Proof of such agreement shall be made available to PharmGKB. Under no circumstances can PharmGKB data be sold for other's private or commercial use.
A viral ShareAlike, a prohibition on sale, and an obligation to produce evidence that downstream recipients accepted the terms. It covers the source tables and every file derived from them.
This repository is published and ships a public demo (ADR-0010), so the conclusion is the same one the terminology layer reached about SNOMED, for the same reason: the data is provisioned locally, never committed, never shipped. The pattern already exists twice over — the ŠÚKL mirror, the catalogue snapshot, the terminology artifact. This is the third instance, not a new problem.
Access is open; the licence is the whole constraint. The archive downloads
from s3.pgkb.org/data/clinicalAnnotations.zip with no account, no key and no
terms gate — verified 2026-07-29, byte-identical to the copy in the prior-art
workspace. So provisioning can be a command that fetches, closer to the ŠÚKL
mirror sync than to npm run data:unii -- --file <archive>, which needs a
hand-downloaded file because the FDA publishes no stable URL.
Fetching for local use is use. Committing the result, or serving it from the demo, is redistribution. The line runs between those two and not at the download.
Attribution and a licence link are owed wherever the derived annotations are displayed.
The prior art extracts the wrong rows
The workspace contains three scripts that produce three datasets, and all three
are mislabelled. PharmGKB records the issuing body in
clinical_ann_evidence.tsv, joined to annotations on Clinical Annotation ID:
| Evidence Type | Rows | Body |
|---|---|---|
| Guideline Annotation | 433 | CPIC 324, DPWG 109 |
| Label Annotation | 74 | FDA 74 |
None of the three scripts open that file. Each filters
clinical_annotations.tsv on Level of Evidence and infers the body from the
tier:
| Output | Claims to be | Actually is | Error |
|---|---|---|---|
cpic_guidelines.json |
CPIC Level 1A/1B, 122 gene-drug pairs | PharmGKB levels 1A+1B, 328 annotations | Right evidence tier, wrong criterion — CPIC membership never checked |
fda_pgx_biomarkers.json |
FDA biomarkers, 48 genes / 395 annotations | PharmGKB levels 1A+1B+2A+2B, 396 annotations | Five times the real count, and no FDA provenance whatever; the accompanying instructions file concedes the FDA table was never downloaded |
dpwg_guidelines.json |
2,919 DPWG pairs at "Level 3/4, highest quality" | PharmGKB levels 3+4, 4,790 rows | Twenty-seven times the real count, and inverted |
The DPWG one is the dangerous case. PharmGKB grades 1A strongest to 4 weakest; levels 3 and 4 together are 91% of the file (4,482 and 308 of 5,186 rows). The accompanying reference note asserts the opposite — "Level 3-4: Highest quality evidence (equivalent to CPIC 1A/1B)" — and the script's own comments concede the guess in the word often. Importing that file would badge PharmGKB's weakest evidence tier as European clinical guidance inside a health record.
None of the three derived files may be imported. They are regenerable from the source tables by the correct join, and that join is smaller, attributable and honest.
Design
Fetch or accept the PharmGKB annotations archive. Join clinical_annotations
to clinical_ann_evidence on Clinical Annotation ID. Keep only
Guideline Annotation and Label Annotation rows; take the issuing body from
the evidence summary and the Evidence URL, which is a durable
pharmgkb.org/guidelineAnnotation/PA… reference. Take per-genotype text from
clinical_ann_alleles.
guideline and source then hold what was actually asserted and by whom,
rather than a tier the importer read a body into. Roughly 500 well-attributed
annotations replace 2,919 mislabelled ones.
Record the source version from the archive's own creation stamp, not from when
it was fetched. The current release is dated 2025-07-05 and was still what
s3.pgkb.org served a year later, while the summary written beside the copy in
the prior-art workspace claims February 2026. The file was right and the prose
was wrong, which is the argument for storing provenance rather than trusting a
description of it — and for showing the reader how old the guidance is, since a
year-old release is normal here and not a fault.
Genotype, not diplotype
clinical_ann_alleles is keyed by plain genotype — CC, CT, TT — with an
annotation text and an allele function per row. That is a better fit for this
record than it first appears.
Full pharmacogenomics is diplotype-based: star alleles such as CYP2D6 *1/*4,
called from haplotypes and, for CYP2D6 specifically, from copy number that
neither an array nor a single-sample VCF reliably provides. The diplotype
column anticipates that and should stay empty rather than be filled with a
guess.
But SNP-level annotations need no star-allele calling at all. They key off the
observed genotype, which the record already stores as ref, alt and zygosity.
That covers the pharmacogenomics an array does well — VKORC1, SLCO1B1, DPYD,
TPMT, CYP2C19 *2, CYP2C9 *2/*3 — and it is where the actionable guidance
concentrates.
So: populate from genotype, leave diplotype null, and be explicit in the interface that a gene reported without a diplotype has been assessed at the level of individual variants and not as a haplotype. A CYP2D6 result that is silent about copy number is not a CYP2D6 phenotype.
CPIC and DPWG will disagree
They are separate bodies with separate grading systems and they issue different
advice for the same gene-drug pair — codeine and clopidogrel are the standing
examples. The schema handles this correctly already, since guideline is a
column and a variant may carry several annotation rows.
What must not happen is a reconciliation. Two guidelines disagreeing is information a prescriber wants, and collapsing it to one row destroys it. Show both, attributed, the way conflicting evidence rows are shown for a variant.
Note also that a PGx evidence level is a different scale from the ClinVar review stars handled in the evidence confidence gating scope. Neither may be rendered in the other's vocabulary; a 1A is not four stars.
Open questions
- Does an annotation attach to a variant, or to a gene when no typed variant underlies it? The column is nullable and the association table faced the same question.
- What happens when a re-provisioned archive changes a recommendation? Variants have a reinterpretation trail; annotations do not, and drug guidance changing is at least as consequential as a classification changing.
- Should the emergency and new-doctor exports carry a pharmacogenomic summary? It is the single most useful genomic output for a prescriber, and the prior-art workspace ends every report by recommending a wallet card. It is also the point at which a licence-encumbered derivation leaves the machine.
- Drug identity: annotations name drugs as free text, while the record already resolves substances through ATC/RxNorm/UNII (ADR-0007). Joining them is what would let an annotation surface against a medication the person actually takes, which is the whole value — and it is a terminology problem.
- Does an unprovisioned instance hide the panel, or show it as unprovisioned?
Not in scope
Shipping any PharmGKB-derived data in the repository or in a catalogue release. Star-allele or diplotype calling. Copy number inference. Any dosing recommendation authored by this project rather than quoted with attribution from a guideline. Interaction checking, which the roadmap already gates behind showing source, update date and uncertainty.
Relationship to the other plans
Last of the four, because it is the largest and because the drug-identity question above is really a request for the concept map in the terminology layer. Independent of the other three in mechanism, but most useful after array import, since the common pharmacogenomic SNPs are exactly what a consumer chip types well — the one place where array data is straightforwardly good rather than a lead requiring confirmation.