跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
开发与测试

admiral-adtte

Derives an ADaM Time-to-Event Analysis Dataset (ADTTE) using the {admiral} R package. Use when a user needs to create ADTTE from SDTM event domains (AE, DS, CE) and ADSL, define event and censoring conditions, derive AVAL in days, and generate QC-ready R code following CDISC ADaM BDS-TTE conventions. Requires SDTM source domains, a completed ADSL, and an ADaM ADTTE specification that defines the event and censoring rules.

RConsortium · 已有 AI 审核记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add RConsortium/pharma-skills --skill admiral-adtte

技能说明


name: admiral-adtte description: > Derives an ADaM Time-to-Event Analysis Dataset (ADTTE) using the {admiral} R package. Use when a user needs to create ADTTE from SDTM event domains (AE, DS, CE) and ADSL, define event and censoring conditions, derive AVAL in days, and generate QC-ready R code following CDISC ADaM BDS-TTE conventions. Requires SDTM source domains, a completed ADSL, and an ADaM ADTTE specification that defines the event and censoring rules. license: MIT metadata: author: Navitas Data Sciences version: "0.1" pharmaverse: "true" parent: admiral compatibility: > Requires R with admiral, dplyr, lubridate, and pharmaversesdtm installed. Requires a completed ADSL dataset with TRTSDT and TRTEDT. Designed for use in a GxP-compliant environment with access to SDTM event domain data and an ADaM ADTTE specification defining event and censoring rules.

admiral-adtte

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 ADTTE-specific.

Derives a CDISC-conformant ADTTE time-to-event dataset using {admiral}. Outputs executable, QC-ready R code with event and censoring logic fully traceable to the ADaM specification.

The primary design challenge in ADTTE is the event and censoring hierarchy: the correct event date, censoring date, and censoring reason depend entirely on the protocol-specified rules. These must be defined as named event_source() and censor_source() objects — never as inline expressions — so they can be reviewed, tested, and reused independently.


Inputs

Before generating code, confirm the following are available or explicitly noted as absent:

InputRequiredNotes
AE / DS / CEYesEvent source domain(s); which domain depends on the endpoint (AE for safety TTE, DS for EFS/PFS, CE for clinical events)
ADSLYesProvides TRTSDT (start date), TRTEDT (censoring date fallback), population flags
ADaM ADTTE specYesEvent definition, censoring hierarchy, PARAMCD/PARAM, CNSDTDSC controlled terminology
Study contextYesPost-treatment window for safety TTE, censoring date priority order, analysis population

If ADSL is absent, stop and request it. If the event source domain is absent, stop and request it — do not substitute synthetic dates.


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(dplyr)
library(lubridate)
library(pharmaversesdtm)
library(pharmaverseadam)

# Load event source domain(s) — substitute with the domain(s) relevant to the endpoint
ae   <- pharmaversesdtm::ae
adsl <- pharmaverseadam::adsl  # assumed derived upstream

stopifnot(nrow(ae) > 0)

Step 2 — DOMAIN removal

Remove DOMAIN from every event source domain before passing it to derive_param_tte(). admiral errors when DOMAIN exists in both the dataset and a source_datasets entry.

ae <- ae |> select(-DOMAIN)
# Repeat for every source domain used in event_source() or censor_source() calls

Step 3 — Merge ADSL backbone variables

Bring required ADSL variables into the event dataset. At minimum: TRTSDT (start date for ADTTE), TRTEDT (fallback censoring date), and population flags. Always use derive_vars_merged() — not left_join().

# REVIEW: Confirm which ADSL variables are required per the ADTTE spec.
#   TRTSDT is the conventional STARTDT for most TTE parameters. If the endpoint
#   uses randomization date instead, use RANDDT. Add population flags as needed.
adtte <- ae |>
  derive_vars_merged(
    dataset_add = adsl,
    by_vars     = exprs(STUDYID, USUBJID),
    new_vars    = exprs(TRTSDT, TRTEDT, TRT01P, TRT01PN, TRT01A, TRT01AN,
                        SAFFL, ITTFL)
  )

Step 4 — Derive event dates on source domain

Convert DTC dates in the source domain to analysis dates using derive_vars_dt() before referencing them in event_source() or censor_source(). Never use as.Date() on DTC variables.

adtte <- adtte |>
  derive_vars_dt(
    dtc             = AESTDTC,
    new_vars_prefix = "AST",
    date_imputation = "first",
    flag_imputation = "auto"
  )

Step 5 — Define event source objects

Define event conditions as named event_source() objects. Never define them inline inside derive_param_tte() — named objects are independently testable and reviewable.

# REVIEW: The event filter below (AESER == "Y") is the most common definition
#   for a time-to-first-serious-AE endpoint. Confirm the exact event definition
#   from the ADaM ADTTE spec and SAP:
#   - Which AE terms or flags qualify? (AESER, AETOXGR >= 3, specific AEDECOD terms)
#   - Does the event require onset during treatment only, or ever?
#   - What is the event date — onset (ASTDT) or report date?
ttae_event <- event_source(
  dataset_name  = "ae",
  filter        = AESER == "Y",          # PLACEHOLDER — confirm from SAP
  date          = ASTDT,
  set_values_to = exprs(
    EVNTDESC = "Serious adverse event",
    SRCDOM   = "AE",
    SRCVAR   = "AESTDTC",
    SRCSEQ   = AESEQ
  )
)

Step 6 — Define censoring source objects

Define censoring conditions as named censor_source() objects in priority order (first entry wins when multiple dates are available for a subject).

# REVIEW: The censoring date below (TRTEDT + 30) is a common proxy for
#   "30 days post last dose" TTE endpoints. Confirm the censoring hierarchy
#   from the ADaM ADTTE spec and SAP:
#   - What is the primary censoring date? (last contact, last dose + window, LSDT)
#   - Is the post-treatment window 30, 28, or another number of days?
#   - What is CNSDTDSC for each censoring type? Confirm against define.xml CT.
ttae_censor <- censor_source(
  dataset_name  = "adsl",
  date          = TRTEDT + 30,           #
阅读完整来源 ↗