Back to projects

Bioinformatics

AfriPharmaGen: pharmacogenomic interpretation for African populations

An agentic system that interprets a patient genotype where CPIC and DPWG guidelines were never calibrated for the population in front of it.

Research software. It is not validated for clinical use, and its output should not guide diagnosis or treatment without review by a qualified clinician.

PythonPydanticOllamaFastAPIPharmVarCPIC/DPWG

Sources for the numbers on this page: Frontiers in Pharmacology (2025), ancestry of PharmGKB study participants.


Problem

Pharmacogenomics guidelines are built almost entirely on European-descent data. Across 1,225 pharmacogenomic studies annotated in PharmGKB, 3,031 of 651,532 participants (0.46%) were of African ancestry. African populations carry star alleles, structural variants, and haplotypes that the standard callers (PharmCAT, StarGazer, Aldy) return a "no call" for, because those alleles are absent from the reference definitions the tools depend on.

The clinical cost is concrete. CYP2B6 slow-metabolizer phenotype, which governs efavirenz dosing in HIV treatment, runs two to three times more common in some African groups than in Europeans. TB, HIV, and malaria co-treatment stacks drugs whose gene-drug pairs have no CPIC guideline at all. A patient gets dosing guidance calibrated to a population that does not represent them, and adverse reactions follow.

The tools stop where the guideline stops, and for these populations the guideline usually stops early.

How it works

AfriPharmaGen is structured as an agent that keeps gathering evidence until it is either confident or explicitly stuck. The agent package separates concerns into a planner, a reasoner, a reflector, a tier classifier, a guideline lookup, an exemplar selector, a working memory, and a firewall that inspects both what reaches the model and what it returns.

Inference runs on a local Ollama model by default. Cloud LLM backends (Anthropic, OpenAI) are an opt-in extra that requires explicit consent, because the input is patient genotype data and the privacy default has to be on-device. A PII layer scrubs free-text evidence before it reaches any model.

The knowledge layer is explicit code: African-specific allele definitions, CPIC and DPWG tables, PharmVar mappings, and a drug-interaction model, each validated against Pydantic schemas so a malformed entry fails when it loads, before any interpretation starts.

Patient VCF / panel
      |
      v
  [ Planner ] --> [ Guideline lookup ] --> [ Reasoner ] --> [ Reflector ]
      |               (CPIC / DPWG /            |               |
      |                African alleles)         |               v
      |                                         |         confident? --no--> gather more evidence
      v                                         v               |
  [ Firewall + PII scrub ]              [ Tier classifier ]     yes
      (egress + ingress)                                         |
                                                                 v
                                                    Clinical report + evidence chain

Hard parts

  • Reasoning past "no data available": for a novel variant absent from every database, the agent gathers functional prediction, population-frequency context, and literature evidence and reasons about likely impact and reports it.
  • Population-specific frequency context: metabolizer-phenotype prediction is conditioned on the specific population (for example Yoruba, Luhya or Mende).
  • Polypharmacy interaction chains: the drug-interaction model reasons across TB, HIV, and malaria co-treatment (rifampicin, efavirenz, isoniazid) across the whole drug combination.
  • Calibrated uncertainty: where no guideline exists, the system produces a provisional, research-only interpretation with its uncertainty stated.
  • A firewall on both directions: an egress rule scopes what leaves to citation domains, and an ingress path scrubs PII from free-text evidence before it reaches the model.

Results

The evaluation harness runs published-case, scenario, and stress suites against the interpreter, with results kept under version control. The differentiator over PharmCAT, StarGazer, and Aldy is behavioural: where those tools return a no-call for a novel African allele, AfriPharmaGen returns a reasoned functional impact with its evidence chain and a confidence score.

  • African allele coverage the standard callers miss, called with population-aware haplotype definitions.
  • Provisional, research-only interpretations with stated uncertainty for gene-drug pairs that have no CPIC or DPWG guideline.
  • An evaluation suite (published cases, scenarios, stress) kept in the repository so outcomes are reproducible.

Artifacts

The interpreter ships as a Python package with a local-LLM default and opt-in cloud backends. A companion curated allele catalog and a Bayesian allele-frequency estimator (separate repositories) supply the population-frequency foundation the interpreter reasons over.

Back to projects