admiral-adrs

使用 {admiral} 和 {admiralonco} R 包从 SDTM RS 域数据生成 ADaM 肿瘤反应分析数据集 (ADRS)。适用于需要从 SDTM RS 和包含随机化与治疗日期的 ADSL 推导 RECIST 1.1 反应参数(总体反应、确认反应、最佳总体反应、临床获益)或生成符合 CDISC ADaM 与肿瘤学规范的 QC 就绪 R 代码的场景。要求输入 SDTM RS、ADSL 和 ADRS 规范。

仓库最近推送
GitHub Stars
146
Forks
36
Issues / PRs
75

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "admiral-adrs":https://skillpi.com/zh/skills/deepskill-1897c0d7d9abab36e36a26a75d8c41e796f698fb72be9ef2fccfc44d2f995a42。安装前核对上游来源和版本:https://github.com/RConsortium/pharma-skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

使用 {admiral} 和 {admiralonco} R 包从 SDTM RS 域数据生成 ADaM 肿瘤反应分析数据集 (ADRS)。适用于需要从 SDTM RS 和包含随机化与治疗日期的 ADSL 推导 RECIST 1.1 反应参数(总体反应、确认反应、最佳总体反应、临床获益)或生成符合 CDISC ADaM 与肿瘤学规范的 QC 就绪 R 代码的场景。要求输入 SDTM RS、ADSL 和 ADRS 规范。

0 下载

介绍来源: third_party · RConsortium · 0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
适合谁
来源文档未说明。
输入和输出
翻译待完成,请参阅来源文档。
软件、账号及付费要求
翻译待完成,请参阅来源文档。
限制与区别
来源文档未说明。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
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   = "Overall Response by Investigator"
    )
  )

Step 7 — Unconfirmed response flag (RSP)

Add RSP records — one per subject, indicating whether any CR or PR was observed (unconfirmed). Retained alongside CONFIRMED to enable the ORR verification check in Step 11.

adrs <- adrs |>
  derive_param_response(
    dataset_adsl  = adsl,
    filter_source = RSEVAL == "INVESTIGATOR" & RSEVALID == "RECIST 1.1",
    source_var    = RSSTRESC,
    resp_val      = c("CR", "PR"),
    set_values_to = exprs(
      PARAMCD = "RSP",
      PARAM   = "Response (Unconfirmed)"
    )
  )

Step 8 — Confirmed response (CONFIRMED)

A CR or PR is confirmed when a second qualifying assessment ≥ ref_confirm days after the first also shows CR or PR. CONFIRMED = "Y" if the subject has at least one confirmed CR or PR; "N" otherwise.

Flag convention note: CONFIRMED uses "Y"/"N", not "Y"/NA — this is the documented admiralonco contract. See Flag convention exception below. Do not recode "N" to NA.

# REVIEW: ref_confirm = 28 is the RECIST 1.1 standard for CR/PR confirmation.
#   Confirm this value against the study protocol and SAP — some programs specify
#   21 days, and regulatory precedent exists for other windows. A wrong value
#   silently inflates or deflates confirmed ORR.
adrs <- adrs |>
  derive_param_confirmed_resp(
    dataset_adsl  = adsl,
    filter_source = RSEVAL == "INVESTIGATOR" & RSEVALID == "RECIST 1.1",
    source_var    = RSSTRESC,
    ref_confirm   = 28,       # PLACEHOLDER — confirm from SAP
    set_values_to = exprs(
      PARAMCD = "CONFIRMED",
      PARAM   = "Confirmed Response"
    )
  )

Step 9 — Best overall response (BESTRESP)

BOR applies the RECIST 1.1 hierarchy across all assessments for each subject. derive_param_confirmed_bor() handles confirmation requirements, the NE propagation rule, and the hierarchy correctly. Never substitute slice_min(AVAL) or manual case_when() — these cannot replicate the NE propagation logic.

# REVIEW: missing_as_ne controls how missing assessments are treated in BOR.
#   FALSE (default): missing assessments are ignored (excluded from BOR).
#   TRUE: missing assessments count as NE, which can worsen BOR for subjects
#   with gaps in the assessment schedule.
#   Confirm the per-protocol analysis population definition with the
#   statistical reviewer before committing to either value.
adrs <- adrs |>
  derive_param_confirmed_bor(
    dataset_adsl  = adsl,
    filter_source = RSEVAL == "INVESTIGATOR" & RSEVALID == "RECIST 1.1",
    source_var    = RSSTRESC,
    ref_confirm   = 28,       # must match Step 8
    missing_as_ne = FALSE,    # PLACEHOLDER — confirm from SAP
    set_values_to = exprs(
      PARAMCD = "BESTRESP",
      PARAM   = "Best Overall Response (Confirmed)"
    )
  )

Step 10 — Clinical benefit (CBRESPFL)

Clinical benefit is a durable non-progressive response: CR, PR, or SD sustained for ≥ ref_start_window days from reference_date. CBRESPFL = "Y" if criteria are met; "N" otherwise.

Flag convention note: CBRESPFL uses "Y"/"N", not "Y"/NA. Same admiralonco contract as CONFIRMED — do not recode.

# REVIEW: Two protocol-specific decisions are required here and must both be
#   confirmed from the protocol and SAP before use:
#
#   (1) reference_date — RANDDT is the conventional anchor. Some protocols
#       instead define the 42-day window from the date of the first qualifying
#       response (first SD, PR, or CR). If the protocol means "from first
#       qualifying assessment", compute per-subject first-assessment dates
#       and pass them as reference_date rather than a fixed ADSL variable.
#
#   (2) ref_start_window = 42 — RECIST standard for SD duration. Some studies
#       use 35 or 56 days. Confirm from the protocol.
adrs <- adrs |>
  derive_param_clinbenefit(
    dataset_adsl     = adsl,
    filter_source    = RSEVAL == "INVESTIGATOR" & RSEVALID == "RECIST 1.1",
    source_var       = RSSTRESC,
    reference_date   = RANDDT,    # PLACEHOLDER — confirm anchor from protocol
    ref_start_window = 42,        # PLACEHOLDER — confirm from protocol
    set_values_to    = exprs(
      PARAMCD = "CBRESPFL",
      PARAM   = "Clinical Benefit"
    )
  )

Step 11 — Verification: confirmed vs unconfirmed ORR

Print response counts side-by-side and assert that confirmed ORR cannot exceed unconfirmed ORR. A confirmed count greater than unconfirmed count signals a configuration error in the confirmation window.

# Print response parameter summary for QC — include in script output log
response_summary <- adrs |>
  filter(PARAMCD %in% c("RSP", "CONFIRMED", "CBRESPFL")) |>
  count(PARAMCD, AVALC)
print(response_summary)

# Confirmed ORR must not exceed unconfirmed ORR
n_confirmed   <- sum(adrs$PARAMCD == "CONFIRMED" & adrs$AVALC == "Y", na.rm = TRUE)
n_unconfirmed <- sum(adrs$PARAMCD == "RSP"       & adrs$AVALC == "Y", na.rm = TRUE)
stopifnot(n_confirmed <= n_unconfirmed)

# PD is never a confirmed response
stopifnot(!any(
  adrs$PARAMCD == "CONFIRMED" & adrs$AVALC == "Y" &
  adrs$AVAL == aval_resp("PD"),
  na.rm = TRUE
))

Step 12 — Final checks

# Required parameter coverage
required_params <- c("OVRLRESP", "RSP", "CONFIRMED", "BESTRESP", "CBRESPFL")
missing_params  <- setdiff(required_params, unique(adrs$PARAMCD))
if (length(missing_params) > 0) {
  stop("Missing required ADRS parameters: ", paste(missing_params, collapse = ", "))
}

# Uniqueness: one record per subject per subject-level parameter
dup_check <- adrs |>
  filter(PARAMCD %in% c("BESTRESP", "CONFIRMED", "RSP", "CBRESPFL")) |>
  count(STUDYID, USUBJID, PARAMCD) |>
  filter(n > 1)
if (nrow(dup_check) > 0) {
  stop("Duplicate subject-level parameter records found:\n",
       paste(paste(dup_check$USUBJID, dup_check$PARAMCD), collapse = "\n"))
}

# Required variable presence check
required_vars <- c(
  "STUDYID", "USUBJID", "PARAMCD", "PARAM",
  "ADT", "ADTF", "ADY", "AVAL", "AVALC", "TRTSDT"
)
missing_vars <- setdiff(required_vars, names(adrs))
if (length(missing_vars) > 0) {
  stop("Missing required ADRS variables: ", paste(missing_vars, collapse = ", "))
}

Flag convention exception for CONFIRMED and CBRESPFL

The admiral family convention is "Y" or NA — never "N" — for flag variables. ADRS has two named exceptions:

Variable Values Reason
CONFIRMED "Y" / "N" admiralonco contract: "N" means assessed but unconfirmed, not missing
CBRESPFL "Y" / "N" admiralonco contract: same logic as CONFIRMED

Do not recode "N" to NA for these variables. The "N" records are required by downstream derive_param_confirmed_bor() logic to correctly identify subjects with no confirmed response. Recoding them breaks BOR derivation.

All other flags in ADRS (ANL01FL, ABLFL, population flags from ADSL) follow the standard "Y" or NA convention.


Common errors to avoid

  • Using rs instead of rs_onco_recist from pharmaversesdtm — the plain rs object is no longer exported; the script will fail at load
  • Using case_when() or slice_min(AVAL) for BOR — manual BOR derivation cannot replicate admiralonco's NE propagation rule and confirmation hierarchy; always use derive_param_confirmed_bor()
  • Not removing DOMAIN from RS before derive_param_*() calls — causes variable conflict errors; DOMAIN must be removed in Step 2, not in the final select() at the end of the script
  • Hardcoding ref_confirm = 28 without a # REVIEW: comment — the confirmation window is protocol-specific and must come from the SAP; a wrong value silently inflates or deflates confirmed ORR
  • Applying derive_vars_dt() after derive_param_response() — ADT must exist before the response parameter functions run; the functions use ADT for confirmation window comparisons
  • Using RANDDT as the clinical benefit anchor without verifying protocol intent — if the protocol defines the 42-day window from the "first qualifying response assessment" rather than randomization, a fixed RANDDT will misclassify subjects
  • Not printing the confirmed vs unconfirmed ORR comparison — the omission is a silent audit risk; confirmed ORR > unconfirmed ORR indicates a derivation error that will not surface without an explicit check
  • Recoding CONFIRMED or CBRESPFL "N" to NA — these values are meaningful per the admiralonco function contract; recoding breaks downstream BOR derivation

Output checklist

Before returning code, verify:

  • [ ] DOMAIN removed from RS in Step 2, before any derive_param_*() call
  • [ ] ADSL merged with at minimum RANDDT, TRTSDT, and population flags before parameter derivation
  • [ ] ADT derived with derive_vars_dt() from RSDTC, with flag_imputation = "auto"
  • [ ] AVALC and AVAL (via aval_resp()) populated before derive_param_response() calls
  • [ ] All five parameters present in output: OVRLRESP, RSP, CONFIRMED, BESTRESP, CBRESPFL
  • [ ] # REVIEW: at PARAMCD/PARAM mapping in Steps 6–10
  • [ ] # REVIEW: at ref_confirm in Steps 8 and 9
  • [ ] # REVIEW: at missing_as_ne in Step 9
  • [ ] # REVIEW: at reference_date and ref_start_window in Step 10
  • [ ] Confirmed vs unconfirmed ORR comparison printed to console (Step 11)
  • [ ] stopifnot(n_confirmed <= n_unconfirmed) present (Step 11)
  • [ ] PD-never-confirmed assertion present (Step 11)
  • [ ] Required PARAMCD coverage check present (Step 12)
  • [ ] Uniqueness assertion for subject-level parameters (Step 12)
  • [ ] CONFIRMED and CBRESPFL values are "Y"/"N" — not recoded to "Y"/NA

当前收录版本

0.1

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值95/100

亮点

  • 解决制药行业肿瘤试验中ADaM ADRS数据集生成的核心痛点
  • 涉及RECIST 1.1反应参数推导、确认逻辑、BOR计算等专业需求
  • 具有明确的GxP合规场景和广泛受众
触发精准92/100

亮点

  • description清晰描述了使用admiral/admiralonco包生成ADRS的具体场景
  • 覆盖SDTM RS输入、ADSL要求、RECIST 1.1参数等关键要素
  • 边界清晰
结构规范90/100

亮点

  • Phase/步骤清晰(Step 1-12),有出口条件(stopifnot检查)
  • 含端到端示例,frontmatter完整
  • 文档组织良好
执行可靠88/100

亮点

  • 工具来源明确(admiral/admiralonco),参数正确
  • 覆盖主要异常(stopifnot检查),不可逆操作有确认机制(# REVIEW注释)
  • 少量异常未覆盖如输入数据验证
证据可验 (前四项均值)91/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

翻译待完成,请参阅来源文档。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。