admiral-adrs
Derives an ADaM Tumor Response Analysis Dataset (ADRS) using the {admiral} and {admiralonco} R packages. Use when a user needs to create ADRS from SDTM RS domain data, derive RECIST 1.1 response parameters (overall response, confirmed response, best overall response, clinical benefit), or generate QC-ready R code following CDISC ADaM and oncology conventions. Requires SDTM RS input data, ADSL with randomization and treatment dates, and an ADaM ADRS specification.
RConsortium · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add RConsortium/pharma-skills --skill admiral-adrs技能说明
name: admiral-adrs description: > Derives an ADaM Tumor Response Analysis Dataset (ADRS) using the {admiral} and {admiralonco} R packages. Use when a user needs to create ADRS from SDTM RS domain data, derive RECIST 1.1 response parameters (overall response, confirmed response, best overall response, clinical benefit), or generate QC-ready R code following CDISC ADaM and oncology conventions. Requires SDTM RS input data, ADSL with randomization and treatment dates, and an ADaM ADRS specification. license: MIT metadata: author: Navitas Data Sciences version: "0.1" pharmaverse: "true" parent: admiral compatibility: > Requires R with admiral, admiralonco, dplyr, lubridate, and pharmaversesdtm installed. Requires a completed ADSL dataset with RANDDT and TRTSDT. Designed for use in a GxP-compliant oncology trial environment with access to SDTM RS domain data and an ADaM ADRS specification.
admiral-adrs
Shared conventions (library setup, pipe style, date rules, flag convention,
# REVIEW:annotations,stopifnot()patterns) are defined in the parent../SKILL.md. The workflow below is ADRS-specific.
Derives a CDISC-conformant ADRS tumor response dataset using {admiral} and {admiralonco}. Outputs executable, QC-ready R code covering RECIST 1.1 response parameters with full derivation traceability.
The primary design challenge in ADRS is the confirmation logic: CR and PR
must be supported by a second qualifying assessment ≥28 days later. Best Overall
Response (BOR) follows a strict hierarchy (CR > PR > SD > NON-CR/NON-PD > PD >
NE) and handles NE propagation in ways that manual case_when() or slice_min()
cannot replicate correctly. Always use admiralonco functions — never manual
derivations.
Inputs
Before generating code, confirm the following are available or explicitly noted as absent:
| Input | Required | Notes |
|---|---|---|
| RS | Yes | One record per tumor assessment per subject; RSSTRESC contains the response category (CR/PR/SD/PD/NE) |
| ADSL | Yes | Provides TRTSDT, RANDDT, treatment labels, population flags |
| ADaM ADRS spec | Yes | Parameter list, PARAMCD/PARAM mapping, confirmation window, clinical benefit definition |
| Study context | Yes | RECIST version (1.0 vs 1.1), assessor (investigator vs BICR), confirmation window, clinical benefit anchor date |
If RS or ADSL are absent, stop and request them.
Note on pharmaversesdtm test data: The pharmaversesdtm package no longer
exports a plain rs object. Use pharmaversesdtm::rs_onco_recist for test or
benchmark runs. When working with real study data, load RS from the study's
SDTM package or file path.
Workflow
Follow these steps in order. Generate code section by section, not as a single block.
Step 1 — Setup and domain loading
library(admiral)
library(admiralonco)
library(dplyr)
library(lubridate)
library(pharmaversesdtm)
# Load RS domain
# For pharmaversesdtm test data: use rs_onco_recist (plain `rs` no longer exported)
rs <- pharmaversesdtm::rs_onco_recist
adsl <- adsl # assumed derived upstream; replace with path/load as needed
# Confirm RS has at least one record
stopifnot(nrow(rs) > 0)
Step 2 — DOMAIN removal
Remove DOMAIN from RS before any derive_param_*() or derive_vars_merged()
calls. admiral errors when DOMAIN exists in both the dataset and a source dataset
passed to these functions.
rs <- rs |> select(-DOMAIN)
Step 3 — Merge ADSL backbone variables
Bring required ADSL variables into the RS dataset before parameter derivation. At minimum: RANDDT and TRTSDT (clinical benefit anchor and study day reference), treatment labels, and population flags.
# REVIEW: Confirm which ADSL variables are required by the ADaM ADRS spec.
# RANDDT is the conventional clinical benefit anchor date; TRTSDT is required
# for ADY derivation. Add or remove population flags per the spec.
adrs <- rs |>
derive_vars_merged(
dataset_add = adsl,
by_vars = exprs(STUDYID, USUBJID),
new_vars = exprs(RANDDT, TRTSDT, TRT01P, TRT01PN, TRT01A, TRT01AN,
ITTFL, SAFFL)
)
Step 4 — Date derivation (ADT, ADTF, ADY)
Derive the analysis date from RSDTC. This must happen before any
derive_param_*() call — admiralonco response functions use ADT internally for
confirmation window comparisons.
adrs <- adrs |>
derive_vars_dt(
dtc = RSDTC,
new_vars_prefix = "A",
date_imputation = "first",
flag_imputation = "auto"
) |>
derive_vars_dy(
reference_date = TRTSDT,
source_vars = exprs(ADT)
)
Step 5 — Analysis value (AVALC, AVAL)
Set AVALC from RSSTRESC and derive the numeric AVAL using the admiralonco helper
aval_resp(). This function maps response categories to a monotone numeric scale:
CR=1, PR=2, SD=3, NON-CR/NON-PD=4, PD=5, NE=6.
# REVIEW: Confirm that RSSTRESC values in this study's RS domain align with the
# RECIST 1.1 CT expected by aval_resp(). Non-standard categories (e.g.
# "NON-CR/NON-PD" in lymphoma, iRECIST response categories) require a custom
# lookup if aval_resp() does not map them — do not suppress the resulting NA.
adrs <- adrs |>
mutate(
AVALC = RSSTRESC,
AVAL = aval_resp(AVALC)
)
Step 6 — Overall response parameter (OVRLRESP)
Add OVRLRESP records — one per subject per assessment timepoint. This parameter carries the verbatim response at each visit; it is not confirmation-adjusted.
# REVIEW: PARAMCD and PARAM values must match the ADaM ADRS spec exactly.
# Adjust filter_source if the study uses a different assessor
# (BICR: RSEVAL == "INDEPENDENT ASSESSOR") or a different RECIST version.
adrs <- adrs |>
derive_param_response(
dataset_adsl = adsl,
filter_source = RSEVAL == "INVESTIGATOR" & RSEVALID == "RECIST 1.1",
source_var = RSSTRESC,
set_values_to = exprs(
PARAMCD = "OVRLRESP",
PARAM = "
阅读完整来源 ↗