The function ae_table_soc()
creates a summary table of AE grades for each patient according to term and SOC CTCAE.
The resulting dataframe can be piped to as_flextable()
to get a nicely formatted flextable.
Usage
ae_table_soc(
df_ae,
...,
df_enrol,
variant = c("max", "sup", "eq"),
arm = NULL,
term = NULL,
sort_by_count = TRUE,
total = TRUE,
showNA = TRUE,
digits = 0,
warn_miss = FALSE,
grade = "AEGR",
soc = "AESOC",
subjid = "SUBJID"
)
# S3 method for class 'ae_table_soc'
as_flextable(
x,
...,
arm_colors = c("#f2dcdb", "#dbe5f1", "#ebf1dd", "#e5e0ec"),
padding_v = NULL
)
Arguments
- df_ae
adverse event dataset, one row per AE, containing subjid, soc, and grade.
- ...
unused
- df_enrol
enrollment dataset, one row per patient, containing subjid (and arm if needed). All patients should be in this dataset.
- variant
one or several of
c("max", "sup", "eq")
.max
computes the maximum AE grade per patient,sup
computes the number of patients having experienced at least one AE of grade higher or equal to X, andeq
computes the number of patients having experienced at least one AE of grade equal to X.- arm
name of the treatment column in
df_enrol
. Case-insensitive. Can be set toNULL
.- term
name of the the CTCAE term column in
df_ae
. Case-insensitive. Can be set toNULL
.- sort_by_count
should the table be sorted by the number of AE or by SOC alphabetically.
- total
whether to add a
total
column for each arm.- showNA
whether to display missing grades.
- digits
significant digits for percentages.
- warn_miss
whether to warn for missing values.
- grade
name of the AE grade column in
df_ae
. Case-insensitive.- soc
name of the SOC column in
df_ae
. Case-insensitive. Grade will be considered 0 if missing (e.g. if patient if absent fromdf_ae
).- subjid
name of the patient ID in both
df_ae
anddf_enrol
. Case-insensitive.- x
a dataframe, resulting of
ae_table_soc()
- arm_colors
colors for the arm groups
- padding_v
a numeric of lenght up to 2, giving the vertical padding of body (1) and header (2)
See also
ae_table_grade()
, ae_table_soc()
, ae_plot_grade()
, ae_plot_grade_sum()
, butterfly_plot()
Examples
tm = grstat_example()
attach(tm, warn.conflicts=FALSE)
ae_table_soc(df_ae=ae, df_enrol=enrolres)
#> # A tibble: 27 × 8
#> soc all_patients_G1 all_patients_G2 all_patients_G3 all_patients_G4
#> <fct> <glue> <glue> <glue> <glue>
#> 1 Congenital, … 27 (14%) 15 (8%) 6 (3%) 3 (2%)
#> 2 Social circu… 19 (10%) 14 (7%) 7 (4%) 5 (2%)
#> 3 Surgical and… 26 (13%) 5 (2%) 8 (4%) 3 (2%)
#> 4 Neoplasms be… 17 (8%) 11 (6%) 2 (1%) 7 (4%)
#> 5 Eye disorders 19 (10%) 7 (4%) 7 (4%) 2 (1%)
#> 6 Pregnancy, p… 18 (9%) 8 (4%) 7 (4%) NA
#> 7 Cardiac diso… 11 (6%) 8 (4%) 4 (2%) 5 (2%)
#> 8 Injury, pois… 11 (6%) 9 (4%) 8 (4%) 1 (0%)
#> 9 Immune syste… 15 (8%) 7 (4%) 3 (2%) 2 (1%)
#> 10 Endocrine di… 10 (5%) 7 (4%) 4 (2%) 3 (2%)
#> # ℹ 17 more rows
#> # ℹ 3 more variables: all_patients_G5 <glue>, all_patients_NA <glue>,
#> # all_patients_Tot <glue>
ae_table_soc(df_ae=ae, df_enrol=enrolres, arm="arm")
#> # A tibble: 27 × 15
#> soc control_G1 control_G2 control_G3 control_G4 control_G5 control_NA
#> <fct> <glue> <glue> <glue> <glue> <glue> <glue>
#> 1 Congenital… 18 (18%) 7 (7%) 2 (2%) 2 (2%) NA NA
#> 2 Social cir… 13 (13%) 5 (5%) 3 (3%) NA NA NA
#> 3 Surgical a… 18 (18%) 2 (2%) 2 (2%) NA NA NA
#> 4 Neoplasms … 9 (9%) 5 (5%) NA 3 (3%) 1 (1%) NA
#> 5 Eye disord… 7 (7%) 2 (2%) 3 (3%) 2 (2%) NA NA
#> 6 Pregnancy,… 10 (10%) 2 (2%) 3 (3%) NA NA NA
#> 7 Cardiac di… 7 (7%) 5 (5%) 3 (3%) 2 (2%) NA NA
#> 8 Injury, po… 6 (6%) 7 (7%) 4 (4%) NA NA NA
#> 9 Immune sys… 10 (10%) 3 (3%) 2 (2%) NA NA NA
#> 10 Endocrine … 4 (4%) 4 (4%) 2 (2%) 1 (1%) NA NA
#> # ℹ 17 more rows
#> # ℹ 8 more variables: control_Tot <glue>, treatment_G1 <glue>,
#> # treatment_G2 <glue>, treatment_G3 <glue>, treatment_G4 <glue>,
#> # treatment_G5 <glue>, treatment_NA <glue>, treatment_Tot <glue>
#sub population
ae_table_soc(df_ae=ae, df_enrol=head(enrolres, 10), arm="arm")
#> # A tibble: 18 × 15
#> soc control_G1 control_G2 control_G3 control_G4 control_G5 control_NA
#> <fct> <glue> <glue> <glue> <glue> <glue> <glue>
#> 1 Congenital… 1 (20%) NA NA NA NA NA
#> 2 Injury, po… NA 1 (20%) 1 (20%) NA NA NA
#> 3 Surgical a… 1 (20%) NA NA NA NA NA
#> 4 Endocrine … NA 1 (20%) NA NA NA NA
#> 5 Eye disord… 1 (20%) NA NA NA NA NA
#> 6 Investigat… 1 (20%) NA 1 (20%) NA NA NA
#> 7 Neoplasms … NA NA NA NA NA NA
#> 8 Respirator… NA NA NA NA NA NA
#> 9 Cardiac di… NA NA NA 1 (20%) NA NA
#> 10 Ear and la… NA NA NA NA NA NA
#> 11 General di… NA NA NA NA NA NA
#> 12 Hepatobili… NA NA NA NA NA NA
#> 13 Metabolism… NA NA NA NA NA NA
#> 14 Musculoske… NA NA NA NA NA NA
#> 15 Psychiatri… NA 1 (20%) NA NA NA NA
#> 16 Skin and s… 1 (20%) NA NA NA NA NA
#> 17 Vascular d… 1 (20%) NA NA NA NA NA
#> 18 No Declare… NA NA NA NA NA 1 (20%)
#> # ℹ 8 more variables: control_Tot <glue>, treatment_G1 <glue>,
#> # treatment_G2 <glue>, treatment_G3 <glue>, treatment_G4 <glue>,
#> # treatment_G5 <glue>, treatment_NA <glue>, treatment_Tot <glue>
#the resulting flextable can be customized using the flextable package
library(flextable)
ae_table_soc(ae, df_enrol=enrolres, total=FALSE) %>%
as_flextable() %>%
hline(i=~soc=="" & soc!=dplyr::lead(soc))
All patients (N=200)
CTCAE SOC
G1
G2
G3
G4
G5
NA
Congenital, familial and genetic disorders
27 (14%)
15 (8%)
6 (3%)
3 (2%)
Social circumstances
19 (10%)
14 (7%)
7 (4%)
5 (2%)
Surgical and medical procedures
26 (13%)
5 (2%)
8 (4%)
3 (2%)
1 (0%)
Neoplasms benign, malignant, and unspecified
17 (8%)
11 (6%)
2 (1%)
7 (4%)
2 (1%)
Eye disorders
19 (10%)
7 (4%)
7 (4%)
2 (1%)
Pregnancy, puerperium and perinatal conditions
18 (9%)
8 (4%)
7 (4%)
Cardiac disorders
11 (6%)
8 (4%)
4 (2%)
5 (2%)
2 (1%)
Injury, poisoning and procedural complications
11 (6%)
9 (4%)
8 (4%)
1 (0%)
1 (0%)
Immune system disorders
15 (8%)
7 (4%)
3 (2%)
2 (1%)
Endocrine disorders
10 (5%)
7 (4%)
4 (2%)
3 (2%)
Hepatobiliary disorders
13 (6%)
9 (4%)
1 (0%)
1 (0%)
Psychiatric disorders
16 (8%)
3 (2%)
2 (1%)
2 (1%)
1 (0%)
Vascular disorders
12 (6%)
5 (2%)
2 (1%)
2 (1%)
1 (0%)
Musculoskeletal and connective tissue disorders
9 (4%)
5 (2%)
2 (1%)
5 (2%)
Respiratory, thoracic and mediastinal disorders
8 (4%)
6 (3%)
2 (1%)
1 (0%)
1 (0%)
Ear and labyrinth disorders
10 (5%)
5 (2%)
1 (0%)
Metabolism and nutrition disorders
7 (4%)
3 (2%)
4 (2%)
General disorders and administration site conditions
8 (4%)
3 (2%)
1 (0%)
Nervous system disorders
7 (4%)
4 (2%)
1 (0%)
Skin and subcutaneous tissue disorders
4 (2%)
5 (2%)
1 (0%)
2 (1%)
Infections and infestations
6 (3%)
3 (2%)
1 (0%)
Blood and lymphatic system disorders
6 (3%)
1 (0%)
1 (0%)
1 (0%)
Gastrointestinal disorders
2 (1%)
2 (1%)
4 (2%)
1 (0%)
Reproductive system and breast disorders
7 (4%)
2 (1%)
Investigations
4 (2%)
2 (1%)
1 (0%)
1 (0%)
Renal and urinary disorders
1 (0%)
3 (2%)
1 (0%)
1 (0%)
No Declared AE
3 (2%)
ae_table_soc(ae, df_enrol=enrolres, term=NULL, sort_by_count=FALSE) %>%
as_flextable() %>%
bold(i=~soc=="Eye disorders")
All patients (N=200)
CTCAE SOC
G1
G2
G3
G4
G5
NA
Tot
Blood and lymphatic system disorders
6 (3%)
1 (0%)
1 (0%)
1 (0%)
9 (4%)
Cardiac disorders
11 (6%)
8 (4%)
4 (2%)
5 (2%)
2 (1%)
30 (15%)
Congenital, familial and genetic disorders
27 (14%)
15 (8%)
6 (3%)
3 (2%)
51 (26%)
Ear and labyrinth disorders
10 (5%)
5 (2%)
1 (0%)
16 (8%)
Endocrine disorders
10 (5%)
7 (4%)
4 (2%)
3 (2%)
24 (12%)
Eye disorders
19 (10%)
7 (4%)
7 (4%)
2 (1%)
35 (18%)
Gastrointestinal disorders
2 (1%)
2 (1%)
4 (2%)
1 (0%)
9 (4%)
General disorders and administration site conditions
8 (4%)
3 (2%)
1 (0%)
12 (6%)
Hepatobiliary disorders
13 (6%)
9 (4%)
1 (0%)
1 (0%)
24 (12%)
Immune system disorders
15 (8%)
7 (4%)
3 (2%)
2 (1%)
27 (14%)
Infections and infestations
6 (3%)
3 (2%)
1 (0%)
10 (5%)
Injury, poisoning and procedural complications
11 (6%)
9 (4%)
8 (4%)
1 (0%)
1 (0%)
30 (15%)
Investigations
4 (2%)
2 (1%)
1 (0%)
1 (0%)
8 (4%)
Metabolism and nutrition disorders
7 (4%)
3 (2%)
4 (2%)
14 (7%)
Musculoskeletal and connective tissue disorders
9 (4%)
5 (2%)
2 (1%)
5 (2%)
21 (10%)
Neoplasms benign, malignant, and unspecified
17 (8%)
11 (6%)
2 (1%)
7 (4%)
2 (1%)
39 (20%)
Nervous system disorders
7 (4%)
4 (2%)
1 (0%)
12 (6%)
Pregnancy, puerperium and perinatal conditions
18 (9%)
8 (4%)
7 (4%)
33 (16%)
Psychiatric disorders
16 (8%)
3 (2%)
2 (1%)
2 (1%)
1 (0%)
24 (12%)
Renal and urinary disorders
1 (0%)
3 (2%)
1 (0%)
1 (0%)
6 (3%)
Reproductive system and breast disorders
7 (4%)
2 (1%)
9 (4%)
Respiratory, thoracic and mediastinal disorders
8 (4%)
6 (3%)
2 (1%)
1 (0%)
1 (0%)
18 (9%)
Skin and subcutaneous tissue disorders
4 (2%)
5 (2%)
1 (0%)
2 (1%)
12 (6%)
Social circumstances
19 (10%)
14 (7%)
7 (4%)
5 (2%)
45 (22%)
Surgical and medical procedures
26 (13%)
5 (2%)
8 (4%)
3 (2%)
1 (0%)
43 (22%)
Vascular disorders
12 (6%)
5 (2%)
2 (1%)
2 (1%)
1 (0%)
22 (11%)
No Declared AE
3 (2%)
3 (2%)
ae_table_soc(ae, df_enrol=enrolres, term="aeterm", arm=NULL) %>%
as_flextable() %>%
highlight(i=~soc=="Hepatobiliary disorders", j="all_patients_Tot")
All patients (N=200)
CTCAE SOC
CTCAE v4.0 Term
G1
G2
G3
G4
G5
NA
Tot
Congenital, familial and genetic disorders
Chromosomal abnormalities
11 (6%)
5 (2%)
1 (0%)
1 (0%)
18 (9%)
Congenital nervous system disorders
6 (3%)
3 (2%)
9 (4%)
Familial hematologic disorders
7 (4%)
1 (0%)
3 (2%)
2 (1%)
13 (6%)
Hereditary connective tissue disorders
9 (4%)
6 (3%)
2 (1%)
17 (8%)
Social circumstances
Cultural issues
5 (2%)
2 (1%)
2 (1%)
1 (0%)
10 (5%)
Economic conditions affecting care
3 (2%)
4 (2%)
1 (0%)
1 (0%)
9 (4%)
Family support issues
6 (3%)
3 (2%)
3 (2%)
2 (1%)
14 (7%)
Social and environmental issues
7 (4%)
5 (2%)
1 (0%)
1 (0%)
14 (7%)
Surgical and medical procedures
Device implantation procedures
13 (6%)
1 (0%)
2 (1%)
1 (0%)
17 (8%)
Diagnostic procedures
10 (5%)
1 (0%)
5 (2%)
16 (8%)
Surgical complications
3 (2%)
4 (2%)
1 (0%)
1 (0%)
9 (4%)
Therapeutic procedures
2 (1%)
1 (0%)
3 (2%)
Neoplasms benign, malignant, and unspecified
Benign neoplasms
5 (2%)
4 (2%)
1 (0%)
3 (2%)
13 (6%)
Malignant neoplasms
6 (3%)
4 (2%)
1 (0%)
2 (1%)
13 (6%)
Neoplasms unspecified
5 (2%)
1 (0%)
1 (0%)
7 (4%)
Tumor progression
2 (1%)
3 (2%)
1 (0%)
1 (0%)
7 (4%)
Eye disorders
Corneal disorders
4 (2%)
2 (1%)
2 (1%)
8 (4%)
Eyelid disorders
6 (3%)
1 (0%)
1 (0%)
8 (4%)
Retinal disorders
5 (2%)
2 (1%)
2 (1%)
9 (4%)
Vision disorders
7 (4%)
4 (2%)
2 (1%)
13 (6%)
Pregnancy, puerperium and perinatal conditions
Breastfeeding issues
4 (2%)
1 (0%)
2 (1%)
7 (4%)
Fetal complications
3 (2%)
2 (1%)
2 (1%)
7 (4%)
Labor and delivery complications
7 (4%)
4 (2%)
1 (0%)
12 (6%)
Pregnancy complications
5 (2%)
1 (0%)
2 (1%)
8 (4%)
Injury, poisoning and procedural complications
Poisonings
3 (2%)
3 (2%)
1 (0%)
1 (0%)
1 (0%)
9 (4%)
Procedural complications
2 (1%)
3 (2%)
2 (1%)
7 (4%)
Radiation-related toxicities
2 (1%)
3 (2%)
2 (1%)
7 (4%)
Traumatic injuries
6 (3%)
1 (0%)
3 (2%)
10 (5%)
Cardiac disorders
Cardiac arrhythmias
5 (2%)
2 (1%)
2 (1%)
9 (4%)
Cardiac valve disorders
2 (1%)
1 (0%)
2 (1%)
1 (0%)
2 (1%)
8 (4%)
Coronary artery disorders
1 (0%)
4 (2%)
1 (0%)
1 (0%)
7 (4%)
Heart failures
5 (2%)
1 (0%)
1 (0%)
1 (0%)
8 (4%)
Immune system disorders
Autoimmune disorders
6 (3%)
1 (0%)
1 (0%)
8 (4%)
Hypersensitivity conditions
4 (2%)
1 (0%)
1 (0%)
1 (0%)
7 (4%)
Immunodeficiency
3 (2%)
1 (0%)
4 (2%)
Inflammatory responses
4 (2%)
5 (2%)
2 (1%)
11 (6%)
Endocrine disorders
Adrenal gland disorders
2 (1%)
5 (2%)
7 (4%)
Parathyroid gland disorders
1 (0%)
3 (2%)
1 (0%)
5 (2%)
Pituitary gland disorders
6 (3%)
2 (1%)
1 (0%)
9 (4%)
Thyroid gland disorders
3 (2%)
1 (0%)
2 (1%)
6 (3%)
Psychiatric disorders
Anxiety disorders
5 (2%)
5 (2%)
Mood disorders
2 (1%)
1 (0%)
3 (2%)
Sleep disorders
8 (4%)
1 (0%)
9 (4%)
Substance-related disorders
2 (1%)
2 (1%)
2 (1%)
1 (0%)
1 (0%)
8 (4%)
Hepatobiliary disorders
Bile duct disorders
4 (2%)
3 (2%)
7 (4%)
Gallbladder disorders
3 (2%)
2 (1%)
5 (2%)
Hepatic failure
3 (2%)
2 (1%)
1 (0%)
1 (0%)
7 (4%)
Liver disorders
3 (2%)
2 (1%)
5 (2%)
Vascular disorders
Hypertension-related conditions
4 (2%)
2 (1%)
1 (0%)
7 (4%)
Hypotension-related conditions
4 (2%)
1 (0%)
1 (0%)
6 (3%)
Vascular hemorrhagic disorders
1 (0%)
2 (1%)
1 (0%)
1 (0%)
5 (2%)
Venous thromboembolic events
3 (2%)
1 (0%)
1 (0%)
5 (2%)
Musculoskeletal and connective tissue disorders
Arthritis and joint disorders
6 (3%)
1 (0%)
1 (0%)
8 (4%)
Bone disorders
2 (1%)
1 (0%)
2 (1%)
5 (2%)
Connective tissue disorders
1 (0%)
2 (1%)
1 (0%)
2 (1%)
6 (3%)
Muscle disorders
2 (1%)
1 (0%)
3 (2%)
Ear and labyrinth disorders
Hearing disorders
2 (1%)
1 (0%)
3 (2%)
Labyrinth disorders
1 (0%)
1 (0%)
Tinnitus
6 (3%)
1 (0%)
7 (4%)
Vertigo and balance disorders
3 (2%)
4 (2%)
7 (4%)
Respiratory, thoracic and mediastinal disorders
Lung function disorders
3 (2%)
3 (2%)
6 (3%)
Pleural disorders
1 (0%)
1 (0%)
1 (0%)
1 (0%)
4 (2%)
Pulmonary vascular disorders
3 (2%)
2 (1%)
1 (0%)
6 (3%)
Respiratory infections
1 (0%)
1 (0%)
2 (1%)
Metabolism and nutrition disorders
Fluid and electrolyte disorders
2 (1%)
1 (0%)
1 (0%)
4 (2%)
Lipid metabolism disorders
1 (0%)
1 (0%)
2 (1%)
Nutritional disorders
4 (2%)
4 (2%)
Vitamin deficiencies
1 (0%)
1 (0%)
2 (1%)
4 (2%)
Nervous system disorders
Headache disorders
3 (2%)
2 (1%)
5 (2%)
Neurological disorders of the central nervous system
3 (2%)
1 (0%)
4 (2%)
Peripheral neuropathies
1 (0%)
1 (0%)
Seizure disorders
2 (1%)
1 (0%)
3 (2%)
General disorders and administration site conditions
Device issues
4 (2%)
1 (0%)
5 (2%)
General physical health deterioration
3 (2%)
3 (2%)
Injection site reactions
1 (0%)
1 (0%)
2 (1%)
Pain and discomfort
2 (1%)
2 (1%)
Skin and subcutaneous tissue disorders
Dermatitis
1 (0%)
1 (0%)
1 (0%)
3 (2%)
Skin and subcutaneous tissue injuries
1 (0%)
2 (1%)
3 (2%)
Skin infections
2 (1%)
2 (1%)
1 (0%)
5 (2%)
Skin pigmentation disorders
1 (0%)
1 (0%)
Infections and infestations
Bacterial infectious disorders
1 (0%)
1 (0%)
Fungal infectious disorders
1 (0%)
1 (0%)
Parasitic infectious disorders
2 (1%)
1 (0%)
3 (2%)
Viral infectious disorders
3 (2%)
2 (1%)
5 (2%)
Blood and lymphatic system disorders
Bone marrow disorders
1 (0%)
1 (0%)
Hematologic neoplasms
4 (2%)
1 (0%)
1 (0%)
6 (3%)
Red blood cell disorders
1 (0%)
1 (0%)
2 (1%)
Gastrointestinal disorders
Esophageal disorders
1 (0%)
1 (0%)
Gastric disorders
2 (1%)
1 (0%)
2 (1%)
5 (2%)
Intestinal disorders
1 (0%)
2 (1%)
3 (2%)
Reproductive system and breast disorders
Breast disorders
2 (1%)
2 (1%)
Female reproductive disorders
2 (1%)
2 (1%)
Male reproductive disorders
2 (1%)
2 (1%)
4 (2%)
Menstrual disorders
1 (0%)
1 (0%)
Investigations
Blood analyses
1 (0%)
1 (0%)
2 (1%)
Cardiovascular assessments
2 (1%)
2 (1%)
Imaging studies
1 (0%)
1 (0%)
2 (1%)
Liver function analyses
1 (0%)
1 (0%)
2 (1%)
Renal and urinary disorders
Bladder disorders
1 (0%)
1 (0%)
2 (1%)
Kidney disorders
1 (0%)
1 (0%)
1 (0%)
3 (2%)
Urinary tract disorders
1 (0%)
1 (0%)
No Declared AE
3 (2%)
3 (2%)