Skip to content

Commit b1135bd

Browse files
authored
Merge pull request #84 from pharmaverse/17_display_dataset_extracts
Closes #17 display dataset extracts
2 parents ca4a508 + b735233 commit b1135bd

File tree

14 files changed

+438
-284
lines changed

14 files changed

+438
-284
lines changed

DESCRIPTION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Imports:
2828
metatools,
2929
pharmaversesdtm,
3030
pharmaverseadam,
31+
reactable,
32+
reactablefmtr,
3133
sparkline,
3234
stringr,
3335
shinylive,

adam/adpc.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ library(metatools)
99
library(xportr)
1010
library(pharmaversesdtm)
1111
library(pharmaverseadam)
12+
library(reactable)
1213

1314
## ----r echo=TRUE--------------------------------------------------------------
1415
# ---- Load Specs for Metacore ----
@@ -19,11 +20,11 @@ metacore <- spec_to_metacore("./metadata/pk_spec.xlsx") %>%
1920
## ----r------------------------------------------------------------------------
2021
# ---- Load source datasets ----
2122
# Load PC, EX, VS, LB and ADSL
22-
data("pc")
23-
data("ex")
24-
data("vs")
23+
ex <- pharmaversesdtm::ex
24+
pc <- pharmaversesdtm::pc
25+
vs <- pharmaversesdtm::vs
2526

26-
data("adsl")
27+
adsl <- pharmaverseadam::adsl
2728

2829
ex <- convert_blanks_to_na(ex)
2930
pc <- convert_blanks_to_na(pc)

adam/adpc.qmd

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ order: 2
44
---
55

66
```{r setup script, include=FALSE, purl=FALSE}
7-
invisible_hook_purl <- function(before, options, ...) {knitr::hook_purl(before, options, ...); NULL}
7+
invisible_hook_purl <- function(before, options, ...) {
8+
knitr::hook_purl(before, options, ...)
9+
NULL
10+
}
811
knitr::knit_hooks$set(purl = invisible_hook_purl)
12+
source("functions/print_df.R")
913
```
1014

1115
The Non-compartmental analysis (NCA) ADaM uses the CDISC Implementation Guide (<https://www.cdisc.org/standards/foundational/adam/adamig-non-compartmental-analysis-input-data-v1-0>). This example presented uses underlying `EX` and `PC` domains where the `EX` and `PC` domains represent data as collected and the `ADPC` ADaM is output. For more details see the `{admiral}` [vignette](https://pharmaverse.github.io/admiral/articles/pk_adnca.html){target="_blank"}.
@@ -28,6 +32,7 @@ library(metatools)
2832
library(xportr)
2933
library(pharmaversesdtm)
3034
library(pharmaverseadam)
35+
library(reactable)
3136
```
3237

3338
## Next Load Specifications for Metacore
@@ -51,11 +56,11 @@ We will load are SDTM data from `{pharmaversesdtm}`. The main components of this
5156
#| label: Load Source
5257
# ---- Load source datasets ----
5358
# Load PC, EX, VS, LB and ADSL
54-
data("pc")
55-
data("ex")
56-
data("vs")
59+
ex <- pharmaversesdtm::ex
60+
pc <- pharmaversesdtm::pc
61+
vs <- pharmaversesdtm::vs
5762
58-
data("adsl")
63+
adsl <- pharmaverseadam::adsl
5964
6065
ex <- convert_blanks_to_na(ex)
6166
pc <- convert_blanks_to_na(pc)
@@ -100,6 +105,10 @@ pc_dates <- pc %>%
100105
)
101106
```
102107

108+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
109+
print_df(pc_dates %>% select(USUBJID, PCTEST, ADTM, VISIT, PCTPT, NFRLT))
110+
```
111+
103112
### Get Dosing Information
104113

105114
Here we also create nomimal time from first dose `NFRLT` for `EX` data based on `VISITDY`.
@@ -188,6 +197,12 @@ ex_exp <- ex_dates %>%
188197
derive_vars_dy(reference_date = TRTSDT, source_vars = exprs(ADT))
189198
```
190199

200+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
201+
print_df(
202+
ex_exp %>% select(USUBJID, DRUG, EXDOSFRQ, ASTDT, AVISIT, NFRLT)
203+
)
204+
```
205+
191206
### Find First Dose
192207

193208
In this section we will find the first dose for each subject and drug.
@@ -214,6 +229,12 @@ adpc_first_dose <- pc_dates %>%
214229
)
215230
```
216231

232+
233+
234+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
235+
print_df(adpc_first_dose %>% select(USUBJID, FANLDTM, NFRLT, ADTM, AVISITN, AVISIT, PCTPT))
236+
```
237+
217238
### Find Previous Dose and Next Dose
218239

219240
Use `derive_vars_joined()` to find the previous dose and the next dose.
@@ -292,6 +313,11 @@ adpc_nom_next <- adpc_nom_prev %>%
292313
)
293314
```
294315

316+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
317+
print_df(adpc_nom_prev %>% select(USUBJID, NFRLT, AVISIT, PCTPT, NFRLT_prev))
318+
```
319+
320+
295321
### Combine PC and EX Data
296322

297323
Combine `PC` and `EX` records and derive the additional relative time variables.
@@ -379,6 +405,12 @@ adpc_nrrlt <- adpc_arrlt %>%
379405
)
380406
```
381407

408+
409+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
410+
print_df(adpc_nrrlt %>% select(USUBJID, NFRLT, NRRLT, AVISIT, PCTPT))
411+
```
412+
413+
382414
### Derive Analysis Variables
383415

384416
Here we derive the analysis variables such as `AVAL` and `ATPTREF`.
@@ -479,6 +511,12 @@ dtype <- adpc_aval %>%
479511
derive_vars_dtm_to_tm(exprs(PCRFTDTM))
480512
```
481513

514+
515+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
516+
print_df(dtype %>% select(USUBJID, DTYPE, BASETYPE, ATPT, NFRLT, NRRLT, AFRLT, ARRLT))
517+
```
518+
519+
482520
### Combine Original and DTYPE Copy
483521

484522
Now the duplicated records are combined with the original records.
@@ -496,6 +534,10 @@ adpc_dtype <- bind_rows(adpc_aval, dtype) %>%
496534
)
497535
```
498536

537+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
538+
print_df(adpc_dtype %>% select(USUBJID, DTYPE, BASETYPE, ATPT, NFRLT, NRRLT, AFRLT, ARRLT))
539+
```
540+
499541
### Derive BASE and CHG
500542

501543
```{r}
@@ -563,6 +605,10 @@ adpc_baselines <- adpc_aseq %>%
563605
)
564606
```
565607

608+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
609+
print_df(adpc_baselines %>% select(USUBJID, HTBL, HTBLU, WTBL, WTBLU, BMIBL, BMIBLU, BASETYPE, ATPT, AVAL))
610+
```
611+
566612
### Combine with ADSL
567613

568614
If needed, the other `ADSL` variables can now be added:

adam/adppk.R

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ metacore <- spec_to_metacore("./metadata/pk_spec.xlsx") %>%
1919
## ----r------------------------------------------------------------------------
2020
# ---- Load source datasets ----
2121
# Load PC, EX, VS, LB and ADSL
22-
data("pc")
23-
data("ex")
24-
data("vs")
25-
data("lb")
2622

27-
data("adsl")
23+
ex <- pharmaversesdtm::ex
24+
pc <- pharmaversesdtm::pc
25+
vs <- pharmaversesdtm::vs
26+
lb <- pharmaversesdtm::lb
27+
28+
adsl <- pharmaverseadam::adsl
2829

2930
ex <- convert_blanks_to_na(ex)
3031
pc <- convert_blanks_to_na(pc)

adam/adppk.qmd

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ order: 3
44
---
55

66
```{r setup script, include=FALSE, purl=FALSE}
7-
invisible_hook_purl <- function(before, options, ...) {knitr::hook_purl(before, options, ...); NULL}
7+
invisible_hook_purl <- function(before, options, ...) {
8+
knitr::hook_purl(before, options, ...)
9+
NULL
10+
}
811
knitr::knit_hooks$set(purl = invisible_hook_purl)
12+
source("functions/print_df.R")
913
```
1014

1115
The Population PK Analysis Data (ADPPK) follows the CDISC Implementation Guide (<https://www.cdisc.org/standards/foundational/adam/basic-data-structure-adam-poppk-implementation-guide-v1-0>). Population PK models generally make use of nonlinear mixed effects models that require numeric variables. The data used in the models will include both dosing and concentration records, relative time variables, and numeric covariate variables. A `DV` or dependent variable is often expected. For more details see the `{admiral}` [vignette](https://pharmaverse.github.io/admiral/articles/pk_adnca.html){target="_blank"}.
@@ -51,12 +55,13 @@ We will load are SDTM data from `{pharmaversesdtm}`. The main components of this
5155
#| label: Load Source
5256
# ---- Load source datasets ----
5357
# Load PC, EX, VS, LB and ADSL
54-
data("pc")
55-
data("ex")
56-
data("vs")
57-
data("lb")
5858
59-
data("adsl")
59+
ex <- pharmaversesdtm::ex
60+
pc <- pharmaversesdtm::pc
61+
vs <- pharmaversesdtm::vs
62+
lb <- pharmaversesdtm::lb
63+
64+
adsl <- pharmaverseadam::adsl
6065
6166
ex <- convert_blanks_to_na(ex)
6267
pc <- convert_blanks_to_na(pc)
@@ -102,6 +107,11 @@ pc_dates <- pc %>%
102107
)
103108
```
104109

110+
111+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
112+
print_df(pc_dates %>% select(USUBJID, PCTEST, ADTM, VISIT, PCTPT, NFRLT))
113+
```
114+
105115
### Get Dosing Information
106116

107117
Here we also create nominal time from first dose `NFRLT` for `EX` data based on `VISITDY`.
@@ -150,6 +160,14 @@ ex_dates <- ex %>%
150160
derive_vars_dtm_to_dt(exprs(AENDTM))
151161
```
152162

163+
164+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
165+
print_df(ex_dates %>% select(
166+
USUBJID, EXTRT, EXDOSFRQ, EXSTDTC, EXENDTC, VISIT, VISITDY
167+
))
168+
```
169+
170+
153171
### Expand Dosing Records
154172

155173
Since there is a start date and end date for dosing records we need to expand the dosing records between the start date and end date using the function `admiral::create_single_dose_dataset()`.
@@ -190,6 +208,13 @@ ex_exp <- ex_dates %>%
190208
derive_vars_dtm_to_tm(exprs(AENDTM))
191209
```
192210

211+
212+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
213+
print_df(
214+
ex_exp %>% select(USUBJID, DRUG, EXDOSFRQ, ASTDT, AVISIT, NFRLT)
215+
)
216+
```
217+
193218
### Find First Dose
194219

195220
In this section we will find the first dose for each subject and drug.
@@ -218,6 +243,11 @@ adppk_first_dose <- pc_dates %>%
218243
)
219244
```
220245

246+
247+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
248+
print_df(adppk_first_dose %>% select(USUBJID, FANLDTM, NFRLT, ADTM, AVISITN, AVISIT, PCTPT))
249+
```
250+
221251
### Find Previous Dose
222252

223253
For `ADPPK` we will find the previous dose with respect to actual time and nominal time.
@@ -244,6 +274,11 @@ adppk_prev <- adppk_first_dose %>%
244274
)
245275
```
246276

277+
278+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
279+
print_df(adppk_prev %>% select(USUBJID, VISIT, ADTM, VISIT, PCTPT, ADTM_prev, AVISIT_prev))
280+
```
281+
247282
### Find Previous Nominal Dose
248283

249284
```{r}
@@ -264,6 +299,12 @@ adppk_nom_prev <- adppk_prev %>%
264299
)
265300
```
266301

302+
303+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
304+
print_df(adppk_nom_prev %>% select(USUBJID, VISIT, ADTM, NFRLT, NFRLT_prev))
305+
```
306+
307+
267308
### Combine PC and EX Data
268309

269310
Here we combine `PC` and `EX` records. We will derive the relative time variables `AFRLT` (Actual Relative Time from First Dose), `APRLT` (Actual Relative Time from Previous Dose), and `NPRLT` (Nominal Relative Time from Previous Dose).
@@ -314,6 +355,14 @@ adppk_aprlt <- bind_rows(adppk_nom_prev, ex_exp) %>%
314355
)
315356
```
316357

358+
359+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
360+
print_df(adppk_aprlt %>% select(USUBJID, FANLDTM, AVISIT, PCTPT, APRLT, NPRLT))
361+
```
362+
363+
364+
365+
317366
### Derive Analysis Variables
318367

319368
The expected analysis variable for `ADPPK` is `DV` or dependent variable. For this example `DV` is set to the numeric concentration value `PCSTRESN`. We will also include `AVAL` equivalent to `DV` for consistency with CDISC ADaM standards. `MDV` missing dependent variable will also be included.
@@ -391,6 +440,12 @@ adppk_aval <- adppk_aprlt %>%
391440
)
392441
```
393442

443+
444+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
445+
print_df(adppk_aval %>% select(USUBJID, AVISIT, EVID, NFRLT, DV))
446+
```
447+
448+
394449
### Add ASEQ
395450

396451
```{r}
@@ -447,6 +502,11 @@ covar <- adsl %>%
447502
create_var_from_codelist(metacore, input_var = SUBJTYPC, out_var = SUBJTYP)
448503
```
449504

505+
506+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
507+
print_df(covar %>% select(USUBJID, SEX, SEXN, RACE, RACEN))
508+
```
509+
450510
### Derive Additional Baselines
451511

452512
Next we add additional baselines from vital signs and laboratory data.
@@ -497,6 +557,13 @@ covar_vslb <- covar %>%
497557
rename(TBILBL = BILIBL)
498558
```
499559

560+
561+
562+
```{r eval=TRUE, echo=FALSE, purl=FALSE}
563+
print_df(covar_vslb %>% select(USUBJID, WTBL, HTBL, BMIBL, CRCLBL))
564+
```
565+
566+
500567
### Combine with Covariates
501568

502569
We combine our covariates with the rest of the data

adam/adrs.R

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@ metacore <- spec_to_metacore("./metadata/onco_spec.xlsx") %>%
1515
select_dataset("ADRS")
1616

1717
## ----r load-data--------------------------------------------------------------
18-
data("adsl")
19-
data("rs_onco_recist")
20-
data("tu_onco_recist")
21-
22-
rs <- rs_onco_recist
23-
tu <- tu_onco_recist
18+
adsl <- pharmaverseadam::adsl
19+
rs <- pharmaversesdtm::rs_onco_recist
20+
tu <- pharmaversesdtm::tu_onco_recist
2421

2522
# Convert blanks to NA
2623
rs <- convert_blanks_to_na(rs)

0 commit comments

Comments
 (0)