We will here use the tabTOX
and plotTOX
functions in the Data &
Functions page.
Download Tox_functions.R
# Data used
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')
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)
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%) |
- tox 1 | 16 (16%) | 17 (17%) | 10 (10%) | 7 (7%) | 1 (1%) |
- tox 2 | 18 (18%) | 10 (10%) | 3 (3%) | 4 (4%) | 2 (2%) |
cat 2 | 13 (13%) | 20 (20%) | 16 (16%) | 7 (7%) | 3 (3%) |
- tox 1 | 10 (10%) | 14 (14%) | 8 (8%) | 2 (2%) | 3 (3%) |
- tox 2 | 10 (10%) | 9 (9%) | 11 (11%) | 5 (5%) | 0 |
cat 1 | 13 (13%) | 17 (17%) | 15 (15%) | 5 (5%) | 1 (1%) |
- tox 2 | 11 (11%) | 10 (10%) | 10 (10%) | 3 (3%) | 0 |
- tox 1 | 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).
plotTOX
functionHere is an example of adverse events visualization for two groups comparison without the optional arguments:
tabae3 <- plotTOX(baz=df, id="OBS", var="tox_bis",
n=c(n_pat/2,n_pat/2), arm="ARM", langue="en")
tabae3$plot
We can:
tabae4 <- plotTOX(baz=df, id="OBS", var="tox_bis",
n=c(n_pat/2,n_pat/2), arm="ARM", langue="en",
percent_supp=15, favors=c("Favor B", "Favor A"),
y_favors_arrow=-0.1, y_favors_text=-0.3)
tabae4$plot
df_bis
, NAME
indicates the type of toxicity,
N
the number of patients affected by the toxicity and the
last one the randomization arm for which name can be given in the
argument arm
of the function)tabae5 <- plotTOX(baz=df_bis, id="OBS", var="tox_bis",
n=c(n_pat/2,n_pat/2), arm="ARM", langue="en",
y_favors_arrow=0, y_favors_text=-0.1)
tabae5$plot
This document is a work of the statistics team in the Biostatistics and Medical Information Department at Saint-Louis Hospital in Paris (SBIM).
Developed and updated 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.