Scripts to rerun the checks
Each worked example says it recomputed something. These are the scripts, so you can run them yourself.
Get the public CDISC pilot files from the CDISC pilot repository, put them in a folder, and pass that folder to the script as its first argument. Each script has a header that says what it reproduces, which packages it needs and what output to expect, and each folder has the saved expected output. Two scripts stop with an error on purpose and one computes the wrong comparison on purpose, to show what the lazy version does. They are labelled.
The code is under the MIT licence, with no warranty. The pilot data belongs to CDISC and is credited to it. Tested with R 4.6.1. These are teaching and checking scripts, not validated software.
Prepare the response plan for an agency request to explain how to replicate an analysis from ADaM
- replicate_14-3-01.R: Follows the AI-written replication plan step by step and compares the result with CSR Table 14-3.01 (ADAS-Cog(11) total, Week 24, efficacy population): 37 cells including the dose-response p-value and the three treatment differences. Expected output.
- run_bad.R: Runs the steps of the vague-input plan literally and shows where it fails (PARAMCD ADAS13, REGION and FASFL do not exist in the pilot data; mmrm is not installed). Expected output.
Turn ADaM spec rows into draft R code with a test plan, for run-and-compare checking
- run_bad.R: The AI-written code for the spec rows, kept exactly as the model wrote it. It assumes data frames ae and adsl already exist, so it is sourced by harness_bad.R and is not meant to be run alone.
- harness_bad.R: Reads sdtm_ae.xpt and adam_adsl.xpt, runs run_bad.R, and compares the result with the delivered ADAE (adam_adae.xpt) variable by variable: 14 non-key variables, TRTEMFL mismatches, ASTDY and AENDY offsets. Expected output.
Draft the written summary of closed-session safety tables for the unblinded statistician
- dsmb_inputs.R: Builds the safety table that was pasted into the prompt: TEAE counts by arm, serious and severe TEAEs, related TEAEs, AE discontinuations, deaths, common preferred terms, and the serious AE and death listings. Expected output.
- recompute.R: Independent recomputation of every number in the AI-written summary (good_output.txt), written separately from dsmb_inputs.R, plus cross-checks against the CSR. Expected output.
- good_output.txt: Example input for the scripts in this folder (text or table the check reads, taken from the worked-example page).
Translate a SAS program to R and prove the numbers match
- run.R: The R translation of adam_adae.sas exactly as the model first wrote it. It stops with the error object 'AEDECOD' not found (a name clash with a helper called .d). Expected output.
- run_fixed.R: The same translation with the one-line fix (helper renamed to aedecod_trim), then a cell-by-cell comparison with the SAS-produced adam_adae.xpt. Expect zero differing variables. Expected output.
- check_extra.R: Extra checks run on top of run_fixed.R: ADUR against ADURN, flag counts, a negative control with planted errors, and the behaviour of as.Date on partial dates. Expected output.
- check_bad_asdate.R: Shows what as.Date(AESTDTC) from the weaker answer does on the real data (errors or NA on year-only and month-only dates). Expected output.
- run_bad_filenames.R: The weaker answer's code with the file names corrected. It still stops with a dplyr error (column TRTA is not found), which is the point: the code was never run against the real files. Expected output.
Check SAS or R programs for reviewer-friendliness before a submission package
- checks.R: Evidence checks C0 to C10 for the line-cited review of adam_adae.sas: ADUR versus ADURN, partial dates, the missing upper bound on TRTEMFL, the CQ01NAM rule, first-occurrence ties, and more. Expected output.
- cq01_list.R: Helper: the preferred-term list printed in CSR Table 12-2 (p. 33), used by checks.R and cq01_vs_csr.R.
- cq01_vs_csr.R: Compares the terms flagged DERMATOLOGIC EVENTS (CQ01NAM) in adam_adae.xpt with the list in CSR Table 12-2. Expected output.
- codes.R: Counts blank or missing values in dictionary and action-taken variables of ADAE and says whether each exists in SDTM AE. Expected output.
- submission-program-readiness-review_quotecheck.py: Checks that each backtick-quoted SAS fragment and each line-number citation in the model's review is really in adam_adae.sas. Expected output.
- model_output.txt: Example input for the scripts in this folder (text or table the check reads, taken from the worked-example page).
Convert shell text into draft analysis-results metadata rows (CDISC ARS), checked against the schema
- check_bindings.R: Checks that the datasets and variables bound in the AI-drafted ARS JSON exist in the pilot data, and counts the records each Week 24 data subset selects. Expected output.
- tfl-shell-to-ars-metadata_validate.py: Validates the AI-drafted ARS JSON against the CDISC ARS JSON schema, plus a strict root-key pass and a dangling-id check. Expected output.
- lazy_run_output.txt: Example input for the scripts in this folder (text or table the check reads, taken from the worked-example page).
- run_A_output.txt: Example input for the scripts in this folder (text or table the check reads, taken from the worked-example page).
- run_B_output_with_schema_extract.txt: Example input for the scripts in this folder (text or table the check reads, taken from the worked-example page).
Draft R practice exercises for SAS-fluent staff tied to team tasks
- ex1_solution_as_written.R: Exercise 1 solution as written: key and date-format checks on SDTM AE, ADSL and ADAE. Expected output.
- ex2_solution_as_written.R: Exercise 2 solution as written: derive ASTDT, AENDT and ADUR and compare with ADAE. Expected output.
- ex3_solution_as_written.R: Exercise 3 solution as written: merge with ADSL, impute partial start dates, derive ASTDY, AENDY and TRTEMFL, and compare with ADAE. Expected output.
- ex4_solution_as_written.R: Exercise 4 solution as written: serious TEAE counts by SOC and preferred term, checked against AOCC04FL. Expected output.
- ex5_solution_as_written.R: Exercise 5 solution as written: Fisher exact tests for serious TEAEs. It filters TRTAN to 1 and 2, but the data use 54 and 81, so the high and low dose comparisons are wrong. Expected output.
- ex5_fixed_TRTAN_54_81.R: Exercise 5 with TRTAN codes 54 and 81 in place of 1 and 2. Only the codes change. Expected output.
- ex6_solution_as_written.R: Exercise 6 solution as written: CQ01NAM and the AOCC flags rebuilt with a flag_first function and compared with ADAE. Expected output.
- recompute_reference.R: Reference counts for the exercise answers: safety denominators, TEAE and serious TEAE subjects and events by arm (CSR Tables 14-5.01 and 14-5.02), Fisher p-values with the right TRTAN codes. Expected output.
- bad_run_check.R: Runs the weaker answer's Exercise 5 and Exercise 7 code on the pilot files to show the errors (TRT01A is not in ADAE; TRT01P is not in ADTTE). Expected output.
- bad_run_data_facts.R: Facts about the pilot data that the weaker answer got wrong: ADTTE parameters and censoring, variable names, AESEV values, arm names. Also reports whether the pharmaverseadam package is installed on the machine running it. Expected output.
Extract biostatistics and programming requirements from an RFP into a scope grid
- rfp-biostat-scope-extraction_quotecheck.py: Checks that every quote in the extraction grid is an exact text match on the cited page of the public NIAID Statement of Work PDF, and counts requirement sentences (shall / must / will provide). Expected output.
- excerpt.txt: Example input for the scripts in this folder (text or table the check reads, taken from the worked-example page).
- grid_quotes.json: Example input for the scripts in this folder (text or table the check reads, taken from the worked-example page).
Get one workflow a week
Unsubscribe anytime. Privacy.