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: derive the lower (ANRLO) and upper (ANRHI) limit of each laboratory parameter's 95% reference range for each sex as the 2.5th and 97.5th percentiles of the study's own results, which assume no distribution, and the variance of those results (AVALVAR), on every record of the parameter and sex.

Input: standardized laboratory results (LB), one result per subject and test, with no result when the test was not done; and subject-level analysis data (ADSL) giving each subject's sex.

Variables:

  • SEX: the subject's sex, from the subject-level data.
  • AVAL: the standardized numeric result; empty when the test was not done.
  • ANRLO: the 2.5th percentile of the results of the record's parameter and sex, by R's default definition (type 7). With the n results sorted ascending, it sits at position h = (n - 1) * 0.025 + 1: the j-th smallest result, j the whole part of h, plus h - j times the gap to the next one, so a limit need not be an observed value. The same on every record of the parameter and sex, including one without a result. It is not rounded.
  • ANRHI: the 97.5th percentile, at h = (n - 1) * 0.975 + 1, under the same terms.
  • AVALVAR: the sample variance of the same results, their squared deviations from their mean added and divided by n - 1, under the same terms.

Note: a test not done takes no part in its group's percentiles, variance or count, and each parameter and sex takes its values from its own results alone. Five results put the limits at positions 1.1 and 4.9, and four at 1.075 and 3.925; the binary rounding of a position reaches no written digit here. The results sorted, and the arithmetic of each group:

Creatinine (umol/L), female: 61, 66, 70, 73, 80
  ANRLO   = 61 + 0.1 * (66 - 61) = 61.5
  ANRHI   = 73 + 0.9 * (80 - 73) = 79.3
  AVALVAR = (81 + 16 + 0 + 9 + 100) / 4 = 51.5, about the mean 70
Creatinine (umol/L), male: 78, 84, 88, 95, 105
  ANRLO   = 78 + 0.1 * (84 - 78) = 78.6
  ANRHI   = 95 + 0.9 * (105 - 95) = 104
  AVALVAR = (144 + 36 + 4 + 25 + 225) / 4 = 108.5, about the mean 90
Hemoglobin (g/L), female: 118, 126, 131, 135, 140
  ANRLO   = 118 + 0.1 * (126 - 118) = 118.8
  ANRHI   = 135 + 0.9 * (140 - 135) = 139.5
  AVALVAR = (144 + 16 + 1 + 25 + 100) / 4 = 71.5, about the mean 130
Hemoglobin (g/L), male, one test not done: 141, 147, 153, 159
  ANRLO   = 141 + 0.075 * (147 - 141) = 141.45
  ANRHI   = 153 + 0.925 * (159 - 153) = 158.55
  AVALVAR = (81 + 9 + 9 + 81) / 3 = 60, about the mean 150

Inputs

Under review
2 source files

input/adsl.csv

Edit
10 rows
input/adsl.csv
STUDYIDUSUBJIDSEX
YAMAA-01F
YAMAA-01M
YAMAA-01F
YAMAA-01M
YAMAA-01F
YAMAA-01M
YAMAA-01F
YAMAA-01M
YAMAA-01F
YAMAA-01M

input/lb.csv

Edit
20 rows
input/lb.csv
STUDYIDDOMAINUSUBJIDLBSEQLBTESTCDLBTESTLBSTRESNLBSTRESULBSTAT
YAMAA-01LB1CREATCreatinine70umol/L—
YAMAA-01LB2HGBHemoglobin126g/L—
YAMAA-01LB1CREATCreatinine95umol/L—
YAMAA-01LB2HGBHemoglobin153g/L—
YAMAA-01LB1CREATCreatinine61umol/L—
YAMAA-01LB2HGBHemoglobin140g/L—
YAMAA-01LB1CREATCreatinine78umol/L—
YAMAA-01LB2HGBHemoglobin141g/L—
YAMAA-01LB1CREATCreatinine80umol/L—
YAMAA-01LB2HGBHemoglobin118g/L—
YAMAA-01LB1CREATCreatinine105umol/L—
YAMAA-01LB2HGBHemoglobin——NOT DONE
YAMAA-01LB1CREATCreatinine66umol/L—
YAMAA-01LB2HGBHemoglobin135g/L—
YAMAA-01LB1CREATCreatinine88umol/L—
YAMAA-01LB2HGBHemoglobin159g/L—
YAMAA-01LB1CREATCreatinine73umol/L—
YAMAA-01LB2HGBHemoglobin131g/L—
YAMAA-01LB1CREATCreatinine84umol/L—
YAMAA-01LB2HGBHemoglobin147g/L—

Expected output

Under review
20 expected rows

expected/adlb.csv

Edit
20 rows
expected/adlb.csv
STUDYIDUSUBJIDSEXPARAMCDAVALANRLOANRHIAVALVAR
YAMAA-01FCREAT7061.579.351.5
YAMAA-01FHGB126118.8139.571.5
YAMAA-01MCREAT9578.6104108.5
YAMAA-01MHGB153141.45158.5560
YAMAA-01FCREAT6161.579.351.5
YAMAA-01FHGB140118.8139.571.5
YAMAA-01MCREAT7878.6104108.5
YAMAA-01MHGB141141.45158.5560
YAMAA-01FCREAT8061.579.351.5
YAMAA-01FHGB118118.8139.571.5
YAMAA-01MCREAT10578.6104108.5
YAMAA-01MHGB—141.45158.5560
YAMAA-01FCREAT6661.579.351.5
YAMAA-01FHGB135118.8139.571.5
YAMAA-01MCREAT8878.6104108.5
YAMAA-01MHGB159141.45158.5560
YAMAA-01FCREAT7361.579.351.5
YAMAA-01FHGB131118.8139.571.5
YAMAA-01MCREAT8478.6104108.5
YAMAA-01MHGB147141.45158.5560
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
ADLBSTUDYIDStudy IdentifiercharacterCopy value from LB.STUDYID.Predecessor
ADLBUSUBJIDUnique Subject IdentifiercharacterCopy value from LB.USUBJID.Predecessor
ADLBSEXSexcharacterCopy value from ADSL.SEX.Predecessor
ADLBPARAMCDParameter CodecharacterCopy value from LB.LBTESTCD.Predecessor
ADLBAVALAnalysis ValuenumericCopy value from LB.LBSTRESN.Predecessor
ADLBANRLOAnalysis Normal Range Lower LimitnumericAggregate QUANTILE(AVAL) over records grouped by STUDYID, PARAMCD, SEX, matching on the shared output keys.Derived
ADLBANRHIAnalysis Normal Range Upper LimitnumericAggregate QUANTILE(AVAL) over records grouped by STUDYID, PARAMCD, SEX, matching on the shared output keys.Derived
ADLBAVALVARAnalysis Value VariancenumericAggregate VARIANCE(AVAL) over records grouped by STUDYID, PARAMCD, SEX, matching on the shared output keys.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-adlb-nonparametric-limits/full.md

Edit
32 lines

Following CDISC ADaM standards, use the provided ADSL and LB datasets to create an ADLB dataset with one record per subject per parameter.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, SEX, PARAMCD, AVAL, ANRLO, ANRHI, AVALVAR

Each LB record, including a test not done, gives one output record. SEX is the subject's sex from ADSL. PARAMCD is the lab test code (LBTESTCD) as given. AVAL is the standardized numeric result (LBSTRESN), and has no value when the test was not done. ANRLO and ANRHI are the lower and upper limits of the 95% reference range of the record's parameter and sex, estimated from the study's own results without assuming a distribution, and AVALVAR is the variance of those results:

  • ANRLO is the 2.5th percentile and ANRHI the 97.5th percentile of the results of the parameter and sex, by Hyndman and Fan's type 7 definition: the quantile at probability p is the value at position (n - 1) * p + 1 of the n results in ascending order, interpolated linearly between the two neighbouring results when that position is fractional, so a limit need not be an observed value. A definition that returns an observed value or the midpoint of two gives other limits.
  • AVALVAR is the sample variance of the same results, with divisor one less than the number of results.
  • A test not done takes no part in the percentiles, the variance or the number of results, and each parameter and sex takes its values from its own results alone.
  • ANRLO, ANRHI and AVALVAR are the same on every record of the parameter and sex, including a record without a result.
  • None of them is rounded.

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

prompts/adam-adlb-nonparametric-limits/conventions.md

Edit
12 lines

Following CDISC ADaM standards, use the provided ADSL and LB datasets to create an ADLB dataset with one record per subject per parameter.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, SEX, PARAMCD, AVAL, ANRLO, ANRHI, AVALVAR

ANRLO and ANRHI are the lower and upper limits of the 95% reference range, by Hyndman and Fan's type 7 definition, and AVALVAR is the sample variance. None of them is rounded.

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

prompts/adam-adlb-nonparametric-limits/brief.md

Edit
8 lines

Following CDISC ADaM standards, use the provided ADSL and LB datasets to create an ADLB dataset with one record per subject per parameter.

The output dataset should contain the following columns in this order: STUDYID, USUBJID, SEX, PARAMCD, AVAL, ANRLO, ANRHI, AVALVAR

Read the source datasets from /app/input and save the completed dataset as /app/output/adlb.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-adlb-nonparametric-limits/result.R

Edit
43 lines
# Reference solution for the yamaa benchmark adam-adlb-nonparametric-limits# (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.adsl <- read.csv("/app/input/adsl.csv", na.strings = "",                 stringsAsFactors = FALSE)lb <- read.csv(  "/app/input/lb.csv",  colClasses = c(LBSTRESN = "numeric"),  na.strings = "",  stringsAsFactors = FALSE)adlb <- merge(lb, adsl[, c("STUDYID", "USUBJID", "SEX")],              by = c("STUDYID", "USUBJID"), all.x = TRUE, sort = FALSE)adlb <- adlb[order(adlb$STUDYID, adlb$USUBJID, adlb$LBTESTCD), ]# Each parameter and sex's 2.5th and 97.5th percentiles (R's default, type 7)# and sample variance, a test not done left out.group <- interaction(adlb$LBTESTCD, adlb$SEX, drop = TRUE)percentile <- function(p) {  function(x) {    if (all(is.na(x))) return(NA_real_)    unname(quantile(x, p, na.rm = TRUE, type = 7))  }}out <- data.frame(  STUDYID = adlb$STUDYID,  USUBJID = adlb$USUBJID,  SEX = adlb$SEX,  PARAMCD = adlb$LBTESTCD,  AVAL = adlb$LBSTRESN,  ANRLO = ave(adlb$LBSTRESN, group, FUN = percentile(0.025)),  ANRHI = ave(adlb$LBSTRESN, group, FUN = percentile(0.975)),  AVALVAR = ave(adlb$LBSTRESN, group, FUN = function(x) var(x, na.rm = TRUE)))dir.create("/app/output", showWarnings = FALSE)write.csv(out, "/app/output/adlb.csv", row.names = FALSE, na = "")

solutions/adam-adlb-nonparametric-limits/result.py

Edit
85 lines
# Reference solution for the yamaa benchmark adam-adlb-nonparametric-limits# (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 csvimport statisticsADSL_CSV = "/app/input/adsl.csv"LB_CSV = "/app/input/lb.csv"OUTPUT_CSV = "/app/output/adlb.csv"def number(text):    text = text.strip()    return float(text) if text else Nonedef cell(value):    return "" if value is None else repr(value)def type7(values, p):    """Hyndman and Fan's type 7 quantile of the values at probability p."""    x = sorted(values)    h = (len(x) - 1) * p + 1    j = int(h)    if j >= len(x):        return x[-1]    return x[j - 1] + (h - j) * (x[j] - x[j - 1])def main():    with open(ADSL_CSV, newline="") as f:        sex = {            (r["STUDYID"], r["USUBJID"]): r["SEX"] for r in csv.DictReader(f)        }    with open(LB_CSV, newline="") as f:        lb = list(csv.DictReader(f))    # Each parameter and sex's results, a test not done left out.    results = {}    for row in lb:        value = number(row["LBSTRESN"])        subject_sex = sex.get((row["STUDYID"], row["USUBJID"]), "")        group = (row["LBTESTCD"], subject_sex)        results.setdefault(group, [])        if value is not None:            results[group].append(value)    summary = {}    for group, values in results.items():        low = type7(values, 0.025) if values else None        high = type7(values, 0.975) if values else None        variance = statistics.variance(values) if len(values) > 1 else None        summary[group] = (low, high, variance)    fieldnames = [        "STUDYID", "USUBJID", "SEX", "PARAMCD", "AVAL", "ANRLO", "ANRHI",        "AVALVAR",    ]    with open(OUTPUT_CSV, "w", newline="") as f:        writer = csv.DictWriter(f, fieldnames=fieldnames)        writer.writeheader()        for row in lb:            subject_sex = sex.get((row["STUDYID"], row["USUBJID"]), "")            low, high, variance = summary[(row["LBTESTCD"], subject_sex)]            writer.writerow(                {                    "STUDYID": row["STUDYID"],                    "USUBJID": row["USUBJID"],                    "SEX": subject_sex,                    "PARAMCD": row["LBTESTCD"],                    "AVAL": cell(number(row["LBSTRESN"])),                    "ANRLO": cell(low),                    "ANRHI": cell(high),                    "AVALVAR": cell(variance),                }            )if __name__ == "__main__":    main()

solutions/adam-adlb-nonparametric-limits/result.sas

Edit
97 lines
/* opensas reference solution for the yamaa benchmark   adam-adlb-nonparametric-limits.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas.   The limits follow R's default definition (type 7), which none of the   percentile definitions of the procedures gives, so a DATA step computes   them from the sorted values. */data lb;  length STUDYID DOMAIN USUBJID LBTESTCD LBTEST LBSTRESU LBSTAT $40;  infile "/app/input/lb.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char40. DOMAIN : $char40. USUBJID : $char40. LBSEQ        LBTESTCD : $char40. LBTEST : $char40. LBSTRESN LBSTRESU : $char40.        LBSTAT : $char40.;run;data adsl;  length STUDYID USUBJID SEX $40;  infile "/app/input/adsl.csv" dsd dlm="," firstobs=2 truncover lrecl=32767;  input STUDYID : $char40. USUBJID : $char40. SEX : $char40.;run;/* Each record with its subject's sex. */proc sql;  create table withsex as    select l.STUDYID, l.USUBJID, a.SEX, l.LBTESTCD, l.LBSTRESN    from lb as l left join adsl as a      on a.STUDYID = l.STUDYID and a.USUBJID = l.USUBJID;quit;/* The results of each parameter and sex in ascending order, numbered from   1; a test not done has none and takes no part. */proc sort data=withsex(where=(not missing(LBSTRESN))) out=sorted;  by LBTESTCD SEX LBSTRESN;run;data ranked;  set sorted;  by LBTESTCD SEX;  if first.SEX then RANK = 0;  RANK + 1;  keep LBTESTCD SEX RANK LBSTRESN;run;proc sql;  create table counts as    select LBTESTCD, SEX, count(*) as N, mean(LBSTRESN) as M    from ranked group by LBTESTCD, SEX;quit;/* Type 7: the quantile at proportion P sits at position H = (N - 1) * P + 1,   between the values ranked J = floor(H) and K = J + 1, at fraction G. */data positions;  set counts;  STAT = 1; P = 0.025; H = (N - 1) * P + 1; J = floor(H); G = H - J;  K = min(J + 1, N); output;  STAT = 2; P = 0.975; H = (N - 1) * P + 1; J = floor(H); G = H - J;  K = min(J + 1, N); output;run;/* The limits, and the sample variance with divisor N - 1. */proc sql;  create table quantiles as    select p.LBTESTCD, p.SEX, p.STAT,           lo.LBSTRESN + p.G * (hi.LBSTRESN - lo.LBSTRESN) as Q    from positions as p      inner join ranked as lo        on lo.LBTESTCD = p.LBTESTCD and lo.SEX = p.SEX and lo.RANK = p.J      inner join ranked as hi        on hi.LBTESTCD = p.LBTESTCD and hi.SEX = p.SEX and hi.RANK = p.K;  create table squares as    select r.LBTESTCD, r.SEX, c.N,           (r.LBSTRESN - c.M) * (r.LBSTRESN - c.M) as SQ    from ranked as r inner join counts as c      on c.LBTESTCD = r.LBTESTCD and c.SEX = r.SEX;  create table variances as    select LBTESTCD, SEX,           case when N > 1 then sum(SQ) / (N - 1) else . end as AVALVAR    from squares group by LBTESTCD, SEX, N;  /* A query of one table names its columns bare: opensas reads a table     alias's qualified names as missing in GROUP BY and inside a summary     function, which would put every row in one group with no limits. */  create table limits as    select LBTESTCD, SEX,           max(case when STAT = 1 then Q else . end) as ANRLO,           max(case when STAT = 2 then Q else . end) as ANRHI    from quantiles group by LBTESTCD, SEX;  create table final as    select w.STUDYID, w.USUBJID, w.SEX, w.LBTESTCD as PARAMCD length=40,           w.LBSTRESN as AVAL, s.ANRLO, s.ANRHI, v.AVALVAR    from withsex as w      left join limits as s on s.LBTESTCD = w.LBTESTCD and s.SEX = w.SEX      left join variances as v on v.LBTESTCD = w.LBTESTCD and v.SEX = w.SEX    order by 1, 2, 4;quit;proc export data=final outfile="/app/output/adlb.csv" dbms=csv replace; run;