Review ask

As a clinical trial statistician or programmer, challenge anything in this benchmark: describe a problem in Comments, or propose a fix with the Edit button on any source file.

  1. Task: Would a real study need this derivation, specified this way? Does it follow CDISC ADaM: variable names, controlled terms, record structure? Flag any rule that is ambiguous or that a sponsor would handle differently.
  2. Inputs: Do they look like data collected in a real trial, and do they include the situations you would expect to meet in one?
  3. Expected output: Would independent QC programming reproduce every value from these inputs and rules?

The other tabs beside Comments are background for assessment, not under review.

Summary

Lifecycle: reviewedEditUnder review
What this benchmark means
README.md

Goal: add one new record per subject (USUBJID) and analysis visit (AVISIT) in study CATH-01 for each of three ECG measures: the Bazett-corrected QT interval (QTCBR), the Fridericia-corrected QT interval (QTCFR), and the RR duration recomputed from heart rate (RRR).

Input: collected electrocardiogram records with parameter codes QT (QT interval duration), RR (RR interval duration), and HR (heart rate), each carrying its label (PARAM), result (AVAL), and unit (AVALU). QT and RR results are in milliseconds (ms or msec); heart rate is in beats per minute (beats/min).

Variables:

  • PARAMCD: QTCBR, QTCFR, or RRR on the new records; QT, RR, or HR on the collected ones. The input must not already contain QTCBR, QTCFR, or RRR.
  • PARAM: "QTcB - Bazett's Correction Formula Rederived (ms)", "QTcF - Fridericia's Correction Formula Rederived (ms)", or "RR Duration Rederived (ms)" on the new records.
  • AVISIT: the analysis visit the record belongs to, for example BASELINE or WEEK 4.
  • AVAL: QT / SQRT(RR / 1000) for QTCBR, QT / POWER(RR / 1000, 1 / 3) for QTCFR, and 60000 divided by the heart rate for RRR; for example, a heart rate of 60 gives 1000.
  • AVALU: ms on the new records.

Note: a QTc record is added only when both the QT and the RR results are present at that visit; an RRR record is added only when the heart rate is present and not zero. Collected QT and RR records in a unit other than ms or msec fail the run, and each visit is expected to carry at most one record per parameter code.

Inputs

Under review
1 source file

input/adeg.csv

Edit
29 rows
input/adeg.csv
STUDYIDUSUBJIDPARAMCDPARAMAVISITAVALAVALU
CATH-01QTQT DurationBASELINE350ms
CATH-01RRRR DurationBASELINE1000ms
CATH-01HRHeart RateBASELINE60beats/min
CATH-01QTQT DurationWEEK 4362ms
CATH-01RRRR DurationWEEK 4950ms
CATH-01HRHeart RateWEEK 463beats/min
CATH-01QTQT DurationBASELINE400msec
CATH-01RRRR DurationBASELINE512msec
CATH-01HRHeart RateBASELINE70beats/min
CATH-01QTQT DurationBASELINE—ms
CATH-01RRRR DurationBASELINE920ms
CATH-01HRHeart RateBASELINE72beats/min
CATH-01QTQT DurationBASELINE388ms
CATH-01RRRR DurationBASELINE—ms
CATH-01HRHeart RateBASELINE60beats/min
CATH-01QTQT DurationBASELINE410ms
CATH-01RRRR DurationBASELINE880ms
CATH-01HRHeart RateBASELINE0beats/min
CATH-01QTQT DurationBASELINE375ms
CATH-01QTQT DurationBASELINE340ms
CATH-01RRRR DurationBASELINE1100ms
CATH-01HRHeart RateBASELINE1beats/min
CATH-01HRHeart RateBASELINE55beats/min
CATH-01QTQT DurationBASELINE395ms
CATH-01RRRR DurationBASELINE980ms
CATH-01HRHeart RateBASELINE—beats/min
CATH-01QTQT DurationBASELINE600ms
CATH-01RRRR DurationBASELINE1500ms
CATH-01HRHeart RateBASELINE40beats/min

Expected output

Under review
51 expected rows

expected/adeg.csv

Edit
51 rows
expected/adeg.csv
STUDYIDUSUBJIDPARAMCDPARAMAVISITAVALAVALU
CATH-01QTQT DurationBASELINE350ms
CATH-01RRRR DurationBASELINE1000ms
CATH-01HRHeart RateBASELINE60beats/min
CATH-01QTQT DurationWEEK 4362ms
CATH-01RRRR DurationWEEK 4950ms
CATH-01HRHeart RateWEEK 463beats/min
CATH-01QTQT DurationBASELINE400msec
CATH-01RRRR DurationBASELINE512msec
CATH-01HRHeart RateBASELINE70beats/min
CATH-01QTQT DurationBASELINE—ms
CATH-01RRRR DurationBASELINE920ms
CATH-01HRHeart RateBASELINE72beats/min
CATH-01QTQT DurationBASELINE388ms
CATH-01RRRR DurationBASELINE—ms
CATH-01HRHeart RateBASELINE60beats/min
CATH-01QTQT DurationBASELINE410ms
CATH-01RRRR DurationBASELINE880ms
CATH-01HRHeart RateBASELINE0beats/min
CATH-01QTQT DurationBASELINE375ms
CATH-01QTQT DurationBASELINE340ms
CATH-01RRRR DurationBASELINE1100ms
CATH-01HRHeart RateBASELINE1beats/min
CATH-01HRHeart RateBASELINE55beats/min
CATH-01QTQT DurationBASELINE395ms
CATH-01RRRR DurationBASELINE980ms
CATH-01HRHeart RateBASELINE—beats/min
CATH-01QTQT DurationBASELINE600ms
CATH-01RRRR DurationBASELINE1500ms
CATH-01HRHeart RateBASELINE40beats/min
CATH-01QTCBRQTcB - Bazett's Correction Formula Rederived (ms)BASELINE350ms
CATH-01QTCBRQTcB - Bazett's Correction Formula Rederived (ms)WEEK 4371.4041634548258ms
CATH-01QTCBRQTcB - Bazett's Correction Formula Rederived (ms)BASELINE559.0169943749474ms
CATH-01QTCBRQTcB - Bazett's Correction Formula Rederived (ms)BASELINE437.0614685290014ms
CATH-01QTCBRQTcB - Bazett's Correction Formula Rederived (ms)BASELINE324.17728034350137ms
CATH-01QTCBRQTcB - Bazett's Correction Formula Rederived (ms)BASELINE399.01025509812325ms
CATH-01QTCBRQTcB - Bazett's Correction Formula Rederived (ms)BASELINE489.89794855663564ms
CATH-01QTCFRQTcF - Fridericia's Correction Formula Rederived (ms)BASELINE350ms
CATH-01QTCFRQTcF - Fridericia's Correction Formula Rederived (ms)WEEK 4368.2426060851786ms
CATH-01QTCFRQTcF - Fridericia's Correction Formula Rederived (ms)BASELINE500ms
CATH-01QTCFRQTcF - Fridericia's Correction Formula Rederived (ms)BASELINE427.8481245967625ms
CATH-01QTCFRQTcF - Fridericia's Correction Formula Rederived (ms)BASELINE329.3679640914978ms
CATH-01QTCFRQTcF - Fridericia's Correction Formula Rederived (ms)BASELINE397.6689998808046ms
CATH-01QTCFRQTcF - Fridericia's Correction Formula Rederived (ms)BASELINE524.1482788417793ms
CATH-01RRRRR Duration Rederived (ms)BASELINE1000ms
CATH-01RRRRR Duration Rederived (ms)WEEK 4952.3809523809524ms
CATH-01RRRRR Duration Rederived (ms)BASELINE857.1428571428571ms
CATH-01RRRRR Duration Rederived (ms)BASELINE833.3333333333334ms
CATH-01RRRRR Duration Rederived (ms)BASELINE1000ms
CATH-01RRRRR Duration Rederived (ms)BASELINE60000ms
CATH-01RRRRR Duration Rederived (ms)BASELINE1090.909090909091ms
CATH-01RRRRR Duration Rederived (ms)BASELINE1500ms
Shaded columns are derived— = missing value

Comments and assessment materials

Comments

Signed in with GitHub; saved in repository Discussions

Mapping spec

Generated from the benchmark YAML; do not edit by hand

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADEGSTUDYIDStudy IdentifiercharacterCopy value from ADEG_RAW.STUDYID.Predecessor
ADEGUSUBJIDUnique Subject IdentifiercharacterCopy value from ADEG_RAW.USUBJID.Predecessor
ADEGPARAMCDParameter CodecharacterSet per constructed row; see the Row construction sheet.Derived
ADEGPARAMParametercharacterSet per constructed row; see the Row construction sheet.Derived
ADEGAVISITAnalysis VisitcharacterCopy value from ADEG_RAW.AVISIT.Predecessor
ADEGAVALAnalysis ValuenumericSet per constructed row; see the Row construction sheet.Derived
ADEGAVALUAnalysis Value UnitcharacterSet per constructed row; see the Row construction sheet.Derived
TemplateInclude whenPARAMCDPARAMQTVALRRVALAVALAVALU
collectedCopy ADEG_RAW.PARAMCDCopy ADEG_RAW.PARAMConstant "None"Constant "None"Copy ADEG_RAW.AVALCopy ADEG_RAW.AVALU
qtc_bazettQTVAL IS NOT NULL AND RRVAL IS NOT NULLConstant "QTCBR"Constant "QTcB - Bazett's Correction Formula Rederived (ms)"Aggregate ONLY(ADEG_RAW.AVAL) over records matching on the shared output keys, where ADEG_RAW.PARAMCD = 'QT'Aggregate ONLY(ADEG_RAW.AVAL) over records matching on the shared output keys, where ADEG_RAW.PARAMCD = 'RR'Compute QTVAL / SQRT(RRVAL / 1000)Constant "ms"
qtc_fridericiaQTVAL IS NOT NULL AND RRVAL IS NOT NULLConstant "QTCFR"Constant "QTcF - Fridericia's Correction Formula Rederived (ms)"Aggregate ONLY(ADEG_RAW.AVAL) over records matching on the shared output keys, where ADEG_RAW.PARAMCD = 'QT'Aggregate ONLY(ADEG_RAW.AVAL) over records matching on the shared output keys, where ADEG_RAW.PARAMCD = 'RR'Compute QTVAL / POWER(RRVAL / 1000, 1 / 3)Constant "ms"
rr_rederivedADEG_RAW.PARAMCD = 'HR' AND ADEG_RAW.AVAL IS NOT NULL AND ADEG_RAW.AVAL <> 0Constant "RRR"Constant "RR Duration Rederived (ms)"Constant "None"Constant "None"Compute 60000 / NULLIF(ADEG_RAW.AVAL, 0)Constant "ms"
VersionDateAuthorDescriptionReviewerSign-off
1.32026-09-29yamaa docs buildShow study codelist names, external dictionaries, and ISO 8601 formats in variable rows; list the document's codelist values and metadata
1.22026-09-29yamaa docs buildClassify ADaM copies from a declared input as Predecessor and recodes as Derived, and SDTM recodes of locally derived columns as Derived
1.12026-09-29yamaa docs buildResolve lookups into the donor record they select, and give every derivation shape a plain-language rule instead of its raw YAML
1.0yamaa docs buildInitial generation from spec.yaml

Agent prompt

The request an agent receives with the input files; each tier states no more than the one above

prompts/adam-adeg-derived-intervals/full.md

Edit
25 lines

Following CDISC ADaM standards, use the provided ADEG_RAW dataset to create an ADEG dataset with one record per subject per parameter per analysis visit.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, AVALU

Keep every collected record unchanged: QT, RR, and HR with their labels, results, and units. Add one new record per subject and visit for each measure the visit supports:

  • "QTCBR" with PARAM "QTcB - Bazett's Correction Formula Rederived (ms)": the QT result divided by the square root of the RR result expressed in seconds;
  • "QTCFR" with PARAM "QTcF - Fridericia's Correction Formula Rederived (ms)": the QT result divided by the cube root of the RR result expressed in seconds;
  • "RRR" with PARAM "RR Duration Rederived (ms)": the RR duration in milliseconds matching the collected heart rate. A QTc record is added only when both the QT and the RR results are present at that visit. An RRR record is added only when the heart rate is present and not zero. New records use AVALU "ms", and their AVAL is not rounded. The input holds no QTCBR, QTCFR, or RRR records.

Read the source datasets from /app/input and save the completed dataset as /app/output/adeg.csv.

prompts/adam-adeg-derived-intervals/conventions.md

Edit
16 lines

Following CDISC ADaM standards, use the provided ADEG_RAW dataset to create an ADEG dataset with one record per subject per parameter per analysis visit.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, AVALU

New records use these parameters:

  • "QTCBR" with PARAM "QTcB - Bazett's Correction Formula Rederived (ms)";
  • "QTCFR" with PARAM "QTcF - Fridericia's Correction Formula Rederived (ms)";
  • "RRR" with PARAM "RR Duration Rederived (ms)". The AVAL of a new record is not rounded.

Read the source datasets from /app/input and save the completed dataset as /app/output/adeg.csv.

prompts/adam-adeg-derived-intervals/brief.md

Edit
9 lines

Following CDISC ADaM standards, use the provided ADEG_RAW dataset to create an ADEG dataset with one record per subject per parameter per analysis visit.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, AVALU

Read the source datasets from /app/input and save the completed dataset as /app/output/adeg.csv.

yamaa code

Runs the yamaa specification; its result must match the expected output

run.R

Edit
4 lines
library(yamaa)adeg <- yamaa_domain("spec.yaml")$outputadeg

run.py

Edit
4 lines
import yamaaadeg = yamaa.yamaa_domain("spec.yaml").outputadeg

Solution without yamaa

Written from the full prompt and the inputs alone; CI checks it reproduces the expected output

solutions/adam-adeg-derived-intervals/result.R

Edit
67 lines
# Reference solution for the yamaa benchmark adam-adeg-derived-intervals (R track).## Written from the benchmark's full prompt and its inputs alone, as an agent# would write it. Harbor's oracle agent runs it to check that the prompt can# be solved and that the grader scores a correct answer 1.library(dplyr, warn.conflicts = FALSE)library(readr)library(tidyr)adeg <- read_csv(  "/app/input/adeg.csv",  col_types = cols(AVAL = col_double(), .default = col_character()))wide <- adeg |>  select(STUDYID, USUBJID, AVISIT, PARAMCD, AVAL) |>  pivot_wider(names_from = PARAMCD, values_from = AVAL)# A QTc record needs both QT and RR; RR in seconds is RR in ms over 1000.qtc <- wide |>  filter(!is.na(QT), !is.na(RR)) |>  mutate(    RRSEC = RR / 1000,    QTCBR = QT / sqrt(RRSEC),    QTCFR = QT / (RRSEC^(1 / 3))  )qtcbr <- qtc |>  transmute(    STUDYID, USUBJID, AVISIT,    PARAMCD = "QTCBR",    PARAM = "QTcB - Bazett's Correction Formula Rederived (ms)",    AVAL = QTCBR,    AVALU = "ms"  )qtcfr <- qtc |>  transmute(    STUDYID, USUBJID, AVISIT,    PARAMCD = "QTCFR",    PARAM = "QTcF - Fridericia's Correction Formula Rederived (ms)",    AVAL = QTCFR,    AVALU = "ms"  )# An RRR record needs a present, nonzero heart rate.rrr <- wide |>  filter(!is.na(HR), HR != 0) |>  transmute(    STUDYID, USUBJID, AVISIT,    PARAMCD = "RRR",    PARAM = "RR Duration Rederived (ms)",    AVAL = 60000 / HR,    AVALU = "ms"  )adeg_out <- bind_rows(  adeg |> select(STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, AVALU),  qtcbr,  qtcfr,  rrr) |>  select(STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, AVALU)dir.create("/app/output", showWarnings = FALSE)write_csv(adeg_out, "/app/output/adeg.csv", na = "")

solutions/adam-adeg-derived-intervals/result.py

Edit
102 lines
# Reference solution for the yamaa benchmark adam-adeg-derived-intervals (Python track).## Written from the benchmark's full prompt and its inputs alone, as an agent# would write it. Harbor's oracle agent runs it to check that the prompt can# be solved and that the grader scores a correct answer 1.import mathfrom pathlib import Pathimport polars as pldef format_number(value: float | None) -> str | None:    if value is None or not math.isfinite(value):        return None    if float(value).is_integer():        return str(int(value))    return repr(float(value))base = pl.read_csv("/app/input/adeg.csv", infer_schema=False)numeric = base.with_columns(AVALNUM=pl.col("AVAL").cast(pl.Float64, strict=False))wide = numeric.group_by(["STUDYID", "USUBJID", "AVISIT"]).agg(    QT=pl.col("AVALNUM").filter(pl.col("PARAMCD") == "QT").first(),    RR=pl.col("AVALNUM").filter(pl.col("PARAMCD") == "RR").first(),    HR=pl.col("AVALNUM").filter(pl.col("PARAMCD") == "HR").first(),)collected = base.select(    "STUDYID", "USUBJID", "PARAMCD", "PARAM", "AVISIT", "AVAL", "AVALU")new_rows: list[dict] = []for record in wide.to_dicts():    studyid, usubjid, avisit = record["STUDYID"], record["USUBJID"], record["AVISIT"]    qt, rr, hr = record["QT"], record["RR"], record["HR"]    # A QTc record needs both QT and RR; RR in seconds is RR in ms over 1000.    if qt is not None and rr is not None:        rr_sec = rr / 1000        new_rows.append(            {                "STUDYID": studyid,                "USUBJID": usubjid,                "PARAMCD": "QTCBR",                "PARAM": "QTcB - Bazett's Correction Formula Rederived (ms)",                "AVISIT": avisit,                "AVAL": format_number(qt / math.sqrt(rr_sec)),                "AVALU": "ms",            }        )    if qt is not None and rr is not None:        rr_sec = rr / 1000        new_rows.append(            {                "STUDYID": studyid,                "USUBJID": usubjid,                "PARAMCD": "QTCFR",                "PARAM": "QTcF - Fridericia's Correction Formula Rederived (ms)",                "AVISIT": avisit,                "AVAL": format_number(qt / (rr_sec ** (1 / 3))),                "AVALU": "ms",            }        )    # An RRR record needs a present, nonzero heart rate.    if hr is not None and hr != 0:        new_rows.append(            {                "STUDYID": studyid,                "USUBJID": usubjid,                "PARAMCD": "RRR",                "PARAM": "RR Duration Rederived (ms)",                "AVISIT": avisit,                "AVAL": format_number(60000 / hr),                "AVALU": "ms",            }        )# Collected rows first, then QTCBR, QTCFR, and RRR per visit.order = {"QTCBR": 0, "QTCFR": 1, "RRR": 2}new_rows.sort(    key=lambda r: (order[r["PARAMCD"]], r["USUBJID"], r["AVISIT"]))derived = pl.DataFrame(    new_rows,    schema={        "STUDYID": pl.String,        "USUBJID": pl.String,        "PARAMCD": pl.String,        "PARAM": pl.String,        "AVISIT": pl.String,        "AVAL": pl.String,        "AVALU": pl.String,    },)adeg = pl.concat([collected, derived], how="diagonal").select(    "STUDYID", "USUBJID", "PARAMCD", "PARAM", "AVISIT", "AVAL", "AVALU")Path("/app/output").mkdir(exist_ok=True)adeg.write_csv("/app/output/adeg.csv")

solutions/adam-adeg-derived-intervals/result.sas

Edit
32 lines
/* opensas reference solution for the yamaa benchmark adam-adeg-derived-intervals.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data adeg;  length STUDYID USUBJID PARAMCD PARAM AVISIT AVALU $1024;  infile "/app/input/adeg.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. PARAMCD : $char1024. PARAM : $char1024. AVISIT : $char1024. AVAL AVALU : $char1024.;run;proc sql;  create table qt as select a.*,b.AVAL as RRVAL from adeg as a inner join adeg as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.AVISIT=b.AVISIT where a.PARAMCD='QT' and b.PARAMCD='RR' and not missing(a.AVAL) and not missing(b.AVAL);quit;data corrected;  length PARAMCD PARAM AVALU $1024;  set qt;  QTVAL=AVAL; AVALU='ms';  PARAMCD='QTCBR'; PARAM="QTcB - Bazett's Correction Formula Rederived (ms)"; AVAL=QTVAL/sqrt(RRVAL/1000); output;  PARAMCD='QTCFR'; PARAM="QTcF - Fridericia's Correction Formula Rederived (ms)"; AVAL=QTVAL/(RRVAL/1000)**(1/3); output;run;data heart;  length PARAMCD PARAM $1024;  set adeg;  if PARAMCD='HR' and not missing(AVAL) and AVAL ne 0;  AVAL=60000/AVAL; PARAMCD='RRR'; PARAM='RR Duration Rederived (ms)'; AVALU='ms';run;data result; set adeg corrected heart; run;proc sql;  create table final as select STUDYID, USUBJID, PARAMCD, PARAM, AVISIT, AVAL, AVALU from result;quit;proc export data=final outfile="/app/output/adeg.csv" dbms=csv replace; run;