/
adrs_basic.Rmd
862 lines (747 loc) · 24.9 KB
/
adrs_basic.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
---
title: "Creating a Basic ADRS"
output:
rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Creating a Basic ADRS}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
library(admiraldev)
```
# Introduction
This article describes creating an `ADRS` ADaM with common oncology
endpoint parameters based on RECIST v1.1. Therefore response values are
expected as either `CR`, `PR`, `SD`, `NON-CR/NON-PD`, `PD` or `NE`.
Please note that this vignette describes the endpoints which were considered by
the admiralonco team as the most common ones. The admiralonco functions used to
derive these endpoints provide a certain flexibility, e.g., specifying the
reference date or time windows for confirmation or stable disease. If different
endpoints or more flexibility is required please read [Creating ADRS (Including
Non-standard Endpoints)](adrs.html).
Examples are currently presented and tested using `ADSL` (ADaM) and
`RS`, `TU` (SDTM) inputs. However, other domains could be used. The
functions and workflow could similarly be used to create an intermediary
`ADEVENT` ADaM.
**Note**: *All examples assume CDISC SDTM and/or ADaM format as input
unless otherwise specified.*
# Programming Workflow
- [Read in Data](#readdata)
- [Pre-processing of Input Records](#input)
- [Derive Progressive Disease Parameter](#pd)
- [Derive Response Parameter](#rsp)
- [Derive Clinical Benefit Parameter](#cb)
- [Derive Best Overall Response Parameter](#bor)
- [Derive Best Overall Response of CR/PR Parameter](#bcp)
- [Derive Response Parameters requiring Confirmation](#confirm)
- [Derive Parameters using Independent Review Facility (IRF)/
Blinded Independent Central Review (BICR) responses](#irf)
- [Derive Death Parameter](#death)
- [Derive Last Disease Assessment Parameters](#lsta)
- [Derive Measurable Disease at Baseline Parameter](#mdis)
- [Derive `AVAL` for New Parameters](#aval)
- [Assign `ASEQ`](#aseq)
- [Add ADSL variables](#adsl_vars)
## Read in Data {#readdata}
To start, all data frames needed for the creation of `ADRS` should be
read into the environment. This will be a company specific process. Some
of the data frames needed may be `ADSL`, `RS` and `TU`.
For example purpose, the SDTM and ADaM datasets (based on CDISC Pilot test
data)---which are included in `{pharmaversesdtm}` and `{pharmaverseadam}`---are
used.
```{r message=FALSE}
library(admiral)
library(admiralonco)
library(dplyr)
library(pharmaversesdtm)
library(pharmaverseadam)
library(lubridate)
library(stringr)
data("adsl")
data("rs_onco_recist")
data("tu_onco_recist")
rs <- rs_onco_recist
tu <- tu_onco_recist
rs <- convert_blanks_to_na(rs)
tu <- convert_blanks_to_na(tu)
```
```{r echo=FALSE}
# select subjects from adsl such that there is one subject without RS data
rs_subjects <- unique(rs$USUBJID)
adsl_subjects <- unique(adsl$USUBJID)
adsl <- filter(
adsl,
USUBJID %in% union(rs_subjects, setdiff(adsl_subjects, rs_subjects)[1])
)
```
At this step, it may be useful to join `ADSL` to your `RS` domain. Only
the `ADSL` variables used for derivations are selected at this step. The
rest of the relevant `ADSL` would be added later.
```{r eval=TRUE}
adsl_vars <- exprs(RANDDT)
adrs <- derive_vars_merged(
rs,
dataset_add = adsl,
new_vars = adsl_vars,
by_vars = exprs(STUDYID, USUBJID)
)
```
```{r, eval=TRUE, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, RSTESTCD, RSDTC, VISIT, RANDDT),
filter = RSTESTCD == "OVRLRESP"
)
```
## Pre-processing of Input Records {#input}
The first step involves company-specific pre-processing of records for
the required input to the downstream parameter functions. Note that this
could be needed multiple times (e.g. once for investigator and once for
Independent Review Facility (IRF)/Blinded Independent Central Review
(BICR) records). It could even involve merging input data from other
sources besides `RS`, such as `ADTR`.
This step would include any required selection/derivation of `ADT` or
applying any necessary partial date imputations, updating `AVAL` (e.g.
this should be ordered from best to worst response), and setting
analysis flag `ANL01FL`. Common options for `ANL01FL` would be to set
null for invalid assessments or those occurring after new anti-cancer
therapy, or to only flag assessments on or after after date of first
treatment/randomization, or rules to cover the case when a patient has
multiple observations per visit (e.g. by selecting worst value). Another
consideration could be extra potential protocol-specific sources of
Progressive Disease such as radiological assessments, which could be
pre-processed here to create a PD record to feed downstream derivations.
For the derivation of the parameters it is expected that the subject
identifier variables (usually `STUDYID` and `USUBJID`) and `ADT` are a
unique key. This can be achieved by deriving an analysis flag
(`ANLzzFL`). See [Derive `ANL01FL`](#anl01fl) for an example.
The below shows an example of a possible company-specific implementation
of this step.
### Select Overall Response Records and Set Parameter Details
In this case we use the overall response records from `RS` from the
investigator as our starting point. The parameter details such as
`PARAMCD`, `PARAM` etc will always be company-specific, but an example
is shown below so that you can trace through how these records feed into
the other parameter derivations.
```{r}
adrs <- adrs %>%
filter(RSEVAL == "INVESTIGATOR" & RSTESTCD == "OVRLRESP") %>%
mutate(
PARAMCD = "OVR",
PARAM = "Overall Response by Investigator",
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "RECIST 1.1"
)
```
```{r, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, VISIT, RSTESTCD, RSEVAL, PARAMCD, PARAM, PARCAT1, PARCAT2, PARCAT3)
)
```
### Partial Date Imputation and Deriving `ADT`, `ADTF`, `AVISIT` etc
If your data collection allows for partial dates, you could apply a
company-specific imputation rule at this stage when deriving `ADT`. For
this example, here we impute missing day to last possible date.
```{r}
adrs <- adrs %>%
derive_vars_dt(
dtc = RSDTC,
new_vars_prefix = "A",
highest_imputation = "D",
date_imputation = "last"
) %>%
mutate(AVISIT = VISIT)
```
```{r, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, AVISIT, PARAMCD, PARAM, RSSTRESC, RSDTC, ADT, ADTF)
)
```
### Derive `AVALC` and `AVAL`
Here we populate `AVALC` and create the numeric version as `AVAL`
(ordered from best to worst response). This ordering is already covered
within our RECIST v1.1 parameter derivation functions, and so changing
`AVAL` here would not change the result of those derivations.
```{r}
adrs <- adrs %>%
mutate(
AVALC = RSSTRESC,
AVAL = aval_resp(AVALC)
)
```
```{r, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, AVISIT, PARAMCD, PARAM, RSSTRESC, AVALC, AVAL)
)
```
### Flag Worst Assessment at Each Date (`ANL01FL`) {#anl01fl}
When deriving `ANL01FL` this is an opportunity to exclude any records
that should not contribute to any downstream parameter derivations. In
the below example this includes only selecting valid assessments and
those occurring on or after randomization date. If there is more than
one assessment at a date, the worst one is flagged.
```{r}
worst_resp <- function(arg) {
case_when(
arg == "NE" ~ 1,
arg == "CR" ~ 2,
arg == "PR" ~ 3,
arg == "SD" ~ 4,
arg == "NON-CR/NON-PD" ~ 5,
arg == "PD" ~ 6,
TRUE ~ 0
)
}
adrs <- adrs %>%
restrict_derivation(
derivation = derive_var_extreme_flag,
args = params(
by_vars = exprs(STUDYID, USUBJID, ADT),
order = exprs(worst_resp(AVALC), RSSEQ),
new_var = ANL01FL,
mode = "last"
),
filter = !is.na(AVAL) & ADT >= RANDDT
)
```
```{r, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, AVISIT, PARAMCD, PARAM, AVALC, ADT, RANDDT, ANL01FL)
)
```
Here is an alternative example where those records occurring after new
anti-cancer therapy are additionally excluded (where `NACTDT` would be
pre-derived as first date of new anti-cancer therapy. See `{admiralonco}` [Creating and Using New Anti-Cancer Start Date](nactdt.html) for deriving this variable).
```{r, eval=FALSE}
adrs <- adrs %>%
mutate(
ANL01FL = case_when(
!is.na(AVAL) & ADT >= RANDDT & ADT < NACTDT ~ "Y",
TRUE ~ NA_character_
)
)
```
Note here that we don't filter out records after first `PD` at this
stage, as that is specifically catered for in the `{admiralonco}`
parameter derivation functions in the below steps, via `source_pd`
arguments.
### Flag Assessments up to First PD (`ANL02FL`) {#anl02fl}
However, if you prefer not to rely on `source_pd` arguments,
then the user is free to filter out records after first `PD` at this
stage in a similar way via a `ANLzzFL` flag, and then you could leave
`source_pd` as null in all downstream parameter derivation function
calls. So, for example the user could create `ANL02FL` flag to subset
the post-baseline response data up to and including first reported
progressive disease. This would be an alternative and transparent method
to the use of `source_pd` argument approach to create ADRS parameters
below. Using `{admiral}` function `admiral::derive_var_relative_flag()`
we could create `ANL02FL` as below.
```{r, eval=FALSE}
adrs <- adrs %>%
derive_var_relative_flag(
by_vars = exprs(STUDYID, USUBJID),
order = exprs(ADT, RSSEQ),
new_var = ANL02FL,
condition = AVALC == "PD",
mode = "first",
selection = "before",
inclusive = TRUE
)
```
## Derive Progressive Disease Parameter {#pd}
Now that we have the input records prepared above with any
company-specific requirements, we can start to derive new parameter
records. For the parameter derivations, all values except those
overwritten by `set_values_to` argument are kept from the earliest
occurring input record fulfilling the required criteria.
The function `admiral::derive_extreme_records()` can be used to find
the date of first `PD`.
```{r}
adrs <- adrs %>%
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
filter_add = PARAMCD == "OVR" & AVALC == "PD" & ANL01FL == "Y",
order = exprs(ADT, RSSEQ),
mode = "first",
exist_flag = AVALC,
false_value = "N",
set_values_to = exprs(
PARAMCD = "PD",
PARAM = "Disease Progression by Investigator",
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "RECIST 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)
```
```{r, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, AVISIT, PARAMCD, PARAM, AVALC, ADT, ANL01FL),
filter = PARAMCD == "PD"
)
```
For progressive disease, response and death parameters shown in steps
here and below, in our examples we show these as `ADRS` parameters, but
they could equally be achieved via `ADSL` dates or `ADEVENT` parameters.
If you prefer to store as an ADSL date, then the function
`admiral::derive_var_extreme_dt()` could be used to find the date of
first `PD` as a variable, rather than as a new parameter record. All the
parameter derivation functions that use these dates are flexible to
allow sourcing these from any input source using
`admiral::date_source()`. See examples below.
## Derive Response Parameter {#rsp}
The next required step is to define the source location for this newly
derived `PD` date.
```{r}
pd <- date_source(
dataset_name = "adrs",
date = ADT,
filter = PARAMCD == "PD" & AVALC == "Y"
)
```
An equivalent example if using `ADSL` instead could be as follows (where
`PDDT` would be pre-derived as first date of progressive disease).
```{r, eval=FALSE}
pd <- date_source(
dataset_name = "adsl",
date = PDDT
)
```
The function `derive_param_response()` can then be used to find the date of
first response. This differs from the `admiral::derive_extreme_records()`
function in that it only looks for events occurring prior to first `PD`. In the
below example, the response condition has been defined as `CR` or `PR`.
```{r}
adrs <- adrs %>%
derive_param_response(
dataset_adsl = adsl,
filter_source = PARAMCD == "OVR" & AVALC %in% c("CR", "PR") & ANL01FL == "Y",
source_pd = pd,
source_datasets = list(adrs = adrs),
set_values_to = exprs(
PARAMCD = "RSP",
PARAM = "Response by Investigator (confirmation not required)",
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "RECIST 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)
```
```{r, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, AVISIT, PARAMCD, PARAM, AVALC, ADT, ANL01FL),
filter = PARAMCD == "RSP"
)
```
## Derive Clinical Benefit Parameter {#cb}
Similarly, we now define the source location for this newly derived
first response date.
```{r}
resp <- date_source(
dataset_name = "adrs",
date = ADT,
filter = PARAMCD == "RSP" & AVALC == "Y"
)
```
The function `derive_param_clinbenefit()` can then be used to derive the
clinical benefit parameter, which we define as a patient having had a
response or a sustained period of time before first `PD`. This could
also be known as disease control. In this example the "sustained period"
has been defined as 42 days after randomization date, using the
`ref_start_window` argument.
```{r}
adrs <- adrs %>%
derive_param_clinbenefit(
dataset_adsl = adsl,
filter_source = PARAMCD == "OVR" & ANL01FL == "Y",
source_resp = resp,
source_pd = pd,
source_datasets = list(adrs = adrs),
reference_date = RANDDT,
ref_start_window = 42,
set_values_to = exprs(
PARAMCD = "CB",
PARAM = "Clinical Benefit by Investigator (confirmation for response not required)",
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "RECIST 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)
```
```{r, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, AVISIT, PARAMCD, PARAM, AVALC, ADT, RANDDT, ANL01FL),
filter = PARAMCD == "CB"
)
```
## Derive Best Overall Response Parameter {#bor}
The function `derive_param_bor()` can be used to derive the best overall
response (without confirmation required) parameter. Similar to the above
function you can optionally decide what period would you consider a `SD`
or `NON-CR/NON-PD` as being eligible from. In this example, 42 days
after randomization date has been used again.
```{r}
adrs <- adrs %>%
derive_param_bor(
dataset_adsl = adsl,
filter_source = PARAMCD == "OVR" & ANL01FL == "Y",
source_pd = pd,
source_datasets = list(adrs = adrs),
reference_date = RANDDT,
ref_start_window = 42,
set_values_to = exprs(
PARAMCD = "BOR",
PARAM = "Best Overall Response by Investigator (confirmation not required)",
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "RECIST 1.1",
AVAL = aval_resp(AVALC),
ANL01FL = "Y"
)
)
```
```{r, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, AVISIT, PARAMCD, PARAM, AVALC, ADT, RANDDT, ANL01FL),
filter = PARAMCD == "BOR"
)
```
Note that the above gives pre-defined `AVAL` values (defined by `aval_resp()`)
of: `"CR" ~ 1`, `"PR" ~ 2`, `"SD" ~ 3`, `"NON-CR/NON-PD" ~ 4`, `"PD" ~ 5`, `"NE"
~ 6`, `"MISSING" ~ 7`.
If you'd like to provide your own company-specific ordering here you
could do this as follows:
```{r, eval=FALSE}
aval_resp_new <- function(arg) {
case_when(
arg == "CR" ~ 7,
arg == "PR" ~ 6,
arg == "SD" ~ 5,
arg == "NON-CR/NON-PD" ~ 4,
arg == "PD" ~ 3,
arg == "NE" ~ 2,
arg == "MISSING" ~ 1,
TRUE ~ NA_real_
)
}
```
Then update the definition of `AVAL` in the `set_values_to` argument of the
above `derive_param_bor()` call. Be aware that this will only impact the `AVAL`
mapping, not the derivation of BOR in any way - as the function derivation
relies only on `AVALC` here.
## Derive Best Overall Response of CR/PR Parameter {#bcp}
The function `admiral::derive_extreme_records()` can be used to check if a
patient had a response for BOR.
```{r}
adrs <- adrs %>%
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
filter_add = PARAMCD == "BOR" & AVALC %in% c("CR", "PR"),
order = exprs(ADT, RSSEQ),
mode = "first",
exist_flag = AVALC,
false_value = "N",
set_values_to = exprs(
PARAMCD = "BCP",
PARAM = "Best Overall Response of CR/PR by Investigator (confirmation not required)",
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "RECIST 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)
```
```{r, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, AVISIT, PARAMCD, PARAM, AVALC, ADT, ANL01FL),
filter = PARAMCD == "BCP"
)
```
## Derive Response Parameters requiring Confirmation {#confirm}
Any of the above response parameters can be repeated for "confirmed"
responses only. For these the functions `derive_param_confirmed_resp()`
and `derive_param_confirmed_bor()` can be used. Some of the other
functions from above can then be re-used passing in these confirmed
response records. See the examples below of derived parameters requiring
confirmation. The assessment and the confirmatory assessment here need
to occur at least 28 days apart *(without any +1 applied to this
calculation of days between visits)*, using the `ref_confirm` argument.
```{r}
adrs <- adrs %>%
derive_param_confirmed_resp(
dataset_adsl = adsl,
filter_source = PARAMCD == "OVR" & ANL01FL == "Y",
source_pd = pd,
source_datasets = list(adrs = adrs),
ref_confirm = 28,
set_values_to = exprs(
PARAMCD = "CRSP",
PARAM = "Confirmed Response by Investigator",
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "RECIST 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)
confirmed_resp <- date_source(
dataset_name = "adrs",
date = ADT,
filter = PARAMCD == "CRSP" & AVALC == "Y"
)
adrs <- adrs %>%
derive_param_clinbenefit(
dataset_adsl = adsl,
filter_source = PARAMCD == "OVR" & ANL01FL == "Y",
source_resp = confirmed_resp,
source_pd = pd,
source_datasets = list(adrs = adrs),
reference_date = RANDDT,
ref_start_window = 42,
set_values_to = exprs(
PARAMCD = "CCB",
PARAM = "Confirmed Clinical Benefit by Investigator",
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "RECIST 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
) %>%
derive_param_confirmed_bor(
dataset_adsl = adsl,
filter_source = PARAMCD == "OVR" & ANL01FL == "Y",
source_pd = pd,
source_datasets = list(adrs = adrs),
reference_date = RANDDT,
ref_start_window = 42,
ref_confirm = 28,
set_values_to = exprs(
PARAMCD = "CBOR",
PARAM = "Best Confirmed Overall Response by Investigator",
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "RECIST 1.1",
AVAL = aval_resp(AVALC),
ANL01FL = "Y"
)
) %>%
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
filter_add = PARAMCD == "CBOR" & AVALC %in% c("CR", "PR"),
order = exprs(ADT, RSSEQ),
mode = "first",
exist_flag = AVALC,
false_value = "N",
set_values_to = exprs(
PARAMCD = "CBCP",
PARAM = "Best Confirmed Overall Response of CR/PR by Investigator",
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "RECIST 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)
```
```{r, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, AVISIT, PARAMCD, PARAM, AVALC, ADT, RANDDT, ANL01FL),
filter = PARAMCD %in% c("CRSP", "CCB", "CBOR", "CBCP")
)
```
## Derive Parameters using Independent Review Facility (IRF)/Blinded Independent Central Review (BICR) responses {#irf}
All of the above steps can be repeated for different sets of records,
such as now using assessments from the IRF/BICR
instead of investigator. For this you would just need to replace the
first steps with selecting the required records, and then feed these as
input to the downstream parameter functions.
Remember that a new progressive disease and response source object would
be required for passing to `source_pd` and `source_resp` respectively.
```{r}
adrs_bicr <- rs %>%
filter(
RSEVAL == "INDEPENDENT ASSESSOR" & RSACPTFL == "Y" & RSTESTCD == "OVRLRESP"
) %>%
mutate(
PARAMCD = "OVRB",
PARAM = "Overall Response by BICR",
PARCAT1 = "Tumor Response",
PARCAT2 = "Blinded Independent Central Review",
PARCAT3 = "RECIST 1.1"
)
```
```{r, echo=FALSE}
dataset_vignette(
adrs_bicr,
display_vars = exprs(USUBJID, VISIT, RSTESTCD, RSEVAL, PARAMCD, PARAM, PARCAT1, PARCAT2, PARCAT3),
filter = PARAMCD == "OVRR1"
)
```
Then in all the calls to the parameter derivation functions you would
replace the `PARAMCD == "OVR"` source with `PARAMCD == "OVRR1"`.
## Derive Death Parameter {#death}
The function `admiral::derive_extreme_records()` can be used to create
a new death parameter using death date from `ADSL`. We need to restrict
the columns from `ADSL` as we'll merge all required variables later
across all our `ADRS` records.
```{r}
adsldth <- adsl %>%
select(STUDYID, USUBJID, DTHDT, !!!adsl_vars)
adrs <- adrs %>%
derive_extreme_records(
dataset_ref = adsldth,
dataset_add = adsldth,
by_vars = exprs(STUDYID, USUBJID),
filter_add = !is.na(DTHDT),
exist_flag = AVALC,
false_value = "N",
set_values_to = exprs(
PARAMCD = "DEATH",
PARAM = "Death",
PARCAT1 = "Reference Event",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y",
ADT = DTHDT
)
) %>%
select(-DTHDT)
```
```{r, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, AVISIT, PARAMCD, PARAM, AVALC, ADT, ANL01FL),
filter = PARAMCD == "DEATH"
)
```
## Derive Last Disease Assessment Parameters {#lsta}
The function `admiral::derive_extreme_records()` can be used to create a
parameter for last disease assessment.
```{r}
adrs <- adrs %>%
derive_extreme_records(
dataset_ref = adsl,
dataset_add = adrs,
by_vars = exprs(STUDYID, USUBJID),
filter_add = PARAMCD == "OVR" & ANL01FL == "Y",
order = exprs(ADT, RSSEQ),
mode = "last",
set_values_to = exprs(
PARAMCD = "LSTA",
PARAM = "Last Disease Assessment by Investigator",
PARCAT1 = "Tumor Response",
PARCAT2 = "Investigator",
PARCAT3 = "RECIST 1.1",
ANL01FL = "Y"
)
)
```
```{r, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, AVISIT, PARAMCD, PARAM, AVALC, ADT, ANL01FL),
filter = PARAMCD == "LSTA"
)
```
## Derive Measurable Disease at Baseline Parameter {#mdis}
The function `admiral::derive_param_exist_flag()` can be used to check
whether a patient has measurable disease at baseline, according to a
company-specific condition. In this example we check `TU` for target
lesions during the baseline visit. We need to restrict the columns from
`ADSL` as we'll merge all required variables later across all our `ADRS`
records.
```{r}
adslmdis <- adsl %>%
select(STUDYID, USUBJID, !!!adsl_vars)
adrs <- adrs %>%
derive_param_exist_flag(
dataset_ref = adslmdis,
dataset_add = tu,
condition = TUEVAL == "INVESTIGATOR" & TUSTRESC == "TARGET" & VISIT == "SCREENING",
false_value = "N",
missing_value = "N",
set_values_to = exprs(
PARAMCD = "MDIS",
PARAM = "Measurable Disease at Baseline by Investigator",
PARCAT2 = "Investigator",
PARCAT3 = "RECIST 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)
```
```{r, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, AVISIT, PARAMCD, PARAM, AVALC, ADT, ANL01FL),
filter = PARAMCD == "MDIS"
)
```
## Assign `ASEQ` {#aseq}
The function `admiral::derive_var_obs_number()` can be used to derive
`ASEQ`. An example call is:
```{r eval=TRUE}
adrs <- adrs %>%
derive_var_obs_number(
by_vars = exprs(STUDYID, USUBJID),
order = exprs(PARAMCD, ADT, VISITNUM, RSSEQ),
check_type = "error"
)
```
```{r, eval=TRUE, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, PARAMCD, ADT, VISITNUM, AVISIT, ASEQ),
filter = USUBJID == "01-701-1015"
)
```
## Add ADSL variables {#adsl_vars}
If needed, the other `ADSL` variables can now be added. List of ADSL
variables already merged held in vector `adsl_vars`.
```{r eval=TRUE}
adrs <- adrs %>%
derive_vars_merged(
dataset_add = select(adsl, !!!negate_vars(adsl_vars)),
by_vars = exprs(STUDYID, USUBJID)
)
```
```{r, eval=TRUE, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, RFSTDTC, RFENDTC, DTHDTC, DTHFL, AGE, AGEU),
filter = USUBJID == "01-701-1015"
)
```
# Example Script {#example}
ADaM | Sample Code
---- | --------------
ADRS_BASIC | `admiral::use_ad_template("ADRS_BASIC", package = "admiralonco")`