-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchevron_catalog.rmd
More file actions
1502 lines (1046 loc) · 63.6 KB
/
Copy pathchevron_catalog.rmd
File metadata and controls
1502 lines (1046 loc) · 63.6 KB
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
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "Chevron Catalog"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Chevron Catalog}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
editor_options:
chunk_output_type: console
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
library(dplyr)
library(dunlin)
library(chevron)
```
## **GENERAL**
### **General Concepts**
`chevron` is a collection of functions to creates tables, listings, and graphs following Roche standards for clinical trials reporting. After loading the R packages and the trial data, the output is to be created by the main function `run(...)` . Two arguments `object=` and `adam_db=` are always expected in the function. `object=` specifies which Roche Standard Template ID to use. `adam_db=` specifies the input dataset. Other mandatory and optional arguments within the `run` function vary depending on which template ID is called. To access which arguments are required and what functions are used in each template, simply try `?template` (e.g. `?aet01`) to see more detailed descriptions and instructions.
#### **1. Input dataset and dataset names**
The input dataset expected by the argument `adam_db=` in the `run(...)` function is a collection of `ADaM` datasets as a list object. Each `ADaM` dataset is expected to be an object of data frame. If the `ADaM` datasets are read in individually, user will need to combine them into a list object and provide the name of the list to `adam_db=`. Also, each element in the list are expected to have corresponding `ADaM` dataset names. Conventional `ADaM` dataset names, including `adsl`,`adex`, `adae`, `adlb`,`advs`,`adeg`,`adcm`,`admh`,`adrs`, and `adtte`, can be picked up by `chevron` with one exception.
```{r eval=FALSE}
std_data <- list(adsl = adsl, adae = adae)
run(object = aet01_nollt, adam_db = std_data)
```
#### **2. Expected variables in input analysis dataset**
By default, `chevron` does not pull any subject-level information from either `adsl` or `adsub` and merge into the analysis dataset in the underlying preprocessing steps. The analysis dataset fed into `adam_db=` is expected to have all variables required for analysis available.
#### **3. Character vs Factor**
In the output generation, we often need to specify a particular sorting order of a variable at the time of display. In `chevron`, a character variable needs to be factorized with pre-specified levels to display in order. When encountering cases, for instance, `"ARM A"` has an Asian group only while `"ARM B"` has both Asian and White groups, it is not able to produce outputs like the demographic table unless `"RACE"` is factorized to provide access to the same level attribute of the variable `"RACE"` after the arm split. It is noted that the feature comes from `rtables` instead of `chevron`.
```{r}
proc_data <- syn_data
proc_data$adsl <- proc_data$adsl %>%
mutate(RACE = case_when(
ARMCD == "ARM A" ~ "ASIAN",
ARMCD == "ARM B" & !.data$RACE %in% c("WHITE", "ASIAN") ~ "ASIAN",
TRUE ~ RACE
))
```
Having `"RACE"` as a character variable rather than a factor leads to error message showing up as "Error: Error applying analysis function (var - RACE): Number of rows generated by analysis function do not match across all columns," and it is recommended to convert analysis variable `"RACE"` to a factor.
```{r eval=FALSE}
run(dmt01, proc_data)
```
To resolve this issue, simply try factorizing the variable `"RACE"`:
```{r}
proc_data$adsl$RACE <- as.factor(proc_data$adsl$RACE)
run(dmt01, proc_data)
```
#### **4. Testing the codes for plot generation**
The `run` function when calling a Graphics Template ID returns a `gTree` object which will be used in the downstream workflow for output generation. There are two alternative approaches to rendering the plot: (1) having `draw = TRUE` in the `run` function to enable the generated plot to be automatically created and viewed via the `Plots` tab, and (2) calling the function `grid.draw` from the package `grid` which can be utilized to render the plot for viewing and testing purpose. See example below:
```{r eval=FALSE}
proc_data <- log_filter(syn_data, PARAMCD == "OS", "adtte")
# method 1
run(kmg01, proc_data, dataset = "adtte", draw = TRUE)
# method 2
res <- run(kmg01, proc_data, dataset = "adtte")
grid::grid.newpage()
grid::grid.draw(res)
```
### **General Control Arguments**
#### **1. `lbl_overall`: Column of Total**
The generic argument `lbl_overall` controls whether the column of total will be produced or not. `lbl_overall = NULL` suppresses the total, `lbl_overall = "All Patients"` produces the total.
#### **2. Column counts: N=xxx**
Column counts are displayed by default. There is no generic argument controlling whether the count of unique number of subjects (N=xxx) will be displayed in the column header or not. Users are allowed to customize the display of N=xxx by forcing `display_columncounts = FALSE` to wipe column counts away during the postprocessing (with precautions and it is not recommended).
```{r}
tbl <- run(dmt01, syn_data) # table with column counts
tbl@col_info@display_columncounts <- FALSE
tbl # no column counts now
```
## **TABLES**
### **Safety Summary (`AET01`)**
#### **1. Safety Summary**
The **`aet01`** template produces the standard safety summary.
```{r}
run(aet01, syn_data, arm_var = "ARM")
```
#### **2. Safety Summary with Modified Rows**
Analyses under "Total number of patients with at least one" can be removed, added, or modified by editing the parameter `anl_vars`. An analysis here is an abbreviated name of the analysis of interest, and supported by a variable in `ADAE` derived under the condition of interest. The defined analyses currently include `"FATAL"`, `"SER"`, `"SERWD"`, `"SERDSM"`, `"RELSER"`, `"WD"`, `"DSM"`, `"REL"`, `"RELWD"`, `"RELDSM"`, and `"SEV"`. When modification is made, analyses must all be listed in the argument `anl_vars`. The example below shows adding the customized analysis `"RELCTC35"`.
```{r}
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
filter(.data$ANL01FL == "Y") %>%
mutate(
FATAL = with_label(.data$AESDTH == "Y", "AE with fatal outcome"),
SER = with_label(.data$AESER == "Y", "Serious AE"),
SEV = with_label(.data$ASEV == "SEVERE", "Severe AE (at greatest intensity)"),
REL = with_label(.data$AREL == "Y", "Related AE"),
WD = with_label(.data$AEACN == "DRUG WITHDRAWN", "AE leading to withdrawal from treatment"),
DSM = with_label(
.data$AEACN %in% c("DRUG INTERRUPTED", "DOSE INCREASED", "DOSE REDUCED"),
"AE leading to dose modification/interruption"
),
SERWD = with_label(.data$SER & .data$WD, "Serious AE leading to withdrawal from treatment"),
SERDSM = with_label(.data$SER & .data$DSM, "Serious AE leading to dose modification/interruption"),
RELSER = with_label(.data$SER & .data$REL, "Related Serious AE"),
RELWD = with_label(.data$REL & .data$WD, "Related AE leading to withdrawal from treatment"),
RELDSM = with_label(.data$REL & .data$DSM, "Related AE leading to dose modification/interruption"),
CTC35 = with_label(.data$ATOXGR %in% c("3", "4", "5"), "Grade 3-5 AE"),
CTC45 = with_label(.data$ATOXGR %in% c("4", "5"), "Grade 4/5 AE"),
RELCTC35 = with_label(.data$ATOXGR %in% c("3", "4", "5") & .data$AEREL == "Y", "Related Grade 3-5")
)
proc_data$adsl <- proc_data$adsl %>%
mutate(DCSREAS = reformat(.data$DCSREAS, missing_rule))
run(aet01, proc_data, anl_vars = list(safety_var = c("FATAL", "SER", "RELSER", "RELCTC35")), auto_pre = FALSE)
```
### **Safety Summary (Adverse Events of Special Interest) (`AET01_AESI`)**
#### **1. Safety Summary (Adverse Events of Special Interest)**
The **`aet01_aesi`** template produces the standard safety summary for adverse events of special interest.
```{r}
run(aet01_aesi, syn_data)
```
#### **2. Safety Summary (Adverse Events of Special Interest) (optional lines)**
Additional analyses can be added with the argument `aesi_vars`, please type `?aet01_aesi` in console to find out the list of all pre-defined optional analyses in the HELP.
```{r}
run(aet01_aesi, syn_data, aesi_vars = c("RESLWD", "RELSER"))
```
#### **3. Safety Summary (Adverse Events of Special Interest) (for studies with multiple drugs)**
For studies with more than one study drug, users need to define the analyses in `adae` and add to the argument `aesi_vars` following the example above. No pre-defined analysis is available at this moment.
### **Adverse Events (`AET02`)**
#### **1. Adverse Events**
1) The template `aet02` produces the standard adverse event summary by MedDRA system organ class and preferred term.
2) The template does not include the column of total as default. The 'All Patients' column can be added with the argument `lbl_overall = "All Patients"`.
3) Missing values in `"AEBODSYS"`, and `"AEDECOD"` are labeled as `No Coding Available`.
```{r}
run(aet02, syn_data)
```
#### **2. Adverse Events (with High-level Term)**
The syntax below displays adverse events by MedDRA system organ class, high-level term and preferred term.
```{r}
run(aet02, syn_data, row_split_var = c("AEBODSYS", "AEHLT"))
```
#### **3. Adverse Events (Preferred Terms only)**
The syntax below displays adverse events by preferred term only.
```{r}
run(aet02, syn_data, row_split_var = NULL)
```
### **Adverse Events by Greatest Intensity(`AET03`)**
#### **1. Adverse Events by Greatest Intensity**
This **`aet03`** template produces the standard adverse event by greatest intensity summary
```{r}
run(aet03, syn_data)
```
### **Adverse Events by Highest `NCI CTCAE` Grade (`AET04`)**
#### **1. Adverse Events by Highest `NCI CTCAE` Grade**
1) The **`aet04`** template produces the standard adverse event by highest `NCI CTCAE` grade summary.
2) By default, this template includes the grouped grades of 'Grade 1-2' and 'Grade 3-4'.
3) By default this template removes the rows with 0 count.
4) If a treatment group does not have any adverse event, the treatment group is automatically displayed providing that it is defined in `ADSL`.
```{r}
run(aet04, syn_data)
```
#### **2. Adverse Events by Highest `NCI CTCAE` Grade (Fill in of Grades)**
If, for some preferred terms, not all grades occur but all grades should be displayed, this can be achieved by specifying the argument `prune_0 = FALSE`.
```{r}
run(aet04, syn_data, prune_0 = FALSE)
```
#### **3. Adverse Events by Highest `NCI CTCAE` Grade with modified grouping of grade**
Collapsing grade 3-4 with grade 5, can be achieved by modifying the definition of grade groups in the argument `grade_groups`.
```{r}
grade_groups <- list(
"Grade 1-2" = c("1", "2"),
"Grade 3-5" = c("3", "4", "5")
)
run(aet04, syn_data, grade_groups = grade_groups, prune_0 = FALSE)
```
### **Adverse Event Rate Adjusted for Patient-Years at Risk - First Occurrence (`AET05`)**
#### **1. Adverse Event Rate Adjusted for Patient-Years at Risk - First Occurrence**
1) The **`aet05`** template produces the standard adverse event rate adjusted for patient-years at risk summary considering first occurrence only.
2) By default, all `adsaftte` parameter codes containing the string `"TTE"` are included in the output. Users are expected to filter the parameter(s) of interest from input safety time-to-event dataset in pre-processing if needed.
3) In the input safety time-to-event dataset, in the censoring variable `CNSR`, `0` indicates the occurrence of an event of interest and `1` denotes censoring.
```{r}
proc_data <- log_filter(syn_data, PARAMCD == "AETTE1", "adsaftte")
run(aet05, proc_data)
```
#### **2. Adverse Event Rate Adjusted for Patient-Years at Risk - First Occurrence (setting type of confidence interval)**
1) The type of the confidence interval for rate can be specified by the argument `conf_type`. Options include `normal` (default), `normal_log` and `exact`.
2) The confidence interval can be adjusted by the argument `conf_level`.
```{r}
run(aet05, syn_data, conf_level = 0.90, conf_type = "exact")
```
### **Adverse Event Rate Adjusted for Patient-Years at Risk - All Occurrences (`AET05_ALL`)**
#### **1. Adverse Event Rate Adjusted for Patient-Years at Risk - All Occurrences**
1) The **`aet05_all`** template produces the standard adverse event rate adjusted for patient-years at risk summary considering all occurrences.
2) By default, all `adsaftte` parameter codes containing the string `"TOT"` and the parameter code `"AEREPTTE"` are required. `"TOT"` parameters store the number of occurrences of adverse event of interests. Parameter code `"AEREPTTE"` stores the time to end of adverse event reporting period in years that contribute to the summary of "total patient-years at risk" in the output. Users are expected to filter parameters of interest from input analysis dataset in pre-processing, if needed.
3) In the input safety time-to-event dataset, in the censoring variable `CNSR`, `0` indicates the occurrence of an event of interest and `1` denotes censoring.
```{r}
proc_data <- log_filter(syn_data, PARAMCD == "AETOT1" | PARAMCD == "AEREPTTE", "adsaftte")
run(aet05_all, proc_data)
```
#### **2. Adverse Event Rate Adjusted for Patient-Years at Risk - All Occurrences (setting type of confidence interval)**
1) The type of the confidence interval for rate can be specified by the argument `conf_type`. Options include `normal` (default), `normal_log`, `exact`, and `byar`.
2) The confidence interval can be adjusted by the argument `conf_level`.
```{r}
run(aet05_all, syn_data, conf_level = 0.90, conf_type = "exact")
```
### **Most Common (>=5%) Adverse Events (`AET10`)**
#### **1. Most Common (>=5%) Adverse Events**
1) The **`aet10`** template produces the standard most common adverse events occurring with relative frequency >=5% output.
```{r}
run(aet10, syn_data)
```
#### **2. Most Common (>=8%) Adverse Events (setting threshold)**
To modify the threshold for displaying preferred terms, this can be achieved by providing the threshold to the argument `atleast`.
```{r}
run(aet10, syn_data, atleast = 0.08)
```
### **Absolute Value and Change from Baseline by Visit (`CFBT01`)**
#### **1. Absolute Value and Change from Baseline by Visit**
1) By default, the `cfbt01` template displays analysis value (`AVAL`) and absolute change from baseline (`CHG`) for each visit.
2) The template does not include the column of total by default.
3) Each parameter is presented on a separate page.
4) The absolute change from baseline at baseline value is not displayed.
```{r}
proc_data <- log_filter(
syn_data,
PARAMCD %in% c("DIABP", "SYSBP"), "advs"
)
run(cfbt01, proc_data, dataset = "advs")
```
#### **2. Absolute Value and Change from Baseline by Visit without Screening**
The `skip` arguments controls which visit values should not be displayed. For instance, to mask the changes from baseline during the "SCREENING" and "BASELINE" visits.
```{r}
run(cfbt01, proc_data, dataset = "advs", skip = list(CHG = c("SCREENING", "BASELINE")))
```
### **3. Absolute Value by Visit**
To display only the absolute value, specify `summaryvars = "AVAL"`.
```{r}
run(cfbt01, proc_data, dataset = "advs", summaryvars = "AVAL")
```
### **Concomitant Medications by Medication Class and Preferred Name (`CMT01A`)**
#### **1. Concomitant Medications by Medication Class and Preferred Name**
1) The **`cmt01a`** template displays concomitant medications by `ATC Level 2` and Preferred Name by default.
2) The template does not include the column of total by default.
3) The template sort medication class and preferred name by alphabetical order by default.
```{r}
run(cmt01a, syn_data)
```
#### **2. Concomitant Medications by Medication Class and Preferred Name (changing `ATC class level`)**
```{r}
run(cmt01a, syn_data, row_split_var = "ATC1")
```
#### **3. Concomitant Medications by Medication Class and Preferred Name (classes sorted by frequency)**
The argument `sort_by_freq = TRUE` sort medication class by frequency.
```{r}
run(cmt01a, syn_data, sort_by_freq = TRUE)
```
#### **4. Concomitant Medications by Medication Class and Preferred Name (total number of treatments per medication class suppressed)**
The **`cmt01a`** template includes the analysis of 'total number of treatments' by default, modify the argument `summary_labels` to change it.
```{r}
run(cmt01a, syn_data, summary_labels = list(TOTAL = cmt01_label, ATC2 = cmt01_label[1]))
```
### **Concomitant Medications by Preferred Name (`CMT02_PT`)**
#### **1. Concomitant Medications by Preferred Name**
1) The **`cmt02_pt`** template displays concomitant medications by Preferred Name by default.
2) The template does not include the column of total by default.
3) The template sorts preferred name by alphabetical order by default. Set the argument `sort_by_freq = TRUE` to sort preferred names by frequency.
```{r}
run(cmt02_pt, syn_data)
```
### **Cox Regression (`COXT01`)**
#### **1. Cox Regression**
1) The **`coxt01`** template produces the standard Cox regression output.
2) Users are expected to pre-process the input analysis data by selecting a time-to-event parameter to be analyzed. The example below is based on the time-to-event parameter "Duration of Confirmed Response by Investigator".
3) The time variable in the model is specified through the `time_var` argument. By default, `time_var` is set to `"AVAL"`, which comes from `ADTTE.AVAL`.
4) The event variable in the model is specified through the `event_var` argument. By default, `event_var` is set to `"EVENT"`, which is derived based on the censoring indicator `ADTTE.CNSR` in the pre-processing function `coxt01_pre`.
5) If there are more than two treatment groups present in the input analysis data, users are also expected to select only two treatment groups. The example below is based on treatment groups `"Arm A"` and `"Arm B"`.
```{r}
proc_data <- log_filter(syn_data, PARAMCD == "OS", "adtte")
proc_data <- log_filter(proc_data, ARMCD != "ARM C", "adsl")
run(coxt01, proc_data, time_var = "AVAL", event_var = "EVENT")
```
#### **2. Cox Regression (with interaction term)**
To add the interaction term to the model, `interaction = TRUE`, which is passed to `tern::control_coxreg()`, needs to be specified.
```{r}
run(coxt01, proc_data, covariates = "AAGE", interaction = TRUE)
```
#### **3. Cox Regression (specifying covariates)**
1) By default, `"SEX"`, `"RACE"` and `"AAGE"` are used as the covariates for the model.
2) Users can specify a different set of covariates through the `covariates` argument. In the example below, `"RACE"` and `"AAGE"` are used as covariates.
```{r}
run(coxt01, proc_data, covariates = c("RACE", "AAGE"))
```
#### **4. Cox Regression (setting strata, ties, and alpha level)**
1) By default, `strata = NULL` (no stratification), `ties = "exact"` (equivalent to `DISCRETE` in SAS), and `conf_level = 0.95` are applied.
2) Users can specify one or more stratification variables via the `strata` argument.
3) Other tie handling methods, i.e., `"efron"` or `"breslow"`, can be specified in the `tie` argument, which is passed to `tern::control_coxreg()`.
4) Users can also customize the alpha level for the confidence intervals through the `conf_level` argument, which is passed to `tern::control_coxreg()`.
```{r}
run(coxt01, proc_data, covariates = c("SEX", "AAGE"), strata = c("RACE"), conf_level = 0.90)
```
### **Multi-variable Cox Regression (`COXT02`)**
#### **1. Multi-variable Cox Regression**
1) The **`coxt02`** template produces the standard multi-variable cox regression output.
2) Users are expected to pre-process the input analysis data by selecting a time-to-event parameter to be analyzed. The example below is based on the time-to-event parameter "Duration of Confirmed Response by Investigator".
3) The time variable in the model is specified through the `time_var` argument. By default, `time_var` is set to `"AVAL"`, which comes from `ADTTE.AVAL`.
4) The event variable in the model is specified through the `event_var` argument. By default, `event_var` is set to `"EVENT"`, which is derived based on the censoring indicator `ADTTE.CNSR` in the pre-processing function `coxt01_pre`.
```{r}
proc_data <- log_filter(syn_data, PARAMCD == "OS", "adtte")
run(coxt02, proc_data, time_var = "AVAL", event_var = "EVENT")
```
#### **2. Multi-variable Cox Regression (specifying covariates)**
1) By default, `"SEX"`, `"RACE"` and `"AAGE"` are used as the covariates for the model.
2) Users can specify a different set of covariates through the `covariates` argument. In the example below, `"RACE"` and `"AAGE"` are used as covariates.
```{r}
run(coxt02, proc_data, covariates = c("RACE", "AAGE"))
```
#### **3. Multi-variable Cox Regression (setting strata, ties, and alpha level)**
1) By default, `strata = NULL` (no stratification), `ties = "exact"` (equivalent to `DISCRETE` in SAS), and `conf_level = 0.95` are applied.
2) Users can specify one or more stratification variables via the `strata` argument.
3) Other tie handling methods, i.e., `"efron"` or `"breslow"`, can be specified in the `tie` argument, which is passed to `tern::control_coxreg()`.
4) Users can also customize the alpha level for the confidence intervals through the `conf_level` argument, which is passed to `tern::control_coxreg()`.
```{r}
run(coxt02, proc_data, covariates = c("SEX", "AAGE"), strata = c("RACE"), conf_level = 0.90, ties = "efron")
```
### **Demographics and Baseline Characteristics (`DMT01`)**
#### **1. Demographics and Baseline Characteristics with All Patients**
1) The **`dmt01`** template produces the standard demographics and baseline characteristics summary.
2) This template includes the column of total by default.
```{r}
run(dmt01, syn_data)
```
#### **2. Demographics and Baseline Characteristics without All Patients**
To remove the column of total, set the argument `lbl_overall` to `NULL`.
```{r}
run(dmt01, syn_data, lbl_overall = NULL)
```
#### **3. Demographics and Baseline Characteristics with an additional study specific continuous variable**
1) Study specific continuous variables can be added to the standard demographics and baseline characteristics summary by editing the argument `summaryvars`. To add or remove analyses, you need to pass all variables you would like to include to the argument.
2) CHEVRON performs the analysis based on the type of variable as defined in the input data.
```{r}
run(dmt01, syn_data, summaryvars = c("AGE", "AGEGR1", "SEX", "ETHNIC", "RACE", "BBMISI"), lbl_overall = NULL)
```
#### **4. Demographics and Baseline Characteristics with an additional study specific categorical variable**
1) Study specific categorical variables can be added to the standard demographics and baseline characteristics summary by editing the argument `summaryvars`.
2) To display the values within a categorical variable in pre-specified order, the categorical variable need to be factorized with pre-specified order provided as levels.
```{r}
proc_data <- syn_data
proc_data$adsl <- proc_data$adsl %>%
mutate(
SEX = reformat(.data$SEX, rule(Male = "M", Female = "F")),
BBMIGR1 = factor(case_when(
BBMISI < 15 ~ "Very severely underweight",
BBMISI >= 15 & BBMISI < 16 ~ "Severely underweight",
BBMISI >= 16 & BBMISI < 18.5 ~ "Underweight",
BBMISI >= 18.5 & BBMISI < 25 ~ "Normal (healthy weight)",
BBMISI >= 25 & BBMISI < 30 ~ "Overweight",
BBMISI >= 30 & BBMISI < 35 ~ "Obese Class I (Moderately obese)",
BBMISI >= 35 & BBMISI < 40 ~ "Obese Class II (Severely obese)",
BBMISI >= 40 ~ "Obese Class III (Very severely obese)"
), levels = c(
"Very severely underweight",
"Severely underweight",
"Underweight",
"Normal (healthy weight)",
"Overweight",
"Obese Class I (Moderately obese)",
"Obese Class II (Severely obese)",
"Obese Class III (Very severely obese)"
))
)
run(dmt01, proc_data, summaryvars = c("AGE", "AGEGR1", "SEX", "ETHNIC", "RACE", "BBMIGR1"), auto_pre = FALSE)
```
#### **5. Demographics and Baseline Characteristics with additional vital signs baseline values from `ADVS` or `ADSUB`**
To add baseline vital signs or other baseline characteristics to the demographics and baseline characteristics summary, manual preprocess of input `adsl` dataset is expected and merge the vital signs baseline values from `advs` (where `ADVS.ABLFL == "Y"`) or `adsub` with `adsl` by unique subject identifier.
```{r}
proc_data <- syn_data
diabpbl <- proc_data$advs %>%
filter(ABLFL == "Y" & PARAMCD == "DIABP") %>%
mutate(DIABPBL = AVAL) %>%
select("STUDYID", "USUBJID", "DIABPBL")
proc_data$adsl <- proc_data$adsl %>%
mutate(SEX = reformat(.data$SEX, rule(Male = "M", Female = "F"))) %>%
left_join(diabpbl, by = c("STUDYID", "USUBJID"))
run(dmt01, proc_data, summaryvars = c("AGE", "AGEGR1", "SEX", "ETHNIC", "RACE", "DIABPBL"), auto_pre = FALSE)
```
### **Patient Disposition (`DST01`)**
#### **1. Patient Disposition**
1) The **`dst01`** template produces the standard patient disposition summary.
2) The template includes the column of total by default. Use `lbl_overall = NULL` to suppress the default.
```{r}
run(dst01, syn_data, lbl_overall = NULL)
```
#### **2. Patient Disposition (with grouping of reasons)**
1) The syntax below produces the standard patient disposition summary with grouping of the discontinuation reasons.
2) The variable [`ADSL.DCSREASGP`] that groups the discontinuation reasons needs to be derived manually and provided in the input `adsl` dataset.
```{r}
run(dst01, syn_data, detail_vars = list(Discontinued = c("DCSREASGP", "DCSREAS")), lbl_overall = NULL)
```
#### **3. Patient Disposition (adding end of treatment status)**
The syntax below adds the end of treatment status to the standard patient disposition summary by providing the end of treatment status variable to the argument `trt_status_var`.
```{r}
run(dst01, syn_data, trt_status_var = "EOTSTT", lbl_overall = NULL)
```
#### **4. Patient Disposition (adding details of study ongoing status)**
The syntax adds the details of study ongoing/alive status to the standard patient disposition summary by modifying the argument `detail_vars`.
```{r}
run(dst01, syn_data, detail_vars = list(Discontinued = "DCSREAS", Ongoing = "STDONS"))
```
### **Deaths (`DTHT01`)**
#### **1. Deaths**
The **`dtht01`** template produces the standard deaths output.
```{r}
run(dst01, syn_data)
```
#### **2. Deaths (adding "Primary Cause of Death" details for 'Other' category)**
```{r}
run(dtht01, syn_data, other_category = TRUE)
```
NOTE: In order to avoid the warning above and display 'Other' as the last category under "Primary Cause of Death" right above the detailed reasons for "Other", the user is expected to manually provide levels to `ADSL.DTHCAT` based on categories available in the dataset.
#### **3. Deaths (adding summary by days from last study drug administration)**
Setting `time_since_last_dose` to `TRUE`, the syntax produces the count of deaths by days from last study drug administration as well as the count of deaths by primary cause and days from last study drug administration.
```{r}
run(dtht01, syn_data, time_since_last_dose = TRUE)
```
### **ECG Results and Change from Baseline by Visit (`EGT01`)**
#### **1. ECG Results and Change from Baseline by Visit**
The **`egt01`** template produces the standard ECG results and change from baseline by visit summary.
```{r}
run(egt01, syn_data)
```
### **ECG Abnormalities (Regardless of Abnormality at Baseline) (`EGT02_1`)**
#### **1. ECG Abnormalities (Regardless of Abnormality at Baseline)**
The **`egt02_1`** template produces the standard ECG abnormalities summary where the abnormalities are summarized regardless of the abnormality at baseline.
```{r}
run(egt02_1, syn_data)
```
### **ECG Abnormalities (Among Subject Without Abnormality at Baseline) (`EGT02_2`)**
#### **1. ECG Abnormalities (Among Subject Without Abnormality at Baseline)**
The **`egt02_2`** template produces the standard ECG abnormalities summary where the abnormalities are summarized among subject without abnormality at baseline.
```{r}
run(egt02_2, syn_data)
```
### **Shift Table of ECG Interval Data - Baseline versus Minimum/Maximum Post-Baseline (`EGT03`)**
#### **1. Shift Table of ECG Interval Data - Baseline versus Minimum Post-Baseline**
The **`egt03`** template produces the standard shift table of ECG interval data - baseline versus minimum post-baseline summary.
```{r}
proc_data <- log_filter(syn_data, PARAMCD == "HR", "adeg")
run(egt03, proc_data)
```
#### **2. Shift Table of ECG Interval Data - Baseline versus Maximum Post-Baseline**
To produce the standard shift table of ECG interval data - baseline versus maximum post-baseline summary....TBA
### **ECG Actual Values and Changes from Baseline by Visit (`EGT05_QTCAT`)**
#### **1. ECG Actual Values and Changes from Baseline by Visit**
The **`egt05_qtcat`** template produces the standard ECG actual values and changes from baseline by visit summary.
```{r}
run(egt05_qtcat, syn_data)
```
#### **2. ECG Actual Values and Changes from Baseline by Visit (removing default analyses)**
The template have two default analyses of `ADEG.AVALCAT1` and `ADEG.CHGCAT1`. To keep only the analyses needed, this can be achieved by modifying the parameter `summaryvars`.
```{r}
run(egt05_qtcat, syn_data, summaryvars = c("AVALCAT1"))
```
### **Study Drug Exposure (`EXT01`)**
#### **1. Study Drug Exposure**
1) The **`ext01`** template displays total number of doses administered and total dose administered by default
2) The template does not include the column of total by default
```{r}
run(ext01, syn_data)
```
### **Laboratory Test Results and Change from Baseline by Visit (`LBT01`)**
#### **1. Laboratory Test Results and Change from Baseline by Visit**
1) The **`lbt01`** template produces the standard laboratory test results and change from baseline by visit.
2) To select the SI/CV/LS results and the panel (chemistry/hematology/urinalysis/coagulation etc.) to display, user defines individual filters and apply to input datasets prior to running CHEVRON.
```{r}
t_lb_chg <- run(lbt01, syn_data)
head(t_lb_chg, 20)
```
#### **2. Laboratory Test Results and Change from Baseline by Visit (customized precision)**
TBA
### **Laboratory Abnormalities (`LBT04`)**
#### **1. Laboratory Abnormalities**
1) The **`lbt04`** template produces the standard laboratory abnormalities summary.
2) The template subsets to SI results by default.
3) The laboratory tests and directions of abnormality in this template is data-driven. Table entries provide the number of patients with a during treatment laboratory value abnormality in the direction specified among patients without this abnormality at baseline.
```{r}
run(lbt04, syn_data)
```
### **Laboratory Abnormalities with Single and Replicated Marked (`LBT05`)**
#### **1. Laboratory Abnormalities with Single and Replicated Marked**
1) The **`lbt05`** template produces the standard laboratory abnormalities summary for marked abnormalities.
2) The laboratory tests and directions of abnormality in this template is currently data-driven. The standard metadata for Safety Lab Standardization will be incorporated in future release.
```{r}
run(lbt05, syn_data)
```
#### **2. Laboratory Abnormalities with Single and Replicated Marked showing all categories**
#### **3. Laboratory Abnormalities with Single and Replicated Marked with study specific `MLAs`**
### **Laboratory Abnormalities by Visit and Baseline Status (`LBT06`)**
#### **1. Laboratory Abnormalities by Visit and Baseline Status**
1) The **`lbt06`** template produces the standard laboratory abnormalities by visit and baseline status summary.
```{r}
run(lbt06, syn_data)
```
### **Laboratory Test Results with Highest `NCI CTCAE` Grade Post-Baseline (`LBT07`)**
#### **1. Laboratory Test Results with Highest `NCI CTCAE` Grade Post-Baseline**
1) The **`lbt07`** template produces the standard laboratory test results with highest `NCI CTCAE` grade post-baseline summary.
2) The laboratory tests and grades in this template is currently data-driven. The standard metadata for possible lab tests and corresponding `NCI CTCAE` grade will be incorporated in future release.
```{r}
run(lbt07, syn_data)
```
### **Laboratory Test Results Shift Table - Highest `NCI-CTCAE` Grade Post-Baseline by Baseline `NCI-CTCAE` Grade (`LBT14`)**
#### **1. Laboratory Test Results Shift Table - Highest `NCI-CTCAE` Grade Post-Baseline by Baseline `NCI-CTCAE` Grade (High)**
To produce the standard laboratory test results shift table - highest `NCI-CTCAE` grade post-baseline by baseline `NCI-CTCAE` grade summary for high abnormalities, use the **`lbt14`** template and set the parameter *`direction`* to `high`.
```{r}
run(lbt14, syn_data, direction = "high")
```
#### **2. Laboratory Test Results Shift Table - Highest `NCI-CTCAE` Grade Post-Baseline by Baseline `NCI-CTCAE` Grade (Low)**
To produce the standard laboratory test results shift table - highest `NCI-CTCAE` grade post-baseline by baseline `NCI-CTCAE` grade summary for high abnormalities, use the **`lbt14`** template and the argument `direction` is `low` by default.
```{r}
run(lbt14, syn_data)
```
#### **3. Laboratory Test Results Shift Table - Highest `NCI-CTCAE` Grade Post-Baseline by Baseline `NCI-CTCAE` Grade (High) Without Patients with Missing Baseline**
To exclude patients with missing baseline grade, set the argument `gr_missing` to `excl`.
```{r}
run(lbt14, syn_data, direction = "high", gr_missing = "excl")
```
#### **4. Laboratory Test Results Shift Table - Highest `NCI-CTCAE` Grade Post-Baseline by Baseline `NCI-CTCAE` Grade (Low) with Missing Baseline Considered as Grade 0**
To count patients with missing baseline grade as grade 0, set the argument `gr_missing` to `gr_0`.
```{r}
run(lbt14, syn_data, gr_missing = "gr_0")
```
#### **4. Laboratory Test Results Shift Table - Highest `NCI-CTCAE` Grade Post-Baseline by Baseline `NCI-CTCAE` Grade (with fill in of grades)**
To display all possible grades even if they do not occur in the data, set the argument `prune_0` to `FALSE`.
```{r}
run(lbt14, syn_data, direction = "high", prune_0 = FALSE)
```
### **Laboratory Test Shifts to `NCI-CTCAE` Grade 3-4 Post-Baseline (`LBT15`)**
Please note that the following examples of summarizing lab grades using single and double grading approaches can be applied to other lab table templates beyond `LBT15`.
#### **1. Laboratory Test Shifts to `NCI-CTCAE` Grade 3-4 Post-Baseline (Single Grading Approach)**
In ADaM v1.1 or below, lab grade variables (`BTOXGR` and `ATOXGR`) in ADLB range from -4 to +4, with -/+ indicating the direction of lab abnormality. This is known as the single grading approach.
To summarize patients shifting to post-baseline grade 3-4 based on ADLB with the single grading approach, simply run the default `lbt15` template shown below.
```{r}
run(lbt15, syn_data)
```
#### **2. Laboratory Test Shifts to `NCI-CTCAE` Grade 3-4 Post-Baseline (Double Grading Approach)**
In ADaM v1.2 or above, ADLB now has two sets of lab grade variables - the high-directional variables (`ATOXDSCH`/`ATOXGRH`/`BTOXGRH`) and the low-directional variables (`ATOXDSCL`/`BTOXGRL`/`ATOXGRL`), both ranging from 0 to 4. This is known as the double grading or the bi-directional approach, which is the default in `{admiral}`.
To summarize patients shifting to post-baseline grade 3-4 based on ADLB with the double grading approach, redefining `ANRIND` and `BNRIND` is needed in the pre-processing step shown below.
```{r}
proc_data <- syn_data
# Convert single grading variables to double ones for demo purpose only
# as the original syn_data is using single grading approach
hr <- rule("0" = c("-4", "-3", "-2", "-1", "0"))
lr <- rule(
"0" = c("4", "3", "2", "1", "0"),
"1" = "-1", "2" = "-2", "3" = "-3", "4" = "-4"
)
proc_data$adlb <- proc_data$adlb %>%
mutate(
BTOXGRH = reformat(.data$BTOXGR, hr),
ATOXGRH = reformat(.data$ATOXGR, hr),
BTOXGRL = reformat(.data$BTOXGR, lr),
ATOXGRL = reformat(.data$ATOXGR, lr)
)
# Redefine ANRIND and BNRIND to adopt double grading approach
preprocess(lbt15) <- function(adam_db, ...) {
adam_db$adlb <- adam_db$adlb %>%
filter(.data$ONTRTFL == "Y", .data$PARCAT2 == "SI") %>%
mutate(
PARAM = with_label(.data$PARAM, "Laboratory Test"),
ANRIND = with_label(
as.factor(
case_when(
ATOXGRH == "0" & ATOXGRL %in% c("3", "4") ~ "LOW",
is.na(ATOXGRH) & ATOXGRL %in% c("3", "4") ~ "LOW",
ATOXGRH %in% c("3", "4") & ATOXGRL == "0" ~ "HIGH",
ATOXGRH %in% c("3", "4") & is.na(ATOXGRL) ~ "HIGH",
is.na(ATOXGRH) & is.na(ATOXGRL) ~ NA_character_,
TRUE ~ "MODERATE/NORMAL"
)
), "Direction of Abnormality"
),
BNRIND = as.factor(
case_when(
BTOXGRH == "0" & BTOXGRL %in% c("3", "4") ~ "LOW",
is.na(BTOXGRH) & BTOXGRL %in% c("3", "4") ~ "LOW",
BTOXGRH %in% c("3", "4") & BTOXGRL == "0" ~ "HIGH",
BTOXGRH %in% c("3", "4") & is.na(BTOXGRL) ~ "HIGH",
is.na(BTOXGRH) & is.na(BTOXGRL) ~ NA_character_,
TRUE ~ "MODERATE/NORMAL"
)
)
)
adam_db
}
run(lbt15, proc_data)
```
### **Medical History (`MHT01`)**
#### **1. Medical History**
1) The **`mht01`** template displays medical conditions by MedDRA system organ class and Preferred Name by default.
2) The default treatment variable is `"ADSL.ARM"`.
3) The user is expected to use filter to subset medical conditions prior to or on entering study.
4) By default, the template produces the overall 'total number of conditions' as well as the 'total number of conditions' per body system after the summary of patients.
5)This template currently does not support sorting MedDRA system organ class and preferred names by order of frequency.
```{r}
run(mht01, syn_data)
```
#### **2. Medical History showing additional column 'All Patients'**
```{r}
run(mht01, syn_data, lbl_overall = "All Patients")
```
### **Major Protocol Deviations (`PDT01`)**
#### **1. Major Protocol Deviations**
1) The **`pdt01`** template produces the standard major protocol deviations output.
2) Users are expected to filter `addv` to only include records where `DVCAT == "MAJOR"` in pre-processing.
```{r}
proc_data <- syn_data
proc_data$addv <- proc_data$addv %>%
filter(DVCAT == "MAJOR")
run(pdt01, proc_data)
```
### **Reasons for Major Protocol Deviations Related to Epidemic/Pandemic (`PDT02`)**
#### **1. Reasons for Major Protocol Deviations Related to Epidemic/Pandemic**
1) The **`pdt02`** template produces the reasons for major protocol deviations related to epidemic/pandemic summary.
2) By default, `ADDV.DVREAS` provides the reason and `ADDV.DVTERM` provides the description.
3) By default, `addv` has been filtered to include only records that meet the condition `AEPRELFL == "Y" & DVCAT == "MAJOR"`.
```{r}
run(pdt02, syn_data)
```
### **Duration of Exposure for Risk Management Plan (`RMPT01`)**
#### **1. Duration of Exposure for Risk Management Plan**
The **`rmpt01`** template produces the standard duration of exposure output for the Risk Management Plan (`RMP`).
Person time is the sum of exposure across all patients in days.
```{r}
run(rmpt01, syn_data)
```
### **Extent of Exposure by Age Group and Gender for Risk Management Plan (`RMPT03`)**
#### **1. Extent of Exposure by Age Group and Gender for Risk Management Plan**
The **`rmpt03`** template produces the standard extent of exposure by age group and gender output for the Risk Management Plan (`RMP`).
By default, the `AGEGR1` variable is used as the age group. If `AGEGR1` is available in `ADSL` only but not in `ADEX`, it needs to be added to `ADEX` first.
```{r}
proc_data <- syn_data
proc_data <- propagate(proc_data, "adsl", "AGEGR1", "USUBJID")
run(rmpt03, proc_data)
```
Any other study specific age group can be used by editing the parameter `summaryvars`. For all `RMP` tables, if the variable specified per `summaryvars` is unavailable in `ADEX`, it needs to be added to `ADEX` first.
```{r}
proc_data <- syn_data
proc_data$adsl <- proc_data$adsl %>%
mutate(
AGEGR2 = with_label(
factor(case_when(
AAGE < 18 ~ "<18",
AAGE >= 18 & AAGE <= 65 ~ "18 - 65",
AAGE > 65 ~ ">65",
), levels = c("<18", "18 - 65", ">65")),
"Age Group 2"
)
)
proc_data <- propagate(proc_data, "adsl", "AGEGR2", "USUBJID")
run(rmpt03, proc_data, summaryvars = "AGEGR2")
```
### **Extent of Exposure by Ethnic Origin for Risk Management Plan (`RMPT04`)**
#### **1. Extent of Exposure by Ethnic Origin for Risk Management Plan**
The **`rmpt04`** template produces the standard extent of exposure by ethnic origin output for the Risk Management Plan (`RMP`).
```{r}
run(rmpt04, syn_data)
```
### **Extent of Exposure by Race for Risk Management Plan (`RMPT05`)**
#### **1. Extent of Exposure by Race for Risk Management Plan**
The **`rmpt05`** template produces the standard extent of exposure by race output for the Risk Management Plan (`RMP`).
```{r}
run(rmpt05, syn_data)
```
### **Best Overall Response (`RSPT01`)**
#### **1. Best Overall Response**
1) The **`rspt01`** template produces the standard best overall response output.
2) The template syntax is built based on `RECIST 1.1`. By default, the subjects with response results of `"CR"` or `"PR"` are considered as responders.
3) Users are expected to pre-process the input analysis data and select the parameter to be analyzed, i.e., best overall response by investigator or best overall response by `BICR`.
4) Unstratified analysis is provided by default.
```{r}
proc_data <- log_filter(syn_data, PARAMCD == "BESRSPI", "adrs")
run(rspt01, proc_data, ref_group = NULL, perform_analysis = "unstrat", strata = NULL)
```
#### **2. Best Overall Response (Ordering of treatment groups)** {#1}
1) By default, the first level or value of `arm_var` (default to `"ADSL.ARM"` unless specified) is treated as the reference group without specification.
2) To apply user-defined reference group, please provide the value from the treatment variable to the argument `ref_group`, e.g., `ref_group = "PLACEBO"`.
3) Since `rtables` displays the reference group at the very left column, the order of displayed treatment groups may not be exactly the same as the order factorized, depending on which group is selected as the reference group. See below for examples:
| Factorized `trt` order | `ref_group` | Displayed `trt` order | Reference group used in analysis |
| :---------------------:| :----------:|:---------------------:|:--------------------------------:|
| ARM C, ARM B, ARM A | NULL | ARM C, ARM B, ARM A | ARM C |
| NULL | ARM B | ARM B, ARM A, ARM C | ARM B |
| ARM C, ARM B, ARM A | ARM B | ARM B, ARM C, ARM A | ARM B |
#### **3. Best Overall Response (selecting sections to display)**
1) The section of `Odds Ratio` can be suppressed with the argument `odds_ratio = FALSE`.
2) The section of `Difference in response rate` can be suppressed with the argument `perform_analysis = NULL`.