43.7 Prep Studio: raw files to a NONMEM-ready dataset
What you will learn
- How a recipe turns raw files into a NONMEM-ready dataset.
- The step families and the checks that catch problems before modelling.
- How the recipe makes the build repeatable when data are refreshed.
The recipe is the product
Raw dosing, concentration and demographic files go in; a NONMEM-ready dataset comes out, together with a recipe that records every step. The dataset can always be rebuilt from the raw files, reviewed line by line, and rebuilt again when the data are refreshed. That is the central idea: the build is code you can read, not an afternoon of clicks nobody can reproduce.
Prep Studio works in the browser. It does not need the engine to build a dataset; where the engine is available, the Check page can also run qc-data on the finished dataset as a second opinion.
The workflow
| Page | What you do |
|---|---|
| Files | Add the raw files (CSV, tab, semicolon or space separated, with a header). The separator is detected. Each file shows a column profile and opens in the table viewer. Adding files never starts a computation. |
| Recipe | Build the list of steps. Press Build and the recipe runs in a background worker with a progress bar and Stop, so a very large dataset never freezes the page. After a change the page says the result is out of date. Run to step N builds only the first N steps. |
| Check | Built-in NONMEM dataset checks on the final table, with the first records of every finding listed by file line. Optionally run nlmx qc-data. |
| Export | The dataset, the $DATA and $INPUT lines, the derivation report, the data dictionary and the recipe. |
| Reference | The expression language, steps, BLQ methods, covariate formulas and the NONMEM data rules. |
Steps, in seven families
- Shape: start from a file, keep, drop or move columns, rename, filter rows, sort, remove duplicates.
- Combine: add columns from another file (a join, with control over unmatched keys and repeated keys) or add rows (a stack, with column mapping and fixed values such as
EVID = 1). Unmatched keys are listed with the share of rows concerned. - Derive: calculate a column from an expression, convert text to numbers, recode values, group a number into categories, number subjects, check plausible limits.
- Adjust: remove or keep listed rows found again by key columns, make manual value changes, convert units (about 40 presets such as kg and lb, mg/dL and µmol/L), clean and replace values.
- Time: time since first dose from dates in many styles (ambiguous dates are refused until you choose the order), and time after the last dose.
- NONMEM:
EVID,MDVandCMT; BLQ methods M1 and M3 to M7; collapsing repeated doses toADDLandII. - Covariates: fill missing values (last observation carried forward, mean, median, most common, fixed) with an
_IMPflag, and compute BMI, BSA (Mosteller, Du Bois), ideal and lean body mass, Cockcroft-Gault, and eGFR (CKD-EPI 2021, CKD-EPI 2009, MDRD, bedside Schwartz).
Steps can be moved, copied, turned off (kept but skipped) and deleted. Turning a step off is the quickest way to see what it did. Each step records what it did (row counts, notes) and what it found (warnings).
A safe expression language
Filters and calculated columns use a small language with no access to anything but the columns:
WT / (HT/100)^2 arithmetic
if(SEX == 'F', 1, 0) conditions and logic
coalesce(WT, 70) isna round log exp sqrt min max
TIME - first(TIME) per-subject functions with Group by ID:
lag lead first last cumsum rownum count locf nocb ...
A mistake, such as an unknown column or an unbalanced bracket, is reported with its position and a suggestion before the step runs.
BLQ methods
| Method | Result |
|---|---|
| M1 | BLQ records are discarded. |
| M3 | Kept with DV = LLOQ, CENS = 1 and an LLOQ column; likelihood-based. |
| M4 | As M3, with the positivity constraint set in the control stream. |
| M5 | DV = LLOQ / 2 for every BLQ record. |
| M6 | In a subject, the first of consecutive BLQ records gets LLOQ / 2; later ones are discarded. |
| M7 | DV = 0. |
The step adds a BLQ flag and warns when more than 20% of observations are BLQ.
Built-in checks
Every finding names the records concerned and lists the first eight by file line. The checks cover invalid column names, missing ID, TIME or DV, text in numeric columns, missing IDs or times, subjects split across blocks, time going backwards, invalid EVID or MDV, observations without concentrations, doses without amounts, subjects with no doses or observations, invalid CMT, RATE, ADDL, II, negative or zero concentrations, concentrations below the LLOQ still in the fit, duplicate rows, and missing or changing covariates (NONMEM reads an empty covariate as 0). The result is Ready when there is no error.
The tools panel and the recipe file
A panel on the right of Files and Recipe handles real-data fixes without hand-writing a step: filter rows, remove or rename columns, fix units, clean values, calculate a column, tick rows to remove or keep, and rows found by key columns. A tool can act on the final dataset, on the table after a selected step, or on one file only ("the weights in study B are in lb").
The recipe file is plain JSON: it can be read, compared with a text diff and kept under version control. It stores a fingerprint of each source file, so a replay says when a file has changed. Unknown steps are refused, not skipped, and a recipe from a newer version is refused with a clear message.
Export and replay
The export zip holds the dataset, a control stream stub ($DATA and $INPUT, with text columns written as =DROP), a one-page derivation report (source files, each step with rows before and after, notes, warnings and checks), the data dictionary, a figure of observations over time, the recipe, the raw files and a checksum file. A replay on refreshed source files rebuilds the dataset with the same recipe.
Limits
Tables are held in memory in the browser; a few hundred thousand rows work comfortably, millions will be slow. Only delimited text files are read, so convert Excel and SAS files to CSV first. Dates are read as clock time with no time zone; a time zone is never guessed. There is no undo other than turning a step off or deleting it, because the recipe is the history.
Navigation
See the previous page, next page, and the chapter overview.