Hands-on: From a VCF to a Recommendation

Build a miniature pharmacogenomics pipeline in your browser: read a patient's VCF, call CYP2C19 and DPYD, and turn the results into a guideline-based summary. Along the way, meet the traps that make real tools necessary.

🟡 Intermediate ⏱️ ~1 hr 🐍 Python in your browser 🌐 No install
Educational content, not medical advice. The patients here are invented, and the code is a teaching simplification. Real reports must come from a validated clinical test, analysed with dedicated software and checked against the current CPIC guideline.

Before you start

Learning objectives

By the end of this lesson you will be able to: read genotypes for pharmacogenomic positions from a VCF; turn CYP2C19 genotypes into a diplotype and phenotype; calculate a DPYD activity score; produce a guideline-based summary; and explain the traps (missing positions, DNA strand, phasing) that real tools such as PharmCAT are built to handle.

The pipeline you will build

1. Read the VCFcopies of each variant 2. CYP2C19diplotype, phenotype 3. DPYDactivity score 4. Summaryper CPIC guideline A miniature version of what PharmCAT does for real reports.
Four small steps, one Python box each.

1Read the genotypes from a VCF

A VCF lists one variant per line. The last column, GT, is the genotype: 0/0 means no copies of the variant, 0/1 one copy, 1/1 two copies, and ./. means the position could not be read (a no-call). Our patient file holds only the seven positions we need, on the GRCh38 genome build.

The strand trap: DPYD reads backwards

CYP2C19 sits on the forward strand of chromosome 10, so its VCF letters match its gene names: rs4244285 is G>A in both. DPYD sits on the reverse strand of chromosome 1, so the VCF shows the opposite (complementary) letters. The variant called c.1905+1G>A in DPYD reports appears in a VCF as C>T at chr1:97,450,058. Matching DPYD variants by letters instead of by position or rsID is a classic, dangerous error.

2Call the CYP2C19 diplotype and phenotype

We count the no-function variant copies (*2, *3) and the increased-function copies (*17), then apply the CPIC table from the last lesson.

A simplification to notice

A standard VCF genotype like 0/1 does not say which chromosome copy carries the variant (it is unphased). When a patient carries one *2 variant and one *17 variant, our code assumes they are on different copies (*2/*17). Real tools handle these ambiguous cases explicitly, and also check dozens of rarer alleles that this mini-version ignores.

3Calculate the DPYD activity score

Start with two fully working copies (value 1 each), add the value of every variant copy found, and add up the two lowest values, as the CPIC guideline describes.

4Write a guideline-based summary

Finally, translate the results using the CPIC recommendations: clopidogrel for patients with acute coronary syndrome or a stent (CPIC 2022), and the starting dose of 5-FU or capecitabine (CPIC 2017 update).

Checkpoint: patient A

CYP2C19 *1/*2, intermediate metabolizer, so avoid clopidogrel after ACS or PCI. DPYD activity score 1.5 (one copy of c.2846A>T), so reduce the starting fluoropyrimidine dose by 50%.

Your turn: three more patients

In the first box, change PATIENT = "A" to "B", "C" and then "D", and re-run all four boxes each time. Predict each result before you run it.

Show the answers

Patient B: CYP2C19 *17/*17, ultrarapid metabolizer, so the standard clopidogrel dose. DPYD: one copy of c.1905+1G>A, activity score 1, so reduce the starting dose by 50%.

Patient C: CYP2C19 poor metabolizer (two copies of the *2 variant), so avoid clopidogrel. DPYD: two copies of c.2846A>T, activity score 1, so a 50% reduction by the score. But the CPIC guideline adds a caveat: people with two copies of c.2846A>T may need a larger reduction. A simple score does not capture every rule, which is why the full guideline must always be read.

Patient D: the HapB3 position is missing from the file. The code reports "not determined" instead of assuming normal. That is the correct behaviour: a missing position is a no-call, not a negative result. Treating it as "no variant" could give a full dose to someone who cannot clear the drug.

How real tools do it: PharmCAT

The Pharmacogenomics Clinical Annotation Tool (PharmCAT) does what you just did, at clinical scale: it reads a VCF, finds the guideline variants, works out diplotypes for many genes, and writes a report with CPIC and DPWG (Dutch) recommendations. Its input rules are the traps from this lesson, made strict:

  • The VCF must be on GRCh38; PharmCAT will not convert other builds for you.
  • Every required position must be present, including 0/0 sites: a missing position is treated as a no-call, which weakens the report.
  • Variants must be normalized (for example with bcftools norm), and chromosome names need the chr prefix.
  • It ignores the QUAL and FILTER columns, so low-quality calls must be removed before running it.

For CYP2D6 from sequencing data, PharmCAT relies on simple variants and deletions; structural variants such as duplications and CYP2D7 hybrids need a dedicated caller (Stargazer, Aldy, StellarPGx) whose result can then be passed in.

Check your understanding

A VCF has no line at all for one of the DPYD positions you need. How should your pipeline treat it?
A missing position means it was not assessed. Assuming "no variant" could hide a no-function allele, so the honest result is "not determined", exactly as PharmCAT treats it.
Why does the DPYD variant c.1905+1G>A appear as C>T in a VCF?
Gene names describe the coding strand. For a gene on the reverse strand, the VCF shows the complementary bases: G becomes C and A becomes T.
A patient carries one copy of c.1679T>G (value 0) and no other DPYD variants. What is the activity score and the CPIC starting-dose advice?
One working copy (1) plus one no-function copy (0) gives 1, an intermediate metabolizer, for whom CPIC recommends a 50% lower starting dose, then adjustment.
Why can an unphased genotype such as one *2 variant plus one *17 variant be ambiguous?
Unphased genotypes only count copies. Assuming the variants are on different chromosomes (*2/*17) is a common default, but real tools flag or resolve the ambiguity.
PharmCAT ignores the QUAL and FILTER columns. What does that mean for you?
Since PharmCAT reads only the genotypes, any filtering for quality has to happen upstream, in your variant-calling pipeline.

Sources & further reading

  1. Lee CR, Luzum JA, Sangkuhl K, et al. Clinical Pharmacogenetics Implementation Consortium guideline for CYP2C19 genotype and clopidogrel therapy: 2022 update. Clin Pharmacol Ther 112: 959-967, 2022. doi:10.1002/cpt.2526
  2. Amstutz U, Henricks LM, Offer SM, et al. Clinical Pharmacogenetics Implementation Consortium (CPIC) guideline for dihydropyrimidine dehydrogenase genotype and fluoropyrimidine dosing: 2017 update. Clin Pharmacol Ther 103: 210-216, 2018. doi:10.1002/cpt.911
  3. Pratt VM, Cavallari LH, Fulmer ML, et al. DPYD genotyping recommendations: a joint consensus recommendation of AMP, ACMG, CPIC, CAP, DPWG, ESPT, PharmGKB, and PharmVar. J Mol Diagn 26: 851-863, 2024. doi:10.1016/j.jmoldx.2024.05.015
  4. Sangkuhl K, Whirl-Carrillo M, Whaley RM, et al. Pharmacogenomics Clinical Annotation Tool (PharmCAT). Clin Pharmacol Ther 107: 203-210, 2020. doi:10.1002/cpt.1568
  5. Li B, Sangkuhl K, Keat K, et al. How to run the Pharmacogenomics Clinical Annotation Tool (PharmCAT). Clin Pharmacol Ther 113: 1036-1047, 2023. doi:10.1002/cpt.2790
  6. PharmCAT documentation: VCF requirements. pharmcat.clinpgx.org
  7. ClinPGx: CPIC guidelines and the PharmGKB knowledge base (current guideline versions). clinpgx.org

Last reviewed: October 2026.

You finished Track 7 (part 1)

Back to the roadmap →