Skip to content

Commit 2f02c69

Browse files
authored
Merge pull request #1088 from pharmaverse/1086-create-example-pc-ex-datasets
Create example PC, EX, DM datasets
2 parents ecdfa5f + 4eac083 commit 2f02c69

File tree

11 files changed

+436
-1
lines changed

11 files changed

+436
-1
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: aNCA
22
Title: (Pre-)Clinical NCA in a Dynamic Shiny App
3-
Version: 0.1.0.9125
3+
Version: 0.1.0.9126
44
Authors@R: c(
55
person("Ercan", "Suekuer", email = "ercan.suekuer@roche.com", role = "aut",
66
comment = c(ORCID = "0009-0001-1626-1526")),

R/data.R

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,90 @@
114114
#'
115115
#' @source Example data created for package demonstration and testing purposes.
116116
"adnca_example"
117+
118+
119+
#' pc_example
120+
#'
121+
#' An SDTM PC-like pharmacokinetic concentrations dataset derived from
122+
#' \code{\link{adnca_example}}. Intended to support and test the PC+EX upload
123+
#' workflow (see GitHub issue #624).
124+
#'
125+
#' @format A data frame with the same number of rows as \code{adnca_example}
126+
#' and 11 variables:
127+
#' \describe{
128+
#' \item{DOMAIN}{Character. Domain Abbreviation.}
129+
#' \item{STUDYID}{Character. Study identifier.}
130+
#' \item{USUBJID}{Character. Unique subject identifier.}
131+
#' \item{PCTEST}{Character. Name of the measured analyte (mapped from PARAM).}
132+
#' \item{PCSPEC}{Character. Specimen type (e.g., SERUM, URINE).}
133+
#' \item{PCSTRESN}{Numeric. Numeric concentration result (mapped from AVAL).}
134+
#' \item{PCSTRESU}{Character. Concentration units (mapped from AVALU).}
135+
#' \item{PCDTC}{Character. Sample collection datetime (ISO 8601), synthesised
136+
#' from AFRLT using an arbitrary reference origin.}
137+
#' \item{PCRFTDTC}{Character. Reference dose datetime (ISO 8601), synthesised
138+
#' from AFRLT - ARRLT.}
139+
#' \item{PCELTM}{Character. Planned elapsed time from reference dose in
140+
#' ISO 8601 duration format (e.g., "PT0.5H"), derived from NFRLT.}
141+
#' \item{VOLUME}{Numeric. Volume of specimen collected (mL), for urine samples.}
142+
#' \item{VOLUMEU}{Character. Volume units.}
143+
#' }
144+
#' @source Derived from \code{\link{adnca_example}} and \code{\link{dm_example}}
145+
#' via \code{data-raw/sdtm_example.R}.
146+
"pc_example"
147+
148+
149+
#' ex_example
150+
#'
151+
#' An SDTM EX-like exposure/dosing dataset derived from
152+
#' \code{\link{adnca_example}}. Contains one row per dosing event per subject.
153+
#' Intended to support and test the PC+EX upload workflow (see GitHub issue #624).
154+
#'
155+
#' @format A data frame with 11 variables:
156+
#' \describe{
157+
#' \item{DOMAIN}{Character. Domain abbreviation.}
158+
#' \item{STUDYID}{Character. Study identifier.}
159+
#' \item{USUBJID}{Character. Unique subject identifier.}
160+
#' \item{EXTRT}{Character. Name of the treatment (mapped from DOSETRT).}
161+
#' \item{EXDOSE}{Numeric. Dose amount (mapped from DOSEA).}
162+
#' \item{EXDOSU}{Character. Dose units (mapped from DOSEU).}
163+
#' \item{EXROUTE}{Character. Route of administration (mapped from ROUTE).}
164+
#' \item{EXSTDTC}{Character. Dosing start datetime (ISO 8601), synthesised
165+
#' from AFRLT - ARRLT using the subject's RFXSTDTC as reference origin.}
166+
#' \item{EXENDTC}{Character. Dosing end datetime (ISO 8601), computed as
167+
#' EXSTDTC + ADOSEDUR.}
168+
#' \item{EXDUR}{Character. Duration of dose in ISO 8601 duration format
169+
#' (e.g., "PT2.9H"), derived from ADOSEDUR.}
170+
#' \item{EXELTM}{Character. Planned elapsed time from first dose in ISO 8601
171+
#' duration format (e.g., "PT0H"), derived from NFRLT - NRRLT relative to
172+
#' the subject's first dose.}
173+
#' }
174+
#' @source Derived from \code{\link{adnca_example}} and \code{\link{dm_example}}
175+
#' via \code{data-raw/sdtm_example.R}.
176+
"ex_example"
177+
178+
179+
#' dm_example
180+
#'
181+
#' An SDTM DM-like demographics dataset derived from
182+
#' \code{\link{adnca_example}}. Contains one row per subject with demographic
183+
#' variables and a synthetic treatment start date (RFXSTDTC) that serves as the
184+
#' reference origin for datetimes in \code{\link{pc_example}} and
185+
#' \code{\link{ex_example}}.
186+
#'
187+
#' @format A data frame with one row per subject and 9 variables:
188+
#' \describe{
189+
#' \item{DOMAIN}{Character. Domain Abbreviation.}
190+
#' \item{STUDYID}{Character. Study identifier.}
191+
#' \item{USUBJID}{Character. Unique subject identifier.}
192+
#' \item{AGE}{Numeric. Age of the subject.}
193+
#' \item{AGEU}{Character. Age units (e.g., "Years").}
194+
#' \item{SEX}{Character. Sex of the subject.}
195+
#' \item{RACE}{Character. Race of the subject.}
196+
#' \item{ARM}{Character. Planned treatment arm (mapped from TRT01A).}
197+
#' \item{ACTARM}{Character. Actual treatment arm (mapped from TRT01A).}
198+
#' \item{RFXSTDTC}{Character. Date/time of first study treatment (ISO 8601).
199+
#' Synthetic, staggered by 3 days per subject to simulate different
200+
#' enrollment dates.}
201+
#' }
202+
#' @source Derived from \code{\link{adnca_example}} via \code{data-raw/sdtm_example.R}.
203+
"dm_example"

data-raw/sdtm_example.R

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Derive SDTM-like example datasets (DM, PC, EX) from adnca_example
2+
#
3+
# This script creates three datasets with SDTM-style column names from the
4+
# existing ADaM-style adnca_example. Intended to support and test the PC+EX
5+
# upload workflow (see issues #624 and #1086).
6+
7+
adnca_example <- read.csv("data-raw/adnca_example.csv", na.strings = c("", "NA"))
8+
9+
# --- DM (Demographics) -------------------------------------------------------
10+
# One row per subject with demographics and a synthetic treatment start date.
11+
12+
subjects <- adnca_example[!duplicated(adnca_example$USUBJID), ]
13+
14+
# Stagger treatment start dates by 3 days per subject to simulate different
15+
# enrollment dates.
16+
base_date <- as.POSIXct("2024-01-15 08:00:00", tz = "UTC")
17+
subject_offsets_days <- seq(0, by = 3, length.out = nrow(subjects))
18+
rfxstdtc <- base_date + subject_offsets_days * 86400
19+
20+
dm_example <- data.frame(
21+
DOMAIN = "DM",
22+
STUDYID = subjects$STUDYID,
23+
USUBJID = subjects$USUBJID,
24+
AGE = subjects$AGE,
25+
AGEU = subjects$AGEU,
26+
SEX = subjects$SEX,
27+
RACE = subjects$RACE,
28+
ARM = subjects$TRT01A,
29+
ACTARM = subjects$TRT01A,
30+
RFXSTDTC = format(rfxstdtc, "%Y-%m-%dT%H:%M:%S"),
31+
stringsAsFactors = FALSE
32+
)
33+
34+
# --- Reference date lookup ----------------------------------------------------
35+
# Used by both PC and EX below.
36+
37+
ref_dates <- stats::setNames(
38+
as.POSIXct(dm_example$RFXSTDTC, format = "%Y-%m-%dT%H:%M:%S", tz = "UTC"),
39+
dm_example$USUBJID
40+
)
41+
42+
# --- PC (Pharmacokinetic Concentrations) --------------------------------------
43+
# One row per concentration observation, same row count as adnca_example.
44+
45+
subject_origin_pc <- ref_dates[adnca_example$USUBJID]
46+
dose_time_from_first <- adnca_example$AFRLT - adnca_example$ARRLT
47+
48+
pc_example <- data.frame(
49+
DOMAIN = "PC",
50+
STUDYID = adnca_example$STUDYID,
51+
USUBJID = adnca_example$USUBJID,
52+
PCTEST = adnca_example$PARAM,
53+
PCSPEC = adnca_example$PCSPEC,
54+
PCSTRESN = adnca_example$AVAL,
55+
PCSTRESU = adnca_example$AVALU,
56+
PCDTC = format(subject_origin_pc + adnca_example$AFRLT * 3600,
57+
"%Y-%m-%dT%H:%M:%S"),
58+
PCRFTDTC = format(subject_origin_pc + dose_time_from_first * 3600,
59+
"%Y-%m-%dT%H:%M:%S"),
60+
PCELTM = sprintf("PT%gH", adnca_example$NFRLT),
61+
VOLUME = adnca_example$VOLUME,
62+
VOLUMEU = adnca_example$VOLUMEU,
63+
stringsAsFactors = FALSE
64+
)
65+
66+
# --- EX (Exposure / Dosing) ---------------------------------------------------
67+
# One row per dosing event, deduplicated from adnca_example.
68+
69+
ex_example <- adnca_example %>%
70+
dplyr::mutate(
71+
dose_time = AFRLT - ARRLT,
72+
nominal_dose_time = NFRLT - NRRLT
73+
) %>%
74+
dplyr::distinct(STUDYID, USUBJID, DOSETRT, ATPTREF, .keep_all = TRUE) %>%
75+
dplyr::group_by(USUBJID) %>%
76+
dplyr::mutate(
77+
subject_origin = ref_dates[USUBJID],
78+
exeltm = nominal_dose_time - min(nominal_dose_time)
79+
) %>%
80+
dplyr::ungroup() %>%
81+
dplyr::transmute(
82+
DOMAIN = "EX",
83+
STUDYID,
84+
USUBJID,
85+
EXTRT = DOSETRT,
86+
EXDOSE = DOSEA,
87+
EXDOSU = DOSEU,
88+
EXROUTE = ROUTE,
89+
EXSTDTC = format(subject_origin + dose_time * 3600, "%Y-%m-%dT%H:%M:%S"),
90+
EXENDTC = format(subject_origin + dose_time * 3600 + ADOSEDUR * 3600,
91+
"%Y-%m-%dT%H:%M:%S"),
92+
EXDUR = sprintf("PT%gH", ADOSEDUR),
93+
EXELTM = sprintf("PT%gH", exeltm)
94+
) %>%
95+
as.data.frame()
96+
97+
# --- Save all three -----------------------------------------------------------
98+
99+
usethis::use_data(dm_example, overwrite = TRUE)
100+
usethis::use_data(pc_example, overwrite = TRUE)
101+
usethis::use_data(ex_example, overwrite = TRUE)

data/dm_example.rda

457 Bytes
Binary file not shown.

data/ex_example.rda

1.03 KB
Binary file not shown.

data/pc_example.rda

8.74 KB
Binary file not shown.

inst/WORDLIST

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Clast
2626
Cmax
2727
Cond
2828
Customizable
29+
DM
2930
DOSEA
3031
DOSETRT
3132
DOSEU
@@ -38,6 +39,7 @@ ERTLST
3839
ERTMAX
3940
EV
4041
EVID
42+
EXSTDTC
4143
Extravascular
4244
Kezia
4345
Kobana
@@ -83,6 +85,7 @@ Pre
8385
QMD
8486
README
8587
RENALCL
88+
RFXSTDTC
8689
RRLTU
8790
RStudio
8891
RefGroups
@@ -132,8 +135,11 @@ customizable
132135
customizations
133136
dataformat
134137
dateTime
138+
datetime
139+
datetimes
135140
devtools
136141
df
142+
dm
137143
doi
138144
extravascular
139145
ggplot
@@ -154,6 +160,7 @@ nca
154160
ng
155161
oligo
156162
pak
163+
pc
157164
pcspec
158165
pharmacodynamics
159166
pharmacokinetic
@@ -176,6 +183,7 @@ SelectInputs
176183
signif
177184
src
178185
standardizations
186+
synthesised
179187
th
180188
tibble
181189
tidyverse

man/dm_example.Rd

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ex_example.Rd

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/pc_example.Rd

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)