Review ask

As a clinical trial statistician or programmer, answer three short questions in Your review: the task, the inputs and outputs, and the AI-assisted review. Agreeing with all three approves this benchmark; disagreeing with any needs a comment. Propose a fix with the Edit button on any source file, or add it to your comments.

We suggest spending no more than 5 minutes on a review. The other tabs beside Your review are background for assessment, not under review.

Summary

Lifecycle: draftEditUnder review
What this benchmark means
README.md

Public entries: Python and R. Passing coverage requires an installed inventory.

Goal: retain the weight used for dosing and calculate body surface area (BSA) at each treatment cycle.

Input: SDTM vital-signs weights, with visit dates and sequence numbers, plus subject-level baseline height in centimetres.

Variables:

  • STUDYID identifies the study.
  • USUBJID identifies the subject within the study.
  • ASEQ is the source measurement's sequence number.
  • AVISITN is the treatment cycle number.
  • ADT is the collection date, absent when no date was collected.
  • AVAL is the collected weight in kilograms, absent for a missing measurement.
  • ANCHORWT starts with the first observed weight. A change of at least 10%, upwards or downwards from the retained weight, replaces it with the current weight. Smaller changes and missing measurements keep the prior retained weight. The replacement applies on the triggering cycle too. There is no retained weight until a weight has been observed.
  • BSA is the square root of retained weight times baseline height divided by 3600, in square metres, absent when retained weight or baseline height is unavailable. Values are displayed to two decimal places.

The published cycle pattern follows Table 3 of Liu et al., PharmaSUG 2020 DS-235. Additional invented measurements exercise repeated exact-boundary resets, missing weight and independent subjects.

Inputs

Under review
2 source files

input/adsl.csv

Edit
2 rows
input/adsl.csv
STUDYIDUSUBJIDHEIGHTBL
DOSE-01175
DOSE-01180

input/vs.csv

Edit
12 rows
input/vs.csv
STUDYIDUSUBJIDVSSEQVISITNUMVSDTCVSSTRESN
DOSE-01112019-04-0271
DOSE-01112019-04-02100
DOSE-01222019-04-2467
DOSE-01222019-04-2490
DOSE-01332019-05-1565
DOSE-01332019-05-1599
DOSE-01442019-06-0565
DOSE-01442019-06-05—
DOSE-01552019-06-2761
DOSE-01662019-07-1760
DOSE-01772019-08-0757
DOSE-01882019-08-3059

Expected output

Under review
12 expected rows

expected/advs.csv

Edit
12 rows
expected/advs.csv
STUDYIDUSUBJIDASEQAVISITNADTAVALANCHORWTBSA
DOSE-01112019-04-02100.00100.002.24
DOSE-01222019-04-2490.0090.002.12
DOSE-01332019-05-1599.0099.002.22
DOSE-01442019-06-05—99.002.22
DOSE-01112019-04-0271.0071.001.86
DOSE-01222019-04-2467.0071.001.86
DOSE-01332019-05-1565.0071.001.86
DOSE-01442019-06-0565.0071.001.86
DOSE-01552019-06-2761.0061.001.72
DOSE-01662019-07-1760.0061.001.72
DOSE-01772019-08-0757.0061.001.72
DOSE-01882019-08-3059.0061.001.72
Shaded columns are derived— = missing value

Human review and assessment

Your review

3 questions and your comments · View benchmark discussions

Mapping spec

Generated from the benchmark YAML; do not edit by hand

Dataset NameVariable NameVariable LabelTypeCodelist/Controlled TermsCoreComputational MethodOrigin
ADVSSTUDYIDStudy IdentifiercharacterCopy value from VS.STUDYID.Predecessor
ADVSUSUBJIDUnique Subject IdentifiercharacterCopy value from VS.USUBJID.Predecessor
ADVSASEQAnalysis Sequence NumbernumericCopy value from VS.VSSEQ.Predecessor
ADVSAVISITNAnalysis Visit NumbernumericCopy value from VS.VISITNUM.Predecessor
ADVSADTAnalysis DatenumericISO 8601Copy value from VS.VSDTC.Predecessor
ADVSAVALCollected Weight (kg)numericCopy value from VS.VSSTRESN.Predecessor
ADVSANCHORWTWeight Used for Dosing (kg)numericIf PREVANCH IS NULL then "AVAL"; If AVAL IS NULL then "PREVANCH"; If ABS(AVAL - PREVANCH) / PREVANCH >= 0.10 then "AVAL"; otherwise "PREVANCH".Derived
ADVSBSABody Surface Area (m2)numericCompute SQRT(ANCHORWT * HEIGHTBL / 3600).Derived
VersionDateAuthorDescriptionReviewerSign-off
1.72026-10-20yamaa docs buildRead a specification in the 1.0 surface as its 0.5 counterpart; state that missing values stay missing where a mapping declares no missing handler, and leave out a declared missing answer that restates a handler's default
1.62026-10-17yamaa docs buildDescribe collected date parts written as ISO 8601 date text and times of day counted in seconds since midnight
1.52026-10-17yamaa docs buildName collected precision in words instead of letter codes; state imputation fallbacks, minimum source precision, bounds ignored outside the collected period, and invalid text with no handler as an error; describe date and datetime shifts, imputation flag codes, and partial text giving no date part
1.42026-10-15yamaa docs buildState datetime precision codes through the hour and minute, and complete only the time parts a collected datetime lacks
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-advs-dosing-weight/full.md

Edit
25 lines

Following CDISC ADaM standards, use the provided ADSL and VS datasets to create an ADVS dataset with one record per subject per treatment cycle.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, AVISITN, ADT, AVAL, ANCHORWT, BSA

ASEQ is the VS sequence number VSSEQ, without renumbering. AVISITN is the cycle number in VISITNUM; ADT is the collection date in VSDTC, and AVAL is the collected weight in kilograms in VSSTRESN.

Within each study and subject, ANCHORWT is the weight used for dosing in kilograms, starting with the first observed weight in ascending cycle order. At a later cycle with a measured weight at least 10% above or below the prior retained dosing weight, ANCHORWT is that measured weight, including a change of exactly 10%. The new weight applies on the triggering cycle too. At other cycles, including a missing weight, ANCHORWT is the prior retained dosing weight.

BSA is the square root of (ANCHORWT times the subject's baseline height in centimetres from ADSL divided by 3600), in square metres, rounded to two decimal places.

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

prompts/adam-advs-dosing-weight/conventions.md

Edit
10 lines

Following CDISC ADaM standards, use the provided ADSL and VS datasets to create an ADVS dataset with one record per subject per treatment cycle.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, AVISITN, ADT, AVAL, ANCHORWT, BSA

BSA is rounded to two decimal places.

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

prompts/adam-advs-dosing-weight/brief.md

Edit
8 lines

Following CDISC ADaM standards, use the provided ADSL and VS datasets to create an ADVS dataset with one record per subject per treatment cycle.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, ASEQ, AVISITN, ADT, AVAL, ANCHORWT, BSA

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

yamaa code

Public calls generated from benchmark.yaml; results must match the expected output

R

Edit
3 lines
library(yamaa)yamaa_spec("spec.yaml")$run()$output

Python

Edit
3 lines
import yamaayamaa.spec("spec.yaml").run().output

Solution without yamaa

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

solutions/adam-advs-dosing-weight/result.R

Edit
63 lines
# Execute with Rscript /app/output/result.R.adsl <- read.csv(  "/app/input/adsl.csv", stringsAsFactors = FALSE, na.strings = c("", "NA"),  colClasses = c(STUDYID = "character", USUBJID = "character", HEIGHTBL = "numeric"))vs <- read.csv(  "/app/input/vs.csv", stringsAsFactors = FALSE, na.strings = c("", "NA"),  colClasses = c(STUDYID = "character", USUBJID = "character", VSSEQ = "numeric",                 VISITNUM = "numeric", VSDTC = "character", VSSTRESN = "numeric"))# Retain a dosing weight until an inclusive 10% change from that weight.retained_weight <- function(weights) {  anchor <- NA_real_  result <- rep(NA_real_, length(weights))  for (i in seq_along(weights)) {    weight <- weights[i]    if (!is.na(weight)) {      if (is.na(anchor)) {        anchor <- weight      } else {        # Allow only floating-point rounding error at the 10% boundary.        tolerance <- 16 * .Machine$double.eps * max(1, abs(anchor), abs(weight))        if (abs(weight - anchor) >= 0.10 * abs(anchor) - tolerance) {          anchor <- weight        }      }    }    result[i] <- anchor  }  result}stopifnot(!anyDuplicated(adsl[c("STUDYID", "USUBJID")]))stopifnot(!anyDuplicated(vs[c("STUDYID", "USUBJID", "VISITNUM")]))vs <- merge(vs, adsl[c("STUDYID", "USUBJID", "HEIGHTBL")],            by = c("STUDYID", "USUBJID"), all.x = TRUE, sort = FALSE)vs <- vs[order(vs$STUDYID, vs$USUBJID, vs$VISITNUM, vs$VSSEQ), , drop = FALSE]vs$ANCHORWT <- rep(NA_real_, nrow(vs))if (nrow(vs) > 0L) {  # Consecutive rows share a group only when study and subject both match.  new_subject <- c(TRUE,    vs$STUDYID[-1L] != vs$STUDYID[-nrow(vs)] |    vs$USUBJID[-1L] != vs$USUBJID[-nrow(vs)])  subject_rows <- split(seq_len(nrow(vs)), cumsum(new_subject))  for (rows in subject_rows) {    vs$ANCHORWT[rows] <- retained_weight(vs$VSSTRESN[rows])  }}advs <- data.frame(  STUDYID = vs$STUDYID,  USUBJID = vs$USUBJID,  ASEQ = vs$VSSEQ,  AVISITN = vs$VISITNUM,  ADT = as.Date(substr(vs$VSDTC, 1, 10)),  AVAL = vs$VSSTRESN,  ANCHORWT = vs$ANCHORWT,  BSA = round(sqrt(vs$ANCHORWT * vs$HEIGHTBL / 3600), 2),  stringsAsFactors = FALSE)write.csv(advs, "/app/output/advs.csv", row.names = FALSE, na = "")

solutions/adam-advs-dosing-weight/result.py

Edit
88 lines
"""Derive cycle-level ADVS dosing weights and body surface area."""import csvfrom decimal import Decimal, ROUND_HALF_UPfrom pathlib import PathINPUT_DIR = Path("/app/input")OUTPUT_DIR = Path("/app/output")COLUMNS = ["STUDYID", "USUBJID", "ASEQ", "AVISITN", "ADT", "AVAL", "ANCHORWT", "BSA"]def numeric(value):    text = (value or "").strip()    if not text:        return None    number = Decimal(text)    return number if number.is_finite() else Nonedef formatted(number):    return "" if number is None else format(number, "f")def main():    with (INPUT_DIR / "adsl.csv").open(newline="", encoding="utf-8-sig") as source:        heights = {            (row["STUDYID"], row["USUBJID"]): numeric(row["HEIGHTBL"])            for row in csv.DictReader(source)        }    with (INPUT_DIR / "vs.csv").open(newline="", encoding="utf-8-sig") as source:        visits = list(csv.DictReader(source))    visits.sort(        key=lambda row: (            row["STUDYID"],            row["USUBJID"],            Decimal(row["VISITNUM"]),            Decimal(row["VSSEQ"]),        )    )    anchors = {}    result = []    for row in visits:        subject = (row["STUDYID"], row["USUBJID"])        weight = numeric(row["VSSTRESN"])        anchor = anchors.get(subject)        if weight is not None:            if (                anchor is None                or weight >= anchor * Decimal("1.10")                or weight <= anchor * Decimal("0.90")            ):                anchor = weight        anchors[subject] = anchor        height = heights.get(subject)        bsa = None        if anchor is not None and height is not None:            bsa = (                (anchor * height / Decimal("3600"))                .sqrt()                .quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)            )        result.append(            {                "STUDYID": row["STUDYID"],                "USUBJID": row["USUBJID"],                "ASEQ": row["VSSEQ"],                "AVISITN": row["VISITNUM"],                "ADT": row["VSDTC"].split("T", 1)[0],                "AVAL": formatted(weight),                "ANCHORWT": formatted(anchor),                "BSA": formatted(bsa),            }        )    OUTPUT_DIR.mkdir(parents=True, exist_ok=True)    with (OUTPUT_DIR / "advs.csv").open("w", newline="", encoding="utf-8") as target:        writer = csv.DictWriter(target, fieldnames=COLUMNS)        writer.writeheader()        writer.writerows(result)if __name__ == "__main__":    main()

solutions/adam-advs-dosing-weight/result.sas

Edit
45 lines
proc import datafile='/app/input/adsl.csv' out=adsl dbms=csv replace;  getnames=yes;  guessingrows=max;run;proc import datafile='/app/input/vs.csv' out=vs dbms=csv replace;  getnames=yes;  guessingrows=max;run;proc sql;  create table cycle_weights as  select v.STUDYID, v.USUBJID, v.VSSEQ as ASEQ,         v.VISITNUM as AVISITN, v.VSDTC, v.VSSTRESN as AVAL,         a.HEIGHTBL  from vs as v left join adsl as a    on v.STUDYID=a.STUDYID and v.USUBJID=a.USUBJID;quit;proc sort data=cycle_weights;  by STUDYID USUBJID AVISITN ASEQ;run;data derived;  set cycle_weights;  by STUDYID USUBJID;  retain ANCHORWT;  if first.USUBJID then ANCHORWT=.;  if not missing(AVAL) then do;    if missing(ANCHORWT) then ANCHORWT=AVAL;    else if 10*abs(AVAL-ANCHORWT) >= ANCHORWT-1e-10 then ANCHORWT=AVAL;  end;  ADT=put(VSDTC,yymmdd10.);  BSA=round(sqrt(ANCHORWT*HEIGHTBL/3600),0.01);run;proc sql;  create table advs as  select STUDYID, USUBJID, ASEQ, AVISITN, ADT, AVAL, ANCHORWT, BSA  from derived  order by STUDYID, USUBJID, AVISITN, ASEQ;quit;proc export data=advs outfile='/app/output/advs.csv' dbms=csv replace;run;