Skip to contents

Overview

This vignette demonstrates how to generate a static AE-specific table reporting patients with drug-related adverse events by treatment group in a gt format.

The workflow uses three functions from metalite.ae:

Related vignettes explain how to customize displayed columns and filter or sort rows. This guide also covers basic gt customization and mock output.

Procedure to generate an AE specific table in gt format

The example uses ADSL and ADAE data from the forestly package.

Step 1: Define metadata

# Define metadata
adsl <- forestly::forestly_adsl
adae <- forestly::forestly_adae

adsl$TRT01A <- factor(
  adsl$TRT01A,
  levels = c("Xanomeline Low Dose", "Placebo"),
  labels = c("Low Dose", "Placebo")
)
adae$TRTA <- factor(
  adae$TRTA,
  levels = c("Xanomeline Low Dose", "Placebo"),
  labels = c("Low Dose", "Placebo")
)

analysis_plan <- metalite::plan(
  analysis = "ae_specific",
  population = "apat",
  observation = "wk12",
  parameter = "rel"
)

meta <- metalite::meta_adam(observation = adae, population = adsl) |>
  metalite::define_plan(analysis_plan) |>
  metalite::define_population(
    name = "apat",
    var = c(
      "USUBJID", "SAFFL", "TRT01A", "TRTDUR",
      "SITEID", "SEX", "RACE", "AGE"
    ),
    group = "TRT01A",
    subset = SAFFL == "Y",
    label = "All Participants as Treated"
  ) |>
  metalite::define_observation(
    name = "wk12",
    var = c(
      "USUBJID", "SAFFL", "TRTA", "AEDECOD", "AEBODSYS", "AEREL",
      "AESER", "AEOUT", "AEACN", "AESDTH", "ASTDT", "AENDT"
    ),
    group = "TRTA",
    subset = SAFFL == "Y",
    label = "Weeks 0 to 12"
  ) |>
  metalite::define_parameter(
    name = "rel",
    term1 = "Drug-Related",
    term2 = "",
    subset = AEREL %in% c("POSSIBLE", "PROBABLE"),
    var = "AEDECOD",
    soc = "AEBODSYS",
    label = "Drug-related AEs"
  ) |>
  metalite::define_analysis(
    name = "ae_specific",
    title = "Participants with Drug-Related Adverse Events"
  ) |>
  metalite::meta_build()
Click to show the output
meta
#> ADaM metadata: 
#>    .$data_population     Population data with 170 subjects 
#>    .$data_observation    Observation data with 736 records 
#>    .$plan    Analysis plan with 1 plans 
#> 
#> 
#>   Analysis population type:
#>     name        id    group
#> 1 'apat' 'USUBJID' 'TRT01A'
#>                                                      var       subset
#> 1 USUBJID, SAFFL, TRT01A, TRTDUR, SITEID, SEX, RACE, AGE SAFFL == 'Y'
#>                           label
#> 1 'All Participants as Treated'
#> 
#> 
#>   Analysis observation type:
#>     name        id  group
#> 1 'wk12' 'USUBJID' 'TRTA'
#>                                                                                         var
#> 1 USUBJID, SAFFL, TRTA, AEDECOD, AEBODSYS, AEREL, AESER, AEOUT, AEACN, AESDTH, ASTDT, AENDT
#>         subset           label
#> 1 SAFFL == 'Y' 'Weeks 0 to 12'
#> 
#> 
#>   Analysis parameter type:
#>    name              label                               subset
#> 1 'rel' 'Drug-related AEs' AEREL %in% c('POSSIBLE', 'PROBABLE')
#> 
#> 
#>   Analysis function:
#>            name                           label
#> 1 'ae_specific' 'Table: specific adverse event'

Step 2: Generate the AE specific table

prepare_ae_specific() uses the population, observation, and parameter definitions in meta to calculate the AE-specific analysis results. It returns an outdata object for formatting and reporting.

prepare_ae_specific(
  meta,
  population = "apat",
  observation = "wk12",
  parameter = "rel"
) |>
  format_ae_specific() |>
  gt_ae_specific(
    meddra_version = "24.0",
    source = "Source:  [CDISCpilot: adam-adsl; adae]",
    analysis = "ae_specific"
  )
Participants with Drug-Related Adverse Events
(Incidence > 0 % in One or More Treatment Groups)
Weeks 0 to 12
All Participants as Treated
Low Dose
Placebo
Total
n (%) n (%) n (%)
Participants in population 84
86
170
with one or more drug-related adverse events 73 (86.9) 44 (51.2) 117 (68.8)
with no drug-related adverse events 11 (13.1) 42 (48.8) 53 (31.2)






Cardiac disorders 7 (8.3) 6 (7.0) 13 (7.6)
Atrial fibrillation 0 (0.0) 1 (1.2) 1 (0.6)
Atrial flutter 1 (1.2) 0 (0.0) 1 (0.6)
Atrioventricular block first degree 0 (0.0) 1 (1.2) 1 (0.6)
Atrioventricular block second degree 0 (0.0) 1 (1.2) 1 (0.6)
Bradycardia 0 (0.0) 1 (1.2) 1 (0.6)
Bundle branch block right 1 (1.2) 0 (0.0) 1 (0.6)
Cardiac failure congestive 0 (0.0) 1 (1.2) 1 (0.6)
Myocardial infarction 1 (1.2) 2 (2.3) 3 (1.8)
Palpitations 1 (1.2) 0 (0.0) 1 (0.6)
Sinus arrhythmia 0 (0.0) 1 (1.2) 1 (0.6)
Sinus bradycardia 2 (2.4) 2 (2.3) 4 (2.4)
Supraventricular extrasystoles 1 (1.2) 0 (0.0) 1 (0.6)
Ventricular extrasystoles 1 (1.2) 0 (0.0) 1 (0.6)
Wolff-parkinson-white syndrome 1 (1.2) 0 (0.0) 1 (0.6)
Congenital, familial and genetic disorders 1 (1.2) 0 (0.0) 1 (0.6)
Ventricular septal defect 1 (1.2) 0 (0.0) 1 (0.6)
Ear and labyrinth disorders 2 (2.4) 0 (0.0) 2 (1.2)
Tinnitus 1 (1.2) 0 (0.0) 1 (0.6)
Vertigo 1 (1.2) 0 (0.0) 1 (0.6)
Eye disorders 1 (1.2) 0 (0.0) 1 (0.6)
Vision blurred 1 (1.2) 0 (0.0) 1 (0.6)
Gastrointestinal disorders 8 (9.5) 4 (4.7) 12 (7.1)
Abdominal pain 1 (1.2) 0 (0.0) 1 (0.6)
Diarrhoea 3 (3.6) 3 (3.5) 6 (3.5)
Dyspepsia 1 (1.2) 1 (1.2) 2 (1.2)
Gastrooesophageal reflux disease 0 (0.0) 1 (1.2) 1 (0.6)
Nausea 3 (3.6) 0 (0.0) 3 (1.8)
Vomiting 2 (2.4) 0 (0.0) 2 (1.2)
General disorders and administration site conditions 43 (51.2) 18 (20.9) 61 (35.9)
Application site bleeding 1 (1.2) 0 (0.0) 1 (0.6)
Application site dermatitis 9 (10.7) 5 (5.8) 14 (8.2)
Application site desquamation 1 (1.2) 0 (0.0) 1 (0.6)
Application site discolouration 1 (1.2) 0 (0.0) 1 (0.6)
Application site erythema 12 (14.3) 3 (3.5) 15 (8.8)
Application site induration 0 (0.0) 1 (1.2) 1 (0.6)
Application site irritation 9 (10.7) 3 (3.5) 12 (7.1)
Application site pruritus 22 (26.2) 6 (7.0) 28 (16.5)
Application site reaction 0 (0.0) 1 (1.2) 1 (0.6)
Application site swelling 1 (1.2) 0 (0.0) 1 (0.6)
Application site urticaria 2 (2.4) 0 (0.0) 2 (1.2)
Application site vesicles 4 (4.8) 1 (1.2) 5 (2.9)
Application site warmth 1 (1.2) 0 (0.0) 1 (0.6)
Asthenia 0 (0.0) 1 (1.2) 1 (0.6)
Chills 1 (1.2) 1 (1.2) 2 (1.2)
Fatigue 2 (2.4) 1 (1.2) 3 (1.8)
Malaise 1 (1.2) 0 (0.0) 1 (0.6)
Oedema 2 (2.4) 0 (0.0) 2 (1.2)
Pain 1 (1.2) 0 (0.0) 1 (0.6)
Injury, poisoning and procedural complications 2 (2.4) 0 (0.0) 2 (1.2)
Fall 1 (1.2) 0 (0.0) 1 (0.6)
Skin laceration 1 (1.2) 0 (0.0) 1 (0.6)
Wound 1 (1.2) 0 (0.0) 1 (0.6)
Investigations 2 (2.4) 4 (4.7) 6 (3.5)
Blood creatine phosphokinase increased 0 (0.0) 1 (1.2) 1 (0.6)
Body temperature increased 1 (1.2) 0 (0.0) 1 (0.6)
Electrocardiogram st segment depression 1 (1.2) 1 (1.2) 2 (1.2)
Heart rate increased 0 (0.0) 1 (1.2) 1 (0.6)
Heart rate irregular 0 (0.0) 1 (1.2) 1 (0.6)
Metabolism and nutrition disorders 0 (0.0) 3 (3.5) 3 (1.8)
Decreased appetite 0 (0.0) 1 (1.2) 1 (0.6)
Food craving 0 (0.0) 1 (1.2) 1 (0.6)
Increased appetite 0 (0.0) 1 (1.2) 1 (0.6)
Musculoskeletal and connective tissue disorders 0 (0.0) 1 (1.2) 1 (0.6)
Shoulder pain 0 (0.0) 1 (1.2) 1 (0.6)
Nervous system disorders 12 (14.3) 5 (5.8) 17 (10.0)
Balance disorder 1 (1.2) 0 (0.0) 1 (0.6)
Complex partial seizures 1 (1.2) 0 (0.0) 1 (0.6)
Coordination abnormal 1 (1.2) 0 (0.0) 1 (0.6)
Dizziness 6 (7.1) 2 (2.3) 8 (4.7)
Headache 1 (1.2) 2 (2.3) 3 (1.8)
Lethargy 1 (1.2) 0 (0.0) 1 (0.6)
Paraesthesia oral 1 (1.2) 0 (0.0) 1 (0.6)
Somnolence 0 (0.0) 1 (1.2) 1 (0.6)
Stupor 1 (1.2) 0 (0.0) 1 (0.6)
Syncope 4 (4.8) 0 (0.0) 4 (2.4)
Transient ischaemic attack 1 (1.2) 0 (0.0) 1 (0.6)
Psychiatric disorders 9 (10.7) 2 (2.3) 11 (6.5)
Agitation 2 (2.4) 0 (0.0) 2 (1.2)
Anxiety 3 (3.6) 0 (0.0) 3 (1.8)
Confusional state 2 (2.4) 1 (1.2) 3 (1.8)
Depressed mood 1 (1.2) 0 (0.0) 1 (0.6)
Irritability 1 (1.2) 1 (1.2) 2 (1.2)
Restlessness 1 (1.2) 0 (0.0) 1 (0.6)
Renal and urinary disorders 1 (1.2) 0 (0.0) 1 (0.6)
Enuresis 1 (1.2) 0 (0.0) 1 (0.6)
Reproductive system and breast disorders 0 (0.0) 1 (1.2) 1 (0.6)
Pelvic pain 0 (0.0) 1 (1.2) 1 (0.6)
Respiratory, thoracic and mediastinal disorders 0 (0.0) 2 (2.3) 2 (1.2)
Dyspnoea 0 (0.0) 1 (1.2) 1 (0.6)
Emphysema 0 (0.0) 1 (1.2) 1 (0.6)
Skin and subcutaneous tissue disorders 39 (46.4) 17 (19.8) 56 (32.9)
Blister 5 (6.0) 0 (0.0) 5 (2.9)
Cold sweat 0 (0.0) 1 (1.2) 1 (0.6)
Dermatitis contact 1 (1.2) 0 (0.0) 1 (0.6)
Erythema 13 (15.5) 9 (10.5) 22 (12.9)
Hyperhidrosis 4 (4.8) 1 (1.2) 5 (2.9)
Pruritus 21 (25.0) 7 (8.1) 28 (16.5)
Pruritus generalised 1 (1.2) 0 (0.0) 1 (0.6)
Rash 11 (13.1) 3 (3.5) 14 (8.2)
Rash erythematous 2 (2.4) 0 (0.0) 2 (1.2)
Rash pruritic 1 (1.2) 0 (0.0) 1 (0.6)
Skin exfoliation 1 (1.2) 0 (0.0) 1 (0.6)
Skin irritation 6 (7.1) 2 (2.3) 8 (4.7)
Skin ulcer 0 (0.0) 1 (1.2) 1 (0.6)
Urticaria 1 (1.2) 0 (0.0) 1 (0.6)
Vascular disorders 2 (2.4) 1 (1.2) 3 (1.8)
Hypertension 1 (1.2) 0 (0.0) 1 (0.6)
Hypotension 1 (1.2) 1 (1.2) 2 (1.2)
Orthostatic hypotension 0 (0.0) 1 (1.2) 1 (0.6)
Every participant is counted a single time for each applicable row and column.
A system organ class or specific adverse event appears on this report only if its incidence in one or more of the columns meets the incidence criterion in the report title, after rounding.
Adverse event terms are from MedDRA Version 24.0.
Source: [CDISCpilot: adam-adsl; adae]