Skip to contents

[Stable]
The function ae_table_soc() creates a summary table of AE grades for each patient by group (usually according CTCAE SOC or term). The resulting dataframe can be piped to as_flextable() to get a nicely formatted flextable.

Usage

ae_table_soc(
  data_ae,
  ...,
  data_pat,
  measure = c("max", "sup", "eq"),
  group1 = "AESOC",
  group2 = NULL,
  arm = NULL,
  cols = c(grade = "AEGR", subjid = "SUBJID"),
  ae_groups = NULL,
  ae_label = "AE",
  sort_by_count = TRUE,
  total = TRUE,
  showNA = TRUE,
  digits = 0,
  warn_miss = FALSE
)

# S3 method for class 'ae_table_soc'
as_flextable(
  x,
  ...,
  show_footer = c("both", "explanation", "example", "none"),
  arm_colors = c("#f2dcdb", "#dbe5f1", "#ebf1dd", "#e5e0ec"),
  padding_v = NULL
)

Arguments

data_ae

adverse event dataset, one row per AE, containing subjid, grade, group1, and potentially group2.

...

unused

data_pat

enrollment dataset, one row per patient, containing subjid (and arm if needed). All patients should be in this dataset.

measure

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, and eq computes the number of patients having experienced at least one AE of grade equal to X.

group1, group2

name of the 1st and 2nd order grouping columns in data_ae. Case-insensitive. Use labels for the flextable output. Usually, group1 is the SOC and group2 the term, but it can be any other grouping variable. group2 can be set to NULL if not needed.

arm

name of the treatment column in data_pat. Case-insensitive. Can be set to NULL.

cols

a named character vector mapping column names. Should contain at least grade and subjid. Case-insensitive.

ae_groups

a named list specifying the grade values for each group.

ae_label

Label used in the output tables (e.g. "AE", "SAE", "Toxicity").

sort_by_count

whether to sort by the number of AE or by group1 alphabetically.

total

whether to add a total column for each arm.

showNA

whether to display missing grades. Only relevant if ae_groups is not used.

digits

significant digits for percentages.

warn_miss

whether to warn for missing values.

x

a dataframe, resulting of ae_table_soc()

whether to show the footer with the explanation, the example, both, or none.

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)

Value

a dataframe (ae_table_soc()) or a flextable (as_flextable()).

a formatted flextable

Examples

tm = grstat_example()
attach(tm, warn.conflicts=FALSE)

#Default
ae_table_soc(data_ae=ae, data_pat=enrolres) %>%
  as_flextable()

All patients (N=200)

AE SOC

G1

G2

G3

G4

G5

NA

Tot

Eye disorders

21 (10%)

16 (8%)

9 (4%)

3 (2%)

49 (24%)

Social circumstances

27 (14%)

12 (6%)

6 (3%)

4 (2%)

49 (24%)

Congenital, familial and genetic disorders

23 (12%)

10 (5%)

4 (2%)

5 (2%)

42 (21%)

Injury, poisoning and procedural complications

17 (8%)

13 (6%)

3 (2%)

2 (1%)

35 (18%)

Immune system disorders

15 (8%)

9 (4%)

7 (4%)

3 (2%)

34 (17%)

Pregnancy, puerperium and perinatal conditions

14 (7%)

12 (6%)

4 (2%)

3 (2%)

33 (16%)

Neoplasms benign, malignant, and unspecified

12 (6%)

12 (6%)

4 (2%)

2 (1%)

30 (15%)

Hepatobiliary disorders

17 (8%)

8 (4%)

1 (0%)

2 (1%)

28 (14%)

Surgical and medical procedures

13 (6%)

10 (5%)

4 (2%)

1 (0%)

28 (14%)

Cardiac disorders

11 (6%)

4 (2%)

7 (4%)

4 (2%)

26 (13%)

Respiratory, thoracic and mediastinal disorders

11 (6%)

6 (3%)

5 (2%)

1 (0%)

1 (0%)

24 (12%)

Ear and labyrinth disorders

7 (4%)

7 (4%)

4 (2%)

18 (9%)

Endocrine disorders

11 (6%)

2 (1%)

2 (1%)

1 (0%)

16 (8%)

Psychiatric disorders

10 (5%)

2 (1%)

3 (2%)

1 (0%)

16 (8%)

Vascular disorders

10 (5%)

3 (2%)

1 (0%)

2 (1%)

16 (8%)

Infections and infestations

10 (5%)

3 (2%)

1 (0%)

1 (0%)

15 (8%)

Musculoskeletal and connective tissue disorders

5 (2%)

3 (2%)

4 (2%)

1 (0%)

2 (1%)

15 (8%)

Nervous system disorders

5 (2%)

6 (3%)

1 (0%)

12 (6%)

Investigations

7 (4%)

1 (0%)

3 (2%)

11 (6%)

Blood and lymphatic system disorders

3 (2%)

3 (2%)

3 (2%)

1 (0%)

10 (5%)

Metabolism and nutrition disorders

8 (4%)

2 (1%)

10 (5%)

Skin and subcutaneous tissue disorders

6 (3%)

3 (2%)

1 (0%)

10 (5%)

General disorders and administration site conditions

2 (1%)

5 (2%)

2 (1%)

9 (4%)

Gastrointestinal disorders

5 (2%)

1 (0%)

1 (0%)

7 (4%)

Renal and urinary disorders

5 (2%)

1 (0%)

1 (0%)

7 (4%)

Reproductive system and breast disorders

3 (2%)

2 (1%)

2 (1%)

7 (4%)

No Declared AE

8 (4%)

8 (4%)

Figures represent the number of patients who experienced an AE of maximum grade, for a given AE SOC.

For example, for AE with AE SOC "Eye disorders", the maximum grade was G2 for 16 (8%) patients.

#By arm, with alternative measure ae_table_soc(data_ae=ae, data_pat=enrolres, arm="arm", measure="sup", total=FALSE) %>% as_flextable()

Control (N=100)

Treatment (N=100)

AE SOC

G1

G2

G3

G4

G5

NA

G1

G2

G3

G4

G5

NA

Eye disorders

31 (31%)

17 (17%)

6 (6%)

2 (2%)

18 (18%)

11 (11%)

6 (6%)

1 (1%)

Social circumstances

27 (27%)

11 (11%)

3 (3%)

22 (22%)

11 (11%)

7 (7%)

4 (4%)

Congenital, familial and genetic disorders

20 (20%)

10 (10%)

3 (3%)

1 (1%)

22 (22%)

9 (9%)

6 (6%)

4 (4%)

Immune system disorders

18 (18%)

10 (10%)

6 (6%)

2 (2%)

16 (16%)

9 (9%)

4 (4%)

1 (1%)

Pregnancy, puerperium and perinatal conditions

16 (16%)

9 (9%)

4 (4%)

2 (2%)

17 (17%)

10 (10%)

3 (3%)

1 (1%)

Injury, poisoning and procedural complications

22 (22%)

10 (10%)

2 (2%)

1 (1%)

13 (13%)

8 (8%)

3 (3%)

1 (1%)

Cardiac disorders

14 (14%)

7 (7%)

4 (4%)

12 (12%)

8 (8%)

7 (7%)

4 (4%)

Neoplasms benign, malignant, and unspecified

17 (17%)

11 (11%)

4 (4%)

1 (1%)

13 (13%)

7 (7%)

2 (2%)

1 (1%)

Surgical and medical procedures

13 (13%)

7 (7%)

2 (2%)

15 (15%)

8 (8%)

3 (3%)

1 (1%)

Respiratory, thoracic and mediastinal disorders

11 (11%)

4 (4%)

1 (1%)

13 (13%)

9 (9%)

6 (6%)

2 (2%)

1 (1%)

Hepatobiliary disorders

14 (14%)

5 (5%)

2 (2%)

2 (2%)

14 (14%)

6 (6%)

1 (1%)

Musculoskeletal and connective tissue disorders

11 (11%)

7 (7%)

5 (5%)

3 (3%)

2 (2%)

4 (4%)

3 (3%)

2 (2%)

Ear and labyrinth disorders

8 (8%)

4 (4%)

2 (2%)

10 (10%)

7 (7%)

2 (2%)

Psychiatric disorders

6 (6%)

2 (2%)

1 (1%)

10 (10%)

4 (4%)

3 (3%)

1 (1%)

Vascular disorders

7 (7%)

1 (1%)

9 (9%)

5 (5%)

3 (3%)

2 (2%)

Endocrine disorders

11 (11%)

2 (2%)

2 (2%)

1 (1%)

5 (5%)

3 (3%)

1 (1%)

Infections and infestations

11 (11%)

3 (3%)

4 (4%)

2 (2%)

2 (2%)

1 (1%)

1 (1%)

Blood and lymphatic system disorders

3 (3%)

3 (3%)

2 (2%)

1 (1%)

7 (7%)

4 (4%)

2 (2%)

Nervous system disorders

5 (5%)

3 (3%)

7 (7%)

4 (4%)

1 (1%)

1 (1%)

General disorders and administration site conditions

6 (6%)

6 (6%)

2 (2%)

3 (3%)

1 (1%)

Investigations

7 (7%)

2 (2%)

1 (1%)

4 (4%)

2 (2%)

2 (2%)

Skin and subcutaneous tissue disorders

4 (4%)

2 (2%)

1 (1%)

1 (1%)

6 (6%)

2 (2%)

Reproductive system and breast disorders

3 (3%)

2 (2%)

1 (1%)

4 (4%)

2 (2%)

1 (1%)

Metabolism and nutrition disorders

5 (5%)

1 (1%)

5 (5%)

1 (1%)

Renal and urinary disorders

4 (4%)

1 (1%)

1 (1%)

3 (3%)

1 (1%)

1 (1%)

1 (1%)

Gastrointestinal disorders

4 (4%)

2 (2%)

1 (1%)

1 (1%)

3 (3%)

No Declared AE

Figures represent the number of patients who experienced at least one AE of grade ≥ X, for a given arm and AE SOC.

For example, for AE in Control arm and with AE SOC "Eye disorders", at least one AE of grade ≥ G2 was reported for 17 (17%) patients.

#Sub-population, without footer ae_table_soc(data_ae=ae, data_pat=head(enrolres, 10), arm="arm") %>% as_flextable(show_footer="none")

Control (N=5)

Treatment (N=5)

AE SOC

G1

G2

G3

G4

G5

NA

Tot

G1

G2

G3

G4

G5

NA

Tot

Eye disorders

3 (60%)

1 (20%)

4 (80%)

1 (20%)

1 (20%)

Pregnancy, puerperium and perinatal conditions

3 (60%)

1 (20%)

4 (80%)

Psychiatric disorders

1 (20%)

1 (20%)

1 (20%)

1 (20%)

2 (40%)

Social circumstances

1 (20%)

1 (20%)

1 (20%)

1 (20%)

2 (40%)

Cardiac disorders

1 (20%)

1 (20%)

1 (20%)

1 (20%)

Metabolism and nutrition disorders

1 (20%)

1 (20%)

1 (20%)

1 (20%)

Neoplasms benign, malignant, and unspecified

2 (40%)

2 (40%)

Surgical and medical procedures

1 (20%)

1 (20%)

2 (40%)

Congenital, familial and genetic disorders

1 (20%)

1 (20%)

Ear and labyrinth disorders

1 (20%)

1 (20%)

Infections and infestations

1 (20%)

1 (20%)

Injury, poisoning and procedural complications

1 (20%)

1 (20%)

Investigations

1 (20%)

1 (20%)

Musculoskeletal and connective tissue disorders

1 (20%)

1 (20%)

Respiratory, thoracic and mediastinal disorders

1 (20%)

1 (20%)

Vascular disorders

1 (20%)

1 (20%)

#Grouping grades, with only TERM ae_groups = list("Any grade"=c(1:5,NA), "Grade 1-2"=1:2, "Grade 3-5"=3:5) ae_table_soc(data_ae=ae, data_pat=head(enrolres, 10), group1="AETERM", ae_groups=ae_groups) %>% as_flextable()

All patients (N=10)

AE Term (HLGT)

Any grade

Grade 1-2

Grade 3-5

Tot

Cardiac arrhythmias

2 (20%)

2 (20%)

2 (20%)

Corneal disorders

2 (20%)

2 (20%)

2 (20%)

Cultural issues

2 (20%)

1 (10%)

1 (10%)

2 (20%)

Fetal complications

2 (20%)

2 (20%)

2 (20%)

Labor and delivery complications

2 (20%)

2 (20%)

2 (20%)

Retinal disorders

2 (20%)

1 (10%)

1 (10%)

2 (20%)

Substance-related disorders

2 (20%)

2 (20%)

2 (20%)

Therapeutic procedures

2 (20%)

1 (10%)

1 (10%)

2 (20%)

Benign neoplasms

1 (10%)

1 (10%)

1 (10%)

Cardiovascular assessments

1 (10%)

1 (10%)

1 (10%)

Connective tissue disorders

1 (10%)

1 (10%)

1 (10%)

Eyelid disorders

1 (10%)

1 (10%)

1 (10%)

Family support issues

1 (10%)

1 (10%)

1 (10%)

Fungal infectious disorders

1 (10%)

1 (10%)

1 (10%)

Hereditary connective tissue disorders

1 (10%)

1 (10%)

1 (10%)

Hypotension-related conditions

1 (10%)

1 (10%)

1 (10%)

Lung function disorders

1 (10%)

1 (10%)

1 (10%)

Mood disorders

1 (10%)

1 (10%)

1 (10%)

Neoplasms unspecified

1 (10%)

1 (10%)

1 (10%)

Nutritional disorders

1 (10%)

1 (10%)

1 (10%)

Procedural complications

1 (10%)

1 (10%)

1 (10%)

Social and environmental issues

1 (10%)

1 (10%)

1 (10%)

Surgical complications

1 (10%)

1 (10%)

1 (10%)

Tinnitus

1 (10%)

1 (10%)

1 (10%)

Vision disorders

1 (10%)

1 (10%)

1 (10%)

Vitamin deficiencies

1 (10%)

1 (10%)

1 (10%)

Figures represent the number of patients who experienced an AE of maximum grade, for a given AE Term (HLGT).

For example, for AE with AE Term (HLGT) "Cardiac arrhythmias", the maximum grade was Grade 1-2 for 2 (20%) patients.

#Stratified by both SOC and TERM ae_table_soc(data_ae=ae, data_pat=head(enrolres, 10), arm="arm", group1="AESOC", group2="AETERM") %>% dplyr::filter(!is.na(group2)) %>% #remove missing term as_flextable()

Control (N=5)

Treatment (N=5)

AE SOC

AE Term (HLGT)

G1

G2

G3

G4

G5

NA

Tot

G1

G2

G3

G4

G5

NA

Tot

Eye disorders

Corneal disorders

2 (40%)

2 (40%)

Eyelid disorders

1 (20%)

1 (20%)

Retinal disorders

1 (20%)

1 (20%)

2 (40%)

Vision disorders

1 (20%)

1 (20%)

Pregnancy, puerperium and perinatal conditions

Fetal complications

1 (20%)

1 (20%)

2 (40%)

Labor and delivery complications

2 (40%)

2 (40%)

Social circumstances

Cultural issues

1 (20%)

1 (20%)

1 (20%)

1 (20%)

Family support issues

1 (20%)

1 (20%)

Social and environmental issues

1 (20%)

1 (20%)

Psychiatric disorders

Mood disorders

1 (20%)

1 (20%)

Substance-related disorders

1 (20%)

1 (20%)

1 (20%)

1 (20%)

Surgical and medical procedures

Surgical complications

1 (20%)

1 (20%)

Therapeutic procedures

1 (20%)

1 (20%)

2 (40%)

Cardiac disorders

Cardiac arrhythmias

1 (20%)

1 (20%)

1 (20%)

1 (20%)

Metabolism and nutrition disorders

Nutritional disorders

1 (20%)

1 (20%)

Vitamin deficiencies

1 (20%)

1 (20%)

Neoplasms benign, malignant, and unspecified

Benign neoplasms

1 (20%)

1 (20%)

Neoplasms unspecified

1 (20%)

1 (20%)

Congenital, familial and genetic disorders

Hereditary connective tissue disorders

1 (20%)

1 (20%)

Ear and labyrinth disorders

Tinnitus

1 (20%)

1 (20%)

Infections and infestations

Fungal infectious disorders

1 (20%)

1 (20%)

Injury, poisoning and procedural complications

Procedural complications

1 (20%)

1 (20%)

Investigations

Cardiovascular assessments

1 (20%)

1 (20%)

Musculoskeletal and connective tissue disorders

Connective tissue disorders

1 (20%)

1 (20%)

Respiratory, thoracic and mediastinal disorders

Lung function disorders

1 (20%)

1 (20%)

Vascular disorders

Hypotension-related conditions

1 (20%)

1 (20%)

Figures represent the number of patients who experienced an AE of maximum grade, for a given arm, AE SOC, and AE Term (HLGT).

For example, for AE in Control arm, with AE SOC "Pregnancy, puerperium and perinatal conditions", and AE Term (HLGT) "Fetal complications", the maximum grade was G2 for 1 (20%) patients.