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 from the study's own results, and give both on every record of the parameter.

Input: standardized laboratory results (LB), one result per subject and test, with no result when the test was not done.

Variables:

  • AVAL: the standardized numeric result; empty when the test was not done.
  • ANRLO: the mean of the parameter's results less 1.96 standard deviations: exactly, the standard normal distribution's 97.5th percentile times the sample standard deviation, with divisor one less than the number of results. The same on every record of the parameter, including one without a result. It is not rounded.
  • ANRHI: the mean plus the same multiple of the standard deviation, under the same terms.

Note: a test not done takes no part in its parameter's mean or standard deviation, and each parameter's limits come from its own results alone. The limits bound the central 95% of a normal distribution with that mean and standard deviation.

Inputs

Under review
1 source file

input/lb.csv

Edit
18 rows
input/lb.csv
STUDYIDDOMAINUSUBJIDLBSEQLBTESTCDLBTESTLBSTRESNLBSTRESULBSTAT
YAMAA-01LB1ALTAlanine Aminotransferase14U/L—
YAMAA-01LB2PLATPlatelets24510^9/L—
YAMAA-01LB3SODIUMSodium137mmol/L—
YAMAA-01LB1ALTAlanine Aminotransferase21U/L—
YAMAA-01LB2PLATPlatelets19810^9/L—
YAMAA-01LB3SODIUMSodium141mmol/L—
YAMAA-01LB1ALTAlanine Aminotransferase——NOT DONE
YAMAA-01LB2PLATPlatelets31010^9/L—
YAMAA-01LB3SODIUMSodium139mmol/L—
YAMAA-01LB1ALTAlanine Aminotransferase35U/L—
YAMAA-01LB2PLATPlatelets26210^9/L—
YAMAA-01LB3SODIUMSodium142mmol/L—
YAMAA-01LB1ALTAlanine Aminotransferase18U/L—
YAMAA-01LB2PLATPlatelets22110^9/L—
YAMAA-01LB3SODIUMSodium139mmol/L—
YAMAA-01LB1ALTAlanine Aminotransferase27U/L—
YAMAA-01LB2PLATPlatelets28710^9/L—
YAMAA-01LB3SODIUMSodium142mmol/L—

Expected output

Under review
18 expected rows

expected/adlb.csv

Edit
18 rows
expected/adlb.csv
STUDYIDUSUBJIDPARAMCDAVALANRLOANRHI
YAMAA-01ALT146.8972527065455939.102747293454414
YAMAA-01PLAT245172.57239767451978335.0942689921469
YAMAA-01SODIUM137136.0800720309199143.9199279690801
YAMAA-01ALT216.8972527065455939.102747293454414
YAMAA-01PLAT198172.57239767451978335.0942689921469
YAMAA-01SODIUM141136.0800720309199143.9199279690801
YAMAA-01ALT—6.8972527065455939.102747293454414
YAMAA-01PLAT310172.57239767451978335.0942689921469
YAMAA-01SODIUM139136.0800720309199143.9199279690801
YAMAA-01ALT356.8972527065455939.102747293454414
YAMAA-01PLAT262172.57239767451978335.0942689921469
YAMAA-01SODIUM142136.0800720309199143.9199279690801
YAMAA-01ALT186.8972527065455939.102747293454414
YAMAA-01PLAT221172.57239767451978335.0942689921469
YAMAA-01SODIUM139136.0800720309199143.9199279690801
YAMAA-01ALT276.8972527065455939.102747293454414
YAMAA-01PLAT287172.57239767451978335.0942689921469
YAMAA-01SODIUM142136.0800720309199143.9199279690801
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
ADLBPARAMCDParameter CodecharacterCopy value from LB.LBTESTCD.Predecessor
ADLBAVALAnalysis ValuenumericCopy value from LB.LBSTRESN.Predecessor
ADLBANRLOAnalysis Normal Range Lower LimitnumericAggregate MEAN(AVAL) - NORM_INV(0.975) * STDDEV(AVAL) over records grouped by STUDYID, PARAMCD, matching on the shared output keys.Derived
ADLBANRHIAnalysis Normal Range Upper LimitnumericAggregate MEAN(AVAL) + NORM_INV(0.975) * STDDEV(AVAL) over records grouped by STUDYID, PARAMCD, 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-reference-limits/full.md

Edit
25 lines

Following CDISC ADaM standards, use the provided LB dataset 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, PARAMCD, AVAL, ANRLO, ANRHI

Each LB record, including a test not done, gives one output record. 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 parameter's 95% reference range, estimated from the study's own results:

  • ANRLO is the mean of the parameter's results less z times their sample standard deviation, and ANRHI is the mean plus z times it.
  • z is the standard normal distribution's 97.5th percentile at full precision (1.9599639845400536), not the rounded 1.96.
  • The standard deviation has divisor one less than the number of results.
  • A test not done takes no part in its parameter's mean, standard deviation or number of results, and each parameter's limits come from its own results alone.
  • Both limits are the same on every record of the parameter, including a record without a result.
  • Neither limit is rounded.

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

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

Edit
11 lines

Following CDISC ADaM standards, use the provided LB dataset 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, PARAMCD, AVAL, ANRLO, ANRHI

ANRLO and ANRHI are the lower and upper limits of the parameter's 95% reference range. Neither limit is rounded.

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

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

Edit
8 lines

Following CDISC ADaM standards, use the provided LB dataset 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, PARAMCD, AVAL, ANRLO, ANRHI

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-reference-limits/result.R

Edit
31 lines
# Reference solution for the yamaa benchmark adam-adlb-reference-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.lb <- read.csv(  "/app/input/lb.csv",  colClasses = c(LBSTRESN = "numeric"),  na.strings = "",  stringsAsFactors = FALSE)# Each parameter's 95% reference range from the study's results: the mean# less and plus the standard normal 0.975 quantile times the sample standard# deviation, a test not done left out.limit <- function(values, sign) {  mean(values, na.rm = TRUE) + sign * qnorm(0.975) * sd(values, na.rm = TRUE)}adlb <- data.frame(  STUDYID = lb$STUDYID,  USUBJID = lb$USUBJID,  PARAMCD = lb$LBTESTCD,  AVAL = lb$LBSTRESN,  ANRLO = ave(lb$LBSTRESN, lb$LBTESTCD, FUN = function(x) limit(x, -1)),  ANRHI = ave(lb$LBSTRESN, lb$LBTESTCD, FUN = function(x) limit(x, 1)))dir.create("/app/output", showWarnings = FALSE)write.csv(adlb, "/app/output/adlb.csv", row.names = FALSE, na = "")

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

Edit
60 lines
# Reference solution for the yamaa benchmark adam-adlb-reference-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 statisticsLB_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 main():    with open(LB_CSV, newline="") as f:        lb = list(csv.DictReader(f))    # Each parameter's results, a test not done left out.    results = {}    for row in lb:        value = number(row["LBSTRESN"])        if value is not None:            results.setdefault(row["LBTESTCD"], []).append(value)    z = statistics.NormalDist().inv_cdf(0.975)    limits = {}    for test, values in results.items():        mean = statistics.fmean(values)        sd = statistics.stdev(values)        limits[test] = (mean - z * sd, mean + z * sd)    fieldnames = ["STUDYID", "USUBJID", "PARAMCD", "AVAL", "ANRLO", "ANRHI"]    with open(OUTPUT_CSV, "w", newline="") as f:        writer = csv.DictWriter(f, fieldnames=fieldnames)        writer.writeheader()        for row in lb:            low, high = limits.get(row["LBTESTCD"], (None, None))            writer.writerow(                {                    "STUDYID": row["STUDYID"],                    "USUBJID": row["USUBJID"],                    "PARAMCD": row["LBTESTCD"],                    "AVAL": cell(number(row["LBSTRESN"])),                    "ANRLO": cell(low),                    "ANRHI": cell(high),                }            )if __name__ == "__main__":    main()

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

Edit
42 lines
/* opensas reference solution for the yamaa benchmark adam-adlb-reference-limits.   Reads the benchmark inputs and derives the requested output.   Execute with the existing opensas runtime: opensas /app/output/result.sas. */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;/* The results of each parameter; a test not done has none and takes no   part. */data results;  set lb;  if not missing(LBSTRESN);run;/* Each parameter's mean and sample standard deviation (divisor n - 1), and   its limits at the mean less and plus the standard normal 0.975 quantile,   probit(0.975) = 1.959963984540054, times that deviation. */proc sql;  create table means as    select LBTESTCD, mean(LBSTRESN) as M, count(*) as N    from results group by LBTESTCD;  create table squares as    select r.LBTESTCD, m.M, m.N, (r.LBSTRESN - m.M) * (r.LBSTRESN - m.M) as SQ    from results as r inner join means as m on m.LBTESTCD = r.LBTESTCD;  create table limits as    select LBTESTCD,           M - 1.959963984540054 * sqrt(sum(SQ) / (N - 1)) as ANRLO,           M + 1.959963984540054 * sqrt(sum(SQ) / (N - 1)) as ANRHI    from squares group by LBTESTCD, M, N;  create table final as    select l.STUDYID, l.USUBJID, l.LBTESTCD as PARAMCD length=40,           l.LBSTRESN as AVAL, s.ANRLO, s.ANRHI    from lb as l left join limits as s on s.LBTESTCD = l.LBTESTCD    order by 1, 2, 3;quit;proc export data=final outfile="/app/output/adlb.csv" dbms=csv replace; run;