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: rank severity and flag the worst-graded clinical event (CE) for each subject, adding ASEV, ASEVN, ATOXGRN and AOCCFL.

Input: clinical event records carrying sequence number (CESEQ), reported term (CETERM), collected severity (CESEV), and analysis start date (ASTDT).

Variables:

  • ASEV: analysis severity, carrying the collected severity (CESEV); blank when none was collected.
  • ASEVN: numeric rank of ASEV, 1 for MILD through 3 for SEVERE; blank when no severity was collected.
  • ATOXGRN: toxicity grade, equal to ASEVN, so a moderate event reads grade 2; blank when no severity was collected.
  • AOCCFL: Y on the graded event with the greatest ATOXGRN for the subject; blank otherwise. Ties break by earliest ASTDT, then lowest CESEQ, so at most one event per subject is flagged.

Note: an event without a grade can never be flagged, so a subject with no graded event has no flagged event. Grading stays separate from flagging so the grade means the same thing on every event while the flag answers a question about the subject.

Inputs

Under review
1 source file

input/ce.csv

Edit
11 rows
input/ce.csv
STUDYIDUSUBJIDCESEQCETERMCESEVASTDT
KN1891FEVERMILD2024-01-11
KN1892FATIGUESEVERE2024-01-12
KN1893CHILLSSEVERE2024-01-13
KN1894FATIGUESEVERE2024-01-12
KN1891FEVER—2024-02-06
KN1892FEVERMODERATE2024-02-06
KN1891REDNESSMODERATE2024-03-02
KN1891FEVER—2024-05-01
KN1892HEADACHE—2024-05-03
KN1891PAINMODERATE2024-04-10
KN1892HEADACHEMODERATE2024-04-05

Expected output

Under review
11 expected rows

expected/adce.csv

Edit
11 rows
expected/adce.csv
STUDYIDUSUBJIDCESEQCETERMASTDTASEVASEVNATOXGRNAOCCFL
KN1891FEVER2024-01-11MILD11—
KN1892FATIGUE2024-01-12SEVERE33Y
KN1893CHILLS2024-01-13SEVERE33—
KN1894FATIGUE2024-01-12SEVERE33—
KN1891FEVER2024-02-06————
KN1892FEVER2024-02-06MODERATE22Y
KN1891REDNESS2024-03-02MODERATE22Y
KN1891FEVER2024-05-01————
KN1892HEADACHE2024-05-03————
KN1891PAIN2024-04-10MODERATE22—
KN1892HEADACHE2024-04-05MODERATE22Y
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
ADCESTUDYIDStudy IdentifiercharacterCopy value from CE.STUDYID.Predecessor
ADCEUSUBJIDUnique Subject IdentifiercharacterCopy value from CE.USUBJID.Predecessor
ADCECESEQSequence NumbernumericCopy value from CE.CESEQ.Predecessor
ADCECETERMReported Term for Clinical EventcharacterCopy value from CE.CETERM.Predecessor
ADCEASTDTAnalysis Start DatenumericISO 8601Copy value from CE.ASTDT.Predecessor
ADCEASEVAnalysis Severity/IntensitycharacterMILD, MODERATE, SEVERECopy value from CE.CESEV.Predecessor
ADCEASEVNAnalysis Severity/Intensity (N)numeric1, 2, 3Recode ASEV: "MILD" → "1", "MODERATE" → "2", "SEVERE" → "3"; missing values stay missing; unlisted values are errors.Derived
ADCEATOXGRNAnalysis Toxicity Grade (N)numeric1, 2, 3Copy value from ASEVN.Derived
ADCEAOCCFLWorst Grade Occurrence FlagcharacterY"Y" when WGRSEQ = 1; blank otherwise.Derived
VariablePermitted values
ASEVMILD, MODERATE, SEVERE
ASEVN1, 2, 3
ATOXGRN1, 2, 3
AOCCFLY
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-adce-worst-toxicity/full.md

Edit
18 lines

Following CDISC ADaM standards, use the provided CE dataset to create an ADCE dataset with one record per clinical event.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, CESEQ, CETERM, ASTDT, ASEV, ASEVN, ATOXGRN, AOCCFL

ASEV is the collected severity, and has no value when none was collected. ASEVN is the numeric rank of ASEV: 1 for MILD through 3 for SEVERE, and has no value when none was collected. ATOXGRN is the toxicity grade, equal to ASEVN, so a moderate event reads grade 2; it has no value when none was collected. AOCCFL is Y on the graded event with the greatest ATOXGRN for the subject, and has no value otherwise. Ties break by earliest ASTDT, then lowest CESEQ, so at most one event per subject is flagged. An event without a grade can never be flagged, so a subject with no graded event has no flagged event.

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

prompts/adam-adce-worst-toxicity/conventions.md

Edit
12 lines

Following CDISC ADaM standards, use the provided CE dataset to create an ADCE dataset with one record per clinical event.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, CESEQ, CETERM, ASTDT, ASEV, ASEVN, ATOXGRN, AOCCFL

ASEVN is the numeric rank of ASEV: 1 for MILD through 3 for SEVERE. ATOXGRN is the toxicity grade, equal to ASEVN, so a moderate event reads grade 2. AOCCFL is Y or has no value.

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

prompts/adam-adce-worst-toxicity/brief.md

Edit
8 lines

Following CDISC ADaM standards, use the provided CE dataset to create an ADCE dataset with one record per clinical event.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, CESEQ, CETERM, ASTDT, ASEV, ASEVN, ATOXGRN, AOCCFL

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

yamaa code

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

run.R

Edit
4 lines
library(yamaa)adce <- yamaa_domain("spec.yaml")$outputadce

run.py

Edit
4 lines
import yamaaadce = yamaa.yamaa_domain("spec.yaml").outputadce

Solution without yamaa

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

solutions/adam-adce-worst-toxicity/result.R

Edit
41 lines
# Reference solution for the yamaa benchmark adam-adce-worst-toxicity (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)ce <- read_csv(  "/app/input/ce.csv",  col_types = cols(CESEQ = col_integer(), ASTDT = col_date(), .default = col_character()))adce <- ce |>  mutate(    ASEV = CESEV,    ASEVN = case_when(      ASEV == "MILD" ~ 1L,      ASEV == "MODERATE" ~ 2L,      ASEV == "SEVERE" ~ 3L    ),    ATOXGRN = ASEVN  )# The graded event with the greatest grade per subject; ties break by# earliest date, then lowest sequence, so at most one per subject.best <- adce |>  filter(!is.na(ATOXGRN)) |>  arrange(USUBJID, desc(ATOXGRN), ASTDT, CESEQ) |>  distinct(USUBJID, .keep_all = TRUE) |>  select(USUBJID, CESEQ) |>  mutate(BEST = "Y")adce <- adce |>  left_join(best, by = c("USUBJID", "CESEQ")) |>  mutate(AOCCFL = BEST) |>  select(STUDYID, USUBJID, CESEQ, CETERM, ASTDT, ASEV, ASEVN, ATOXGRN, AOCCFL)dir.create("/app/output", showWarnings = FALSE)write_csv(adce, "/app/output/adce.csv", na = "")

solutions/adam-adce-worst-toxicity/result.py

Edit
58 lines
# Reference solution for the yamaa benchmark adam-adce-worst-toxicity (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.from pathlib import Pathimport polars as plce = (    pl.read_csv("/app/input/ce.csv", infer_schema=False)    .with_columns(        pl.col("CESEQ").cast(pl.Int64),        pl.col("ASTDT").str.to_date(strict=False),    ))adce = ce.with_columns(    ASEV=pl.col("CESEV"),    ASEVN=pl.when(pl.col("CESEV") == "MILD")    .then(1)    .when(pl.col("CESEV") == "MODERATE")    .then(2)    .when(pl.col("CESEV") == "SEVERE")    .then(3)    .otherwise(None)    .cast(pl.Int64),).with_columns(ATOXGRN=pl.col("ASEVN"))# The graded event with the greatest grade per subject; ties break by# earliest date, then lowest sequence, so at most one per subject.best = (    adce.filter(pl.col("ATOXGRN").is_not_null())    .sort(["ATOXGRN", "ASTDT", "CESEQ"], descending=[True, False, False], nulls_last=True)    .unique("USUBJID", keep="first", maintain_order=True)    .select("USUBJID", "CESEQ")    .with_columns(BEST=pl.lit("Y")))adce = (    adce.join(best, on=["USUBJID", "CESEQ"], how="left")    .with_columns(AOCCFL=pl.col("BEST"))    .select(        "STUDYID",        "USUBJID",        "CESEQ",        "CETERM",        "ASTDT",        "ASEV",        "ASEVN",        "ATOXGRN",        "AOCCFL",    ))Path("/app/output").mkdir(exist_ok=True)adce.write_csv("/app/output/adce.csv")

solutions/adam-adce-worst-toxicity/result.sas

Edit
24 lines
/* opensas reference solution for the yamaa benchmark adam-adce-worst-toxicity.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */data ce;  length STUDYID USUBJID CETERM CESEV ASTDT $1024;  infile "/app/input/ce.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char1024. USUBJID : $char1024. CESEQ CETERM : $char1024. CESEV : $char1024. ASTDT : $char1024.;run;data graded;  length ASEV $1024;  set ce; NODATE=missing(ASTDT); ASEV=CESEV;  select(ASEV); when('MILD') ASEVN=1; when('MODERATE') ASEVN=2; when('SEVERE') ASEVN=3; otherwise ASEVN=.; end;  ATOXGRN=ASEVN;run;proc sort data=graded(where=(not missing(ATOXGRN))) out=eligible; by STUDYID USUBJID descending ATOXGRN NODATE ASTDT CESEQ; run;data worst; set eligible; by STUDYID USUBJID; if first.USUBJID; keep STUDYID USUBJID CESEQ; run;proc sql; create table result as select a.*,case when not missing(b.CESEQ) then 'Y' else '' end as AOCCFL from graded as a left join worst as b on a.STUDYID=b.STUDYID and a.USUBJID=b.USUBJID and a.CESEQ=b.CESEQ; quit;proc sql;  create table final as select STUDYID, USUBJID, CESEQ, CETERM, ASTDT, ASEV, ASEVN, ATOXGRN, AOCCFL from result;quit;proc export data=final outfile="/app/output/adce.csv" dbms=csv replace; run;