We will here use the tabTOX, tabTOX_arm and
plotTOX functions in the Data & Functions
page.
Download Tox_functions.R
# Libraries
library(tidyverse)
library(ggplot2)
library(kableExtra)
# Creation of datasets
set.seed(1234)
n_AE <- 300
n_pat <- 100
df <- data.frame(OBS = sample(1:n_pat, n_AE, replace=T),
cat_tox = sample(paste("cat", 1:3), n_AE, replace=T),
tox = sample(paste("tox", 1:2), n_AE, replace=T),
tox_bis = sample(paste("tox", 1:20), n_AE, replace=T),
grade = sample(c(1, 2, 3, 4, 5, NA), n_AE, prob=c(0.3, 0.3, 0.2, 0.1, 0.05, 0.05), replace=T)) %>% arrange(OBS)
df$ARM <- ifelse(df$OBS%in%1:50, 'A', 'B')
df_bis <- data.frame(NAME = rep(paste("tox", 1:8), each=2),
N = sample(0:(n_pat/2), 16, replace=T),
ARM = rep(c('A', 'B'), 8))tabTOX functiontabae1 <- tabTOX(df, "OBS", var="tox", var_grade="grade",
grade_max=FALSE, percent="%", latex=FALSE, langue='en')
kable(tabae1, "html", booktabs = T, longtable = T,
row.names = 0, escape = F, linesep = "") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed"),
full_width = FALSE, position = "left")| tox | N | N grade 1 | N grade 2 | N grade 3 | N grade 4 | N grade 5 | N missing grade |
|---|---|---|---|---|---|---|---|
| Total | 97 | 64 | 62 | 44 | 20 | 7 | 12 |
| tox 1 | 85 | 40 | 45 | 26 | 12 | 5 | 5 |
| tox 2 | 76 | 40 | 30 | 23 | 11 | 2 | 7 |
Here is another example where other optional parameters are used:
tabae2 <- tabTOX(df, "OBS", var="tox", var_cat="cat_tox", var_grade="grade",
grade_max=TRUE, percent="%", latex=FALSE, langue='en',
all=FALSE, addNA=FALSE, var_name="AE", total="All", n=n_pat)
kable(tabae2, "html", booktabs = T, longtable = T,
row.names = 0, escape = F, linesep = "") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed"),
full_width = FALSE, position = "left")| AE | N grade 1 | N grade 2 | N grade 3 | N grade 4 | N grade 5 |
|---|---|---|---|---|---|
| All | 11 (11%) | 28 (28%) | 31 (31%) | 20 (20%) | 7 (7%) |
| cat 3 | 20 (20%) | 22 (22%) | 13 (13%) | 11 (11%) | 3 (3%) |
|
16 (16%) | 17 (17%) | 10 (10%) | 7 (7%) | 1 (1%) |
|
18 (18%) | 10 (10%) | 3 (3%) | 4 (4%) | 2 (2%) |
| cat 2 | 13 (13%) | 20 (20%) | 16 (16%) | 7 (7%) | 3 (3%) |
|
10 (10%) | 14 (14%) | 8 (8%) | 2 (2%) | 3 (3%) |
|
10 (10%) | 9 (9%) | 11 (11%) | 5 (5%) | 0 |
| cat 1 | 13 (13%) | 17 (17%) | 15 (15%) | 5 (5%) | 1 (1%) |
|
11 (11%) | 10 (10%) | 10 (10%) | 3 (3%) | 0 |
|
9 (9%) | 9 (9%) | 7 (7%) | 3 (3%) | 1 (1%) |
In the example above, only the maximal grade per toxicity is taken into account, missing grades and any grades are not displayed. Category of each adverse event is added. The percentages of the numbers are also displayed (per patients).
tabTOX_arm functiontabae3 <- tabTOX_arm(df, "OBS", var="tox", var_cat="cat_tox", var_grade="grade",
arm="ARM", grade_filter = 3,
percent="%", latex=FALSE, langue='en',
var_name="AE", total="All", n=c(n_pat/2,n_pat/2))
kable(tabae3, "html", booktabs = T, longtable = T,
row.names = 0, escape = F, linesep = "") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed"),
full_width = FALSE, position = "left")| AE | A | B | ||
|---|---|---|---|---|
| Any grade | >= Grade 3 | Any grade | >= Grade 3 | |
| All | 49 (98%) | 27 (54%) | 48 (96%) | 31 (62%) |
| cat 3 | 35 (70%) | 13 (26%) | 37 (74%) | 14 (28%) |
|
23 (46%) | 9 (18%) | 28 (56%) | 9 (18%) |
|
21 (42%) | 4 (8%) | 19 (38%) | 5 (10%) |
| cat 2 | 34 (68%) | 10 (20%) | 28 (56%) | 16 (32%) |
|
21 (42%) | 5 (10%) | 18 (36%) | 8 (16%) |
|
20 (40%) | 5 (10%) | 17 (34%) | 11 (22%) |
| cat 1 | 29 (58%) | 11 (22%) | 24 (48%) | 10 (20%) |
|
20 (40%) | 7 (14%) | 16 (32%) | 6 (12%) |
|
14 (28%) | 5 (10%) | 15 (30%) | 6 (12%) |
This document is a work of the statistics team in the Biostatistics and Medical Information Department at Saint-Louis Hospital in Paris (SBIM).
This site was developed by Emma Lafaurie.
Actual development and updating by Noémie Bigot and Anouk Walter-Petrich
noemie.bigot@aphp.fr; anouk.walter-petrich@u-paris.fr.
Based on The R Graph Gallery by Yan Holtz.