Before you start
- Do Star alleles, diplotypes and phenotypes first.
- You should know what a VCF file is. If not, see File formats.
- Everything runs in your browser. Run the four Python boxes in order: each one uses results from the box before.
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
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/0sites: 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 thechrprefix. - 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
Sources & further reading
- 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
- 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
- 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
- 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
- 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
- PharmCAT documentation: VCF requirements. pharmcat.clinpgx.org
- ClinPGx: CPIC guidelines and the PharmGKB knowledge base (current guideline versions). clinpgx.org
Last reviewed: October 2026.