Lab
The building blocks of this site's posts, working, each with the code that produces it.
Every component here is shared: any post can use it. Units are shown on every parameter and axis, colours come from the design tokens so everything follows the light and dark themes, and interactive pieces load their JavaScript only when they scroll into view. All data on this page is illustrative.
Content
Written straight into a post's MDX; no import needed.
Callout
An aside: a note (the default), a tip or a warning, with an optional title. Add class="wide" to span the wide column.
Note
A note: the peak time does not depend on dose.Shortcut
Press / to search the site.Check your units
NONMEM does not track units. If the dose is in mg and V in L, setS2 = V.
<Callout>A note: the peak time does not depend on dose.</Callout>
<Callout type="tip" title="Shortcut">Press / to search the site.</Callout>
<Callout type="warning" title="Check your units"> NONMEM does not track units. If the dose is in mg and $V$ in L, set `S2 = V`.</Callout>PostLink
A link to another post that shows the post's current title, so retitling a post retitles every link to it. In Markdown and MDX, leave the link text empty; in .astro pages, use <PostLink>. A slug with no post fails the build.
The newest post is Where distributions enter pharmacometric models.
Every number here comes from the engine; [](/posts/how-this-site-is-built/) has more.
Links with their own text keep it: [the colophon](/posts/how-this-site-is-built/).---import { PostLink } from '../components/content';---
<p><PostLink slug="how-this-site-is-built" /> explains how.</p><p>The <PostLink slug="how-this-site-is-built" hash="hosting" /> section on hosting.</p>Figure
An image with a caption, numbered automatically and lazy-loaded at responsive sizes. alt is required; variant is default, wide or full.

import bateman from './bateman.png';
<Figure src={bateman} alt="Concentration rises steeply to a peak of 1.60 mg/L at 2.2 h, then declines to about 0.2 mg/L at 24 h."> Concentration after a single 100 mg oral dose ($k_a$ = 1.2 1/h, $CL$ = 5 L/h, $V$ = 50 L).</Figure>Static charts
Drawn to SVG when the site is built: no JavaScript, and they still follow the theme. Use these unless the reader can do something with the chart.
StaticChart, ready-made
A named chart (concentration-time, obs-pred, vpc or forest) from data in the post folder. table adds the numbers under “View data”.
View data
| Series | Time (h) | Concentration (mg/L) |
|---|---|---|
| 100 mg | 0 | 0 |
| 100 mg | 0.5 | 0.878 |
| 100 mg | 1 | 1.317 |
| 100 mg | 1.5 | 1.517 |
| 100 mg | 2 | 1.588 |
| 100 mg | 2.5 | 1.591 |
| 100 mg | 3 | 1.557 |
| 100 mg | 3.5 | 1.505 |
| 100 mg | 4 | 1.445 |
| 100 mg | 4.5 | 1.381 |
| 100 mg | 5 | 1.318 |
| 100 mg | 5.5 | 1.256 |
| 100 mg | 6 | 1.196 |
| 100 mg | 6.5 | 1.138 |
| 100 mg | 7 | 1.083 |
| 100 mg | 7.5 | 1.03 |
| 100 mg | 8 | 0.98 |
| 100 mg | 8.5 | 0.932 |
| 100 mg | 9 | 0.887 |
| 100 mg | 9.5 | 0.844 |
| 100 mg | 10 | 0.803 |
| 100 mg | 10.5 | 0.763 |
| 100 mg | 11 | 0.726 |
| 100 mg | 11.5 | 0.691 |
| 100 mg | 12 | 0.657 |
| 100 mg | 12.5 | 0.625 |
| 100 mg | 13 | 0.595 |
| 100 mg | 13.5 | 0.566 |
| 100 mg | 14 | 0.538 |
| 100 mg | 14.5 | 0.512 |
| 100 mg | 15 | 0.487 |
| 100 mg | 15.5 | 0.463 |
| 100 mg | 16 | 0.441 |
| 100 mg | 16.5 | 0.419 |
| 100 mg | 17 | 0.399 |
| 100 mg | 17.5 | 0.379 |
| 100 mg | 18 | 0.361 |
| 100 mg | 18.5 | 0.343 |
| 100 mg | 19 | 0.326 |
| 100 mg | 19.5 | 0.31 |
| 100 mg | 20 | 0.295 |
| 100 mg | 20.5 | 0.281 |
| 100 mg | 21 | 0.267 |
| 100 mg | 21.5 | 0.254 |
| 100 mg | 22 | 0.242 |
| 100 mg | 22.5 | 0.23 |
| 100 mg | 23 | 0.219 |
| 100 mg | 23.5 | 0.208 |
| 100 mg | 24 | 0.198 |
import profile from './profile.json';
<StaticChart kind="concentration-time" data={profile} options={{ timeUnit: 'h', concUnit: 'mg/L' }} alt="Concentration rises to a peak of 1.6 mg/L at about 2 h, then declines to 0.2 mg/L at 24 h." table> Concentration after a single 100 mg oral dose.</StaticChart>StaticChart, custom spec
Any other chart: a spec function that returns Plot options, built with themedPlot, chrome, categorical and axisLabel from src/lib/charts.
import { clearanceLinear } from './clearanceSpec';import clearances from './clearances.csv';
<StaticChart spec={clearanceLinear} data={clearances} alt="Individual clearance estimates in three dose groups, with similar medians."> Individual clearances by dose group; ticks mark the medians.</StaticChart>import * as Plot from '@observablehq/plot';import { axisLabel, axisLengths, axisScale, categorical, chrome, themedPlot, type SpecBuilder,} from '../../../lib/charts';
/** A row of clearances.csv. */export interface ClearanceRow { /** Dose group, e.g. `50 mg`. */ group: string; /** Individual clearance estimate (L/h). */ cl: number;}
/** * A custom chart: individual clearances as dots, one column per dose group, with each * group's median as a tick. Colours, gridlines and labels come from the chart theme. */export function clearanceSpec(log: boolean): SpecBuilder<readonly ClearanceRow[]> { return (data, ctx) => { const groups = [...new Set(data.map((d) => d.group))]; return themedPlot( { x: { label: 'Dose group', domain: groups, padding: 0.4 }, y: { label: axisLabel('Clearance', 'L/h'), ...axisScale(log), nice: true }, color: categorical(groups), marks: [ // A log axis is drawn by chrome(), which needs its length to space the ticks. ...chrome({ y: true, ...(log ? { log: { y: axisLengths(ctx).y } } : {}) }), Plot.dot(data, { x: 'group', y: 'cl', fill: 'group', r: 4, fillOpacity: 0.85 }), Plot.tickY( data, Plot.groupX({ y: 'median' }, { x: 'group', y: 'cl', strokeWidth: 2, stroke: 'group' }), ), ], }, ctx, ); };}
/** Built once at module scope: `PlotChart` redraws whenever a spec's identity changes. */export const clearanceLinear = clearanceSpec(false);export const clearanceLog = clearanceSpec(true);Chart islands
React charts that are redrawn to fit their container. Each needs ariaLabel, a text alternative; showTable adds the data as a table.
ConcentrationTimeChart
One line per series, labelled where it ends, with a linear/log toggle for the concentration axis.
View data
| Series | Time (h) | Concentration (mg/L) |
|---|---|---|
| 100 mg | 0 | 0 |
| 100 mg | 0.5 | 0.878 |
| 100 mg | 1 | 1.317 |
| 100 mg | 1.5 | 1.517 |
| 100 mg | 2 | 1.588 |
| 100 mg | 2.5 | 1.591 |
| 100 mg | 3 | 1.557 |
| 100 mg | 3.5 | 1.505 |
| 100 mg | 4 | 1.445 |
| 100 mg | 4.5 | 1.381 |
| 100 mg | 5 | 1.318 |
| 100 mg | 5.5 | 1.256 |
| 100 mg | 6 | 1.196 |
| 100 mg | 6.5 | 1.138 |
| 100 mg | 7 | 1.083 |
| 100 mg | 7.5 | 1.03 |
| 100 mg | 8 | 0.98 |
| 100 mg | 8.5 | 0.932 |
| 100 mg | 9 | 0.887 |
| 100 mg | 9.5 | 0.844 |
| 100 mg | 10 | 0.803 |
| 100 mg | 10.5 | 0.763 |
| 100 mg | 11 | 0.726 |
| 100 mg | 11.5 | 0.691 |
| 100 mg | 12 | 0.657 |
| 100 mg | 12.5 | 0.625 |
| 100 mg | 13 | 0.595 |
| 100 mg | 13.5 | 0.566 |
| 100 mg | 14 | 0.538 |
| 100 mg | 14.5 | 0.512 |
| 100 mg | 15 | 0.487 |
| 100 mg | 15.5 | 0.463 |
| 100 mg | 16 | 0.441 |
| 100 mg | 16.5 | 0.419 |
| 100 mg | 17 | 0.399 |
| 100 mg | 17.5 | 0.379 |
| 100 mg | 18 | 0.361 |
| 100 mg | 18.5 | 0.343 |
| 100 mg | 19 | 0.326 |
| 100 mg | 19.5 | 0.31 |
| 100 mg | 20 | 0.295 |
| 100 mg | 20.5 | 0.281 |
| 100 mg | 21 | 0.267 |
| 100 mg | 21.5 | 0.254 |
| 100 mg | 22 | 0.242 |
| 100 mg | 22.5 | 0.23 |
| 100 mg | 23 | 0.219 |
| 100 mg | 23.5 | 0.208 |
| 100 mg | 24 | 0.198 |
| 200 mg | 0 | 0 |
| 200 mg | 0.5 | 1.756 |
| 200 mg | 1 | 2.634 |
| 200 mg | 1.5 | 3.035 |
| 200 mg | 2 | 3.177 |
| 200 mg | 2.5 | 3.181 |
| 200 mg | 3 | 3.113 |
| 200 mg | 3.5 | 3.01 |
| 200 mg | 4 | 2.889 |
| 200 mg | 4.5 | 2.763 |
| 200 mg | 5 | 2.636 |
| 200 mg | 5.5 | 2.512 |
| 200 mg | 6 | 2.392 |
| 200 mg | 6.5 | 2.276 |
| 200 mg | 7 | 2.166 |
| 200 mg | 7.5 | 2.061 |
| 200 mg | 8 | 1.96 |
| 200 mg | 8.5 | 1.865 |
| 200 mg | 9 | 1.774 |
| 200 mg | 9.5 | 1.688 |
| 200 mg | 10 | 1.605 |
| 200 mg | 10.5 | 1.527 |
| 200 mg | 11 | 1.453 |
| 200 mg | 11.5 | 1.382 |
| 200 mg | 12 | 1.314 |
| 200 mg | 12.5 | 1.25 |
| 200 mg | 13 | 1.189 |
| 200 mg | 13.5 | 1.131 |
| 200 mg | 14 | 1.076 |
| 200 mg | 14.5 | 1.024 |
| 200 mg | 15 | 0.974 |
| 200 mg | 15.5 | 0.926 |
| 200 mg | 16 | 0.881 |
| 200 mg | 16.5 | 0.838 |
| 200 mg | 17 | 0.797 |
| 200 mg | 17.5 | 0.758 |
| 200 mg | 18 | 0.721 |
| 200 mg | 18.5 | 0.686 |
| 200 mg | 19 | 0.653 |
| 200 mg | 19.5 | 0.621 |
| 200 mg | 20 | 0.591 |
| 200 mg | 20.5 | 0.562 |
| 200 mg | 21 | 0.534 |
| 200 mg | 21.5 | 0.508 |
| 200 mg | 22 | 0.484 |
| 200 mg | 22.5 | 0.46 |
| 200 mg | 23 | 0.437 |
| 200 mg | 23.5 | 0.416 |
| 200 mg | 24 | 0.396 |
import ConcentrationTimeChart from '../../../components/charts/ConcentrationTimeChart.tsx';import profiles from './profiles.json';
<ConcentrationTimeChart client:visible data={profiles} timeUnit="h" concUnit="mg/L" showTable ariaLabel="Concentration–time curves after 100 mg and 200 mg oral doses. The 200 mg curve is twice as high at every time."> Doubling the dose doubles the concentration at every time. On the log scale the curves are parallel.</ConcentrationTimeChart>ObsPredChart
Observations against predictions on equal axes, with the line of identity.
import ObsPredChart from '../../../components/charts/ObsPredChart.tsx';import gof from './gof.csv';
<ObsPredChart client:visible data={gof} unit="mg/L" predLabel="Population prediction" ariaLabel="Observed against population-predicted concentrations, scattered evenly about the line of identity."> Observations against population predictions. The line is $y = x$.</ObsPredChart>VpcChart
A visual predictive check from pre-computed percentiles: simulated intervals as bands, observed percentiles as lines.
import VpcChart from '../../../components/charts/VpcChart.tsx';import vpc from './vpc.csv';
<VpcChart client:visible data={vpc} timeUnit="h" concUnit="ng/mL" yScale="log" ariaLabel="Visual predictive check: the observed 5th, 50th and 95th percentiles fall inside the simulated intervals at every time."> Observed percentiles (lines) against 95% intervals of the simulated percentiles (bands).</VpcChart>ForestPlot
Point estimates with intervals, top to bottom, against a reference line and an optional band.
View data
| AUC ratio to reference | Lower | Upper | |
|---|---|---|---|
| Weight 50 kg | 1.24 | 1.12 | 1.38 |
| Weight 100 kg | 0.81 | 0.73 | 0.9 |
| Mild renal impairment | 1.12 | 0.98 | 1.27 |
| Moderate renal impairment | 1.41 | 1.18 | 1.69 |
| Taken with food | 0.93 | 0.85 | 1.02 |
import ForestPlot from '../../../components/charts/ForestPlot.tsx';import covariates from './covariates.csv';
<ForestPlot client:visible data={covariates} xLabel="AUC ratio to reference" band={[0.8, 1.25]} log showTable ariaLabel="Covariate effects on AUC. Weight and moderate renal impairment fall outside 0.8 to 1.25; the others overlap it."> Ratios of AUC to a 70 kg adult with normal renal function, with 90% confidence intervals. The band is 0.8–1.25.</ForestPlot>PlotChart
The frame the charts above are built on: any spec, redrawn on resize and theme change, with an optional toolbar. It takes a function, so use it inside your own island.
import { useState } from 'react';import PlotChart from '../../../components/charts/PlotChart';import Toggle from '../../../components/controls/Toggle';import { clearanceLinear, clearanceLog } from './clearanceSpec';import clearances from './clearances.csv';
export default function PlotChartExample() { const [log, setLog] = useState(false);
return ( <PlotChart spec={log ? clearanceLog : clearanceLinear} data={clearances} ariaLabel="Individual clearance estimates in three dose groups, 2.6 to 9.8 L/h, with similar medians in each group." toolbar={ <div className="chart-toolbar"> <Toggle label="Log clearance axis" checked={log} onChange={setLog} /> </div> } > Clearance does not change with dose: the medians (ticks) are level across the groups. </PlotChart> );}Controls
Native form elements: labelled, keyboard-operable, with a visible focus ring. They take callbacks, so they live inside an island; the code shown is each example's own source.
Slider
A range input with its unit and a formatted readout, on a linear or log track.
import { useState } from 'react';import Slider from '../../../components/controls/Slider';
export default function SliderExample() { const [cl, setCl] = useState(5); const [v, setV] = useState(50);
return ( <div> {/* Log scale: equal track distances are equal ratios (needs min > 0). */} <Slider label="CL" unit="L/h" value={cl} onChange={setCl} min={0.5} max={50} scale="log" /> <Slider label="V" unit="L" value={v} onChange={setV} min={5} max={200} step={1} /> </div> );}NumberInput
A number field with its unit. Entries out of range are flagged, then clamped on blur.
import { useState } from 'react';import NumberInput from '../../../components/controls/NumberInput';
export default function NumberInputExample() { const [dose, setDose] = useState(100);
// An entry outside 10–1000 is flagged while typing and clamped on blur. return ( <NumberInput label="Dose" unit="mg" value={dose} onChange={setDose} min={10} max={1000} step={10} /> );}Toggle
An on/off switch: a checkbox with the switch role, so Space toggles it.
Showing a single dose
import { useState } from 'react';import Toggle from '../../../components/controls/Toggle';
export default function ToggleExample() { const [steadyState, setSteadyState] = useState(false);
return ( <div> <Toggle label="Steady state" checked={steadyState} onChange={setSteadyState} /> <p className="param-readout" aria-live="polite"> {steadyState ? 'Showing steady state' : 'Showing a single dose'} </p> </div> );}Select
A drop-down of typed options, with an optional unit.
import { useState } from 'react';import Select from '../../../components/controls/Select';
// `as const` keeps the values as a union type: `tau` is '8' | '12' | '24'.const INTERVALS = [ { value: '8', label: '8' }, { value: '12', label: '12' }, { value: '24', label: '24' },] as const;
export default function SelectExample() { const [tau, setTau] = useState<(typeof INTERVALS)[number]['value']>('12');
return ( <Select label="Dosing interval" unit="h" value={tau} onChange={setTau} options={INTERVALS} /> );}ParameterPanel and useParameters
Sliders and number fields drawn from a schema, with reset. useParameters returns typed values and can keep changed ones in the page address.
ka = 1.2 1/h, CL = 5 L/h, V = 50 L, Dose = 100 mg
import { defineParams, formatValue, withUnit } from '../../../lib/controls';import ParameterPanel from '../../../components/controls/ParameterPanel';import { useParameters } from '../../../components/controls/useParameters';
// At module scope. Every entry needs a unit; `control: 'number'` gives a number field.const schema = defineParams([ { name: 'ka', label: 'ka', unit: '1/h', min: 0.1, max: 5, default: 1.2, scale: 'log' }, { name: 'CL', label: 'CL', unit: 'L/h', min: 0.5, max: 50, default: 5, scale: 'log' }, { name: 'V', label: 'V', unit: 'L', min: 5, max: 200, default: 50, step: 1 }, { name: 'dose', label: 'Dose', unit: 'mg', min: 10, max: 1000, default: 100, step: 10, control: 'number', },]);
export default function ParameterPanelExample() { // urlSync keeps changed values in the address (?lab-CL=7.5); reset clears them. const { values, setValue, reset } = useParameters(schema, { urlSync: true, urlPrefix: 'lab-' });
return ( <div> <ParameterPanel schema={schema} values={values} onChange={setValue} onReset={reset} legend="Model parameters" /> <p className="param-readout"> {schema .map((p) => `${p.label} = ${withUnit(formatValue(values[p.name]), p.unit)}`) .join(', ')} </p> </div> );}Scrollytelling
A graphic that stays in view while the steps scroll past, redrawn for the step being read: here, repeated oral doses of 100 mg every 12 h.
Scrolly and Step
Steps are written in MDX with <Step>; the graphic is a function of the active step, supplied by a small island that wraps Scrolly.
Dose 1. The first 100 mg dose peaks at 1.60 mg/L at about 2.3 h. By 12 h the concentration has fallen to 0.66 mg/L, not to zero.
Dose 2. The second dose lands on what is left of the first. The curves add, so the peak rises to 2.13 mg/L and the trough at 24 h to 0.86 mg/L.
Dose 3. Each dose adds less than the one before, because less of the earlier doses remains. The peak is now 2.29 mg/L.
Dose 4. The peak is 2.34 mg/L and the trough 0.93 mg/L: hard to tell from the interval before.
Dose 5. After 48 h, about seven half-lives, each interval eliminates nearly a whole dose: peak 2.35 mg/L, trough 0.94 mg/L.
Steady state. The curve settles between a peak of 2.36 mg/L and a trough of 0.94 mg/L, the dashed lines.
import type { ReactNode } from 'react';import type { SpecBuilder } from '../../lib/charts';import PlotChart from '../charts/PlotChart';import Scrolly from './Scrolly';import { DEMO_REGIMEN, buildUpLabel, buildUpSpec } from './scrollyDemoData';
// Module scope: PlotChart redraws whenever the builder's identity changes.const spec: SpecBuilder<number> = (step, ctx) => buildUpSpec(step, ctx);
/** * Scrollytelling demo: a concentration–time curve that builds up dose by dose. The steps are * the children, written in the post with `<Step>`; there is one per dose, then one more that * adds the steady-state peak and trough. */export default function ScrollyDemo({ children }: { children?: ReactNode }) { return ( <Scrolly graphic={(active) => ( <PlotChart spec={spec} data={active} ariaLabel={buildUpLabel(active)}> Repeated oral doses of {DEMO_REGIMEN.dose} mg every {DEMO_REGIMEN.tau} h. Dotted vertical lines mark the doses given so far. </PlotChart> )} > {children} </Scrolly> );}import ScrollyDemo from './ScrollyDemo.tsx';
<ScrollyDemo client:visible> <Step>**Dose 1.** The first 100 mg dose peaks at 1.60 mg/L …</Step> <Step>**Dose 2.** The second dose lands on what is left of the first …</Step> <Step>**Dose 3.** Each dose adds less than the one before …</Step> <Step>**Dose 4.** …</Step> <Step>**Dose 5.** …</Step> <Step>**Steady state.** …</Step></ScrollyDemo>PK explorer
Live concentration–time curves from the PK engine, with sliders for the model's parameters. The view (parameters, axis and frozen curve) is kept in the page address, so it can be shared.
PKExplorer
A preset linear model (one to four compartments, IV or oral) with plain props, usable straight from MDX or the CMS snippet. Freeze a curve to compare against, switch the axis, read the exposure metrics.
View data
| Time (h) | Current (mg/L) |
|---|---|
| 0 | 0 |
| 1.5 | 2.029 |
| 3 | 1.552 |
| 4.5 | 1.072 |
| 6 | 0.8107 |
| 7.5 | 0.6799 |
| 9 | 0.6081 |
| 10.5 | 0.5608 |
| 12 | 0.5238 |
| 13.5 | 2.521 |
| 15 | 2.014 |
| 16.5 | 1.507 |
| 18 | 1.22 |
| 19.5 | 1.065 |
| 21 | 0.9709 |
| 22.5 | 0.9023 |
| 24 | 0.8452 |
| 25.5 | 2.823 |
| 27 | 2.299 |
| 28.5 | 1.775 |
| 30 | 1.473 |
| 31.5 | 1.303 |
| 33 | 1.194 |
| 34.5 | 1.113 |
| 36 | 1.043 |
| 37.5 | 3.01 |
| 39 | 2.474 |
| 40.5 | 1.94 |
| 42 | 1.628 |
| 43.5 | 1.449 |
| 45 | 1.332 |
| 46.5 | 1.242 |
| 48 | 1.165 |
| 49.5 | 3.124 |
| 51 | 2.582 |
| 52.5 | 2.042 |
| 54 | 1.724 |
| 55.5 | 1.539 |
| 57 | 1.417 |
| 58.5 | 1.322 |
| 60 | 1.241 |
| 61.5 | 3.195 |
| 63 | 2.649 |
| 64.5 | 2.105 |
| 66 | 1.783 |
| 67.5 | 1.595 |
| 69 | 1.469 |
| 70.5 | 1.372 |
| 72 | 1.287 |
| Metric | Current |
|---|---|
| Cmax (mg/L) | |
| Tmax (h) | |
| AUC0–72 (mg·h/L) | |
| AUC0–∞ (mg·h/L) | |
| Css,avg (mg/L) | |
| Vss (L) | |
| t½, λ₁ (h) | |
| Terminal t½, λ₂ (h) |
import PKExplorer from '../../../components/interactive/PKExplorer.tsx';
<PKExplorer client:visible model="2cmt-oral" params={{ CL: 4, V1: 20, Q: 10, V2: 60, ka: 0.8 }} regimen={{ amt: 100, ii: 12, addl: 5 }} window={{ min: 1, max: 3 }}> 100 mg every 12 h with a two-compartment model. Freeze a curve, then change a parameter to compare; the window is illustrative (1–3 mg/L).</PKExplorer>PKExplorer in macro-constants
Any preset in clearance and volume, micro-constants or macro-constants (A₁, λ₁, …), with a control that lets the reader switch; the values convert so the curve is unchanged. Here a three-compartment bolus on a log axis, with a half-life per phase and Vss.
View data
| Time (h) | Current (mg/L) |
|---|---|
| 0 | 10 |
| 2 | 1.005 |
| 4 | 0.6253 |
| 6 | 0.4383 |
| 8 | 0.3192 |
| 10 | 0.2427 |
| 12 | 0.1932 |
| 14 | 0.1608 |
| 16 | 0.1394 |
| 18 | 0.1249 |
| 20 | 0.1148 |
| 22 | 0.1076 |
| 24 | 0.1022 |
| 26 | 0.09795 |
| 28 | 0.09447 |
| 30 | 0.0915 |
| 32 | 0.08886 |
| 34 | 0.08646 |
| 36 | 0.08421 |
| 38 | 0.08209 |
| 40 | 0.08007 |
| 42 | 0.07812 |
| 44 | 0.07623 |
| 46 | 0.0744 |
| 48 | 0.07262 |
| 50 | 0.07089 |
| 52 | 0.0692 |
| 54 | 0.06755 |
| 56 | 0.06594 |
| 58 | 0.06438 |
| 60 | 0.06285 |
| 62 | 0.06135 |
| 64 | 0.05989 |
| 66 | 0.05847 |
| 68 | 0.05708 |
| 70 | 0.05572 |
| 72 | 0.0544 |
| 74 | 0.05311 |
| 76 | 0.05185 |
| 78 | 0.05061 |
| 80 | 0.04941 |
| 82 | 0.04824 |
| 84 | 0.04709 |
| 86 | 0.04597 |
| 88 | 0.04488 |
| 90 | 0.04381 |
| 92 | 0.04277 |
| 94 | 0.04176 |
| 96 | 0.04076 |
Coefficients A are for a dose of 100 mg; peripheral compartments are numbered fastest first.
| Metric | Current |
|---|---|
| Cmax (mg/L) | |
| Tmax (h) | |
| AUC0–96 (mg·h/L) | |
| AUC0–∞ (mg·h/L) | |
| Vss (L) | |
| t½, λ₁ (h) | |
| t½, λ₂ (h) | |
| Terminal t½, λ₃ (h) |
import PKExplorer from '../../../components/interactive/PKExplorer.tsx';
<PKExplorer client:visible model="3cmt-iv" parameterization="macro" regimen={{ amt: 100 }} scale="log" tEnd={96} urlPrefix="pk3-"> A three-compartment bolus written as three exponential phases. Switch to micro-constants or clearance and volume: the curve stays the same.</PKExplorer>PKExplorer with a custom model
A model with no closed form, written in TypeScript in a small island: a parameter schema and a simulate function (here the ODE engine with Michaelis–Menten elimination).
View data
| Time (h) | Current (mg/L) |
|---|---|
| 0 | 10 |
| 1 | 9.154 |
| 2 | 8.331 |
| 3 | 7.533 |
| 4 | 6.764 |
| 5 | 6.026 |
| 6 | 5.323 |
| 7 | 4.657 |
| 8 | 4.033 |
| 9 | 3.453 |
| 10 | 2.922 |
| 11 | 2.441 |
| 12 | 2.013 |
| 13 | 1.638 |
| 14 | 1.315 |
| 15 | 1.043 |
| 16 | 0.8173 |
| 17 | 0.6339 |
| 18 | 0.4871 |
| 19 | 0.3715 |
| 20 | 0.2815 |
| 21 | 0.2122 |
| 22 | 0.1593 |
| 23 | 0.1192 |
| 24 | 10.09 |
| 25 | 9.24 |
| 26 | 8.415 |
| 27 | 7.614 |
| 28 | 6.842 |
| 29 | 6.101 |
| 30 | 5.394 |
| 31 | 4.724 |
| 32 | 4.095 |
| 33 | 3.511 |
| 34 | 2.974 |
| 35 | 2.488 |
| 36 | 2.055 |
| 37 | 1.674 |
| 38 | 1.346 |
| 39 | 1.069 |
| 40 | 0.8386 |
| 41 | 0.6511 |
| 42 | 0.5008 |
| 43 | 0.3822 |
| 44 | 0.2897 |
| 45 | 0.2185 |
| 46 | 0.1641 |
| 47 | 0.1228 |
| 48 | 0.0917 |
| Metric | Current |
|---|---|
| Cmax (mg/L) | |
| Tmax (h) | |
| AUC0–48 (mg·h/L) | |
| AUC0–∞ (mg·h/L) | |
| Vss (L) | |
| t½ (h) |
import PKExplorer from '../../../components/interactive/PKExplorer';import { defineParams } from '../../../lib/controls';import { michaelisMenten, solveOde } from '../../../lib/pk';import type { ExplorerModel } from '../../../lib/pk-explorer';
// A custom model for <PKExplorer>: a schema for its sliders and a simulate function. Here,// Michaelis–Menten elimination from one compartment (V = 50 L), solved by the ODE engine.// A slider named `dose` sets the amount of every dose. Illustrative values.const schema = defineParams([ { name: 'vmax', label: 'Vmax', unit: 'mg/h', min: 5, max: 500, default: 60, scale: 'log' }, { name: 'km', label: 'Km', unit: 'mg/L', min: 0.1, max: 50, default: 4, scale: 'log' }, { name: 'dose', label: 'Dose', unit: 'mg', min: 10, max: 2000, default: 500, scale: 'log' },]);
const saturable: ExplorerModel = { schema, route: 'bolus', simulate: (values, doses, times) => solveOde(michaelisMenten, doses, times, { params: { vmax: values.vmax, km: values.km }, }).output('concentration'), // No terminal half-life or exact AUC∞ for a nonlinear model: the table shows "—".};
export default function PkCustomExample() { return ( <PKExplorer model={saturable} regimen={{ amt: 500, ii: 24, addl: 1 }} scale="log" urlPrefix="lab-mm-" ariaLabel="Concentration against time after two 500 mg IV bolus doses 24 h apart, with Michaelis–Menten elimination." > Saturable elimination. Well above Km the concentration falls at a nearly constant rate (zero order, Vmax/V), so the curve bends downwards on the log axis; well below Km the decline is exponential, a straight line. </PKExplorer> );}Population explorer
A simulated population around a linear PK model: sliders for the typical parameters and their between-subject variability, and the median with a prediction-interval band. The simulation runs in a Web Worker, which loads only when the explorer comes into view.
PopulationExplorer
1,000 subjects with log-normal IIV (as % CV) and residual error, simulated off the main thread while a slider moves. Resample draws a new population; the seed is kept in the page address with the sliders.
View data
| Time (h) | Typical subject (mg/L) |
|---|---|
| 0 | 0 |
| 1.75 | 1.479 |
| 3.5 | 1.499 |
| 5.25 | 1.303 |
| 7 | 1.101 |
| 8.75 | 0.926 |
| 10.5 | 0.7776 |
| 12.25 | 1.089 |
| 14 | 2.067 |
| 15.75 | 1.935 |
| 17.5 | 1.659 |
| 19.25 | 1.399 |
| 21 | 1.175 |
| 22.75 | 0.9868 |
| 24.5 | 1.594 |
| 26.25 | 2.236 |
| 28 | 2.033 |
| 29.75 | 1.733 |
| 31.5 | 1.46 |
| 33.25 | 1.226 |
| 35 | 1.03 |
| 36.75 | 1.876 |
| 38.5 | 2.274 |
| 40.25 | 2.03 |
| 42 | 1.725 |
| 43.75 | 1.452 |
| 45.5 | 1.22 |
| 47.25 | 1.024 |
| 49 | 2.053 |
| 50.75 | 2.267 |
| 52.5 | 1.998 |
| 54.25 | 1.694 |
| 56 | 1.425 |
| 57.75 | 1.196 |
| 59.5 | 1.004 |
| 61.25 | 2.168 |
| 63 | 2.243 |
| 64.75 | 1.957 |
| 66.5 | 1.656 |
| 68.25 | 1.392 |
| 70 | 1.169 |
| 71.75 | 0.9813 |
| 73.5 | 2.241 |
| 75.25 | 2.211 |
| 77 | 1.913 |
| 78.75 | 1.616 |
| 80.5 | 1.358 |
| 82.25 | 1.141 |
| 84 | 0.9576 |
import PopulationExplorer from '../../../components/interactive/PopulationExplorer.tsx';
<PopulationExplorer client:visible model="1cmt-oral" params={{ CL: 5, V: 50, ka: 1 }} iiv={{ CL: 30, V: 20, ka: 40 }} residual={{ prop: 10 }} regimen={{ amt: 100, ii: 12, addl: 6 }} window={{ min: 1, max: 3 }}> 1,000 simulated subjects on 100 mg every 12 h: the median and the 90% prediction interval. IIV and residual error are illustrative.</PopulationExplorer>