Subject disposition

inTextSummaryTable

 # data of interest
data_in <- dataAll$ADSL

varDMFL <- grep("FL$", colnames(data_in), value = TRUE)
varDMFLLabel <- sub(" Flag$", "", labelVars[varDMFL])

getSummaryStatisticsTable(
    data = data_in,
    var = varDMFL, varFlag = varDMFL, varGeneralLab = "Analysis Set, N", 
    varLab = varDMFLLabel,
    stats = getStats("n (%)"),
    colVar = "TRT01P",
    labelVars = labelVars,
    colTotalInclude = TRUE, colTotalLab = "All subjects",
    varInclude0 = TRUE,
    title = tools::toTitleCase("Table: subject disposition")
    # file = file.path("tables_CSR", "Table_subjectDisposition.docx")
)

Table: Subject Disposition

Analysis Set, N

Placebo
(N=2)

Xanomeline High Dose
(N=3)

Xanomeline Low Dose
(N=2)

All subjects
(N=7)

Safety Population

2 (100)

3 (100)

2 (100)

7 (100)

Intent-to-Treat Population

2 (100)

3 (100)

2 (100)

7 (100)

Efficacy Population

1 (50.0)

3 (100)

2 (100)

6 (85.7)

Completers of Week 8 Population

1 (50.0)

3 (100)

2 (100)

6 (85.7)

Completers of Week 16 Population

1 (50.0)

1 (33.3)

1 (50.0)

3 (42.9)

Completers of Week 24 Population

1 (50.0)

1 (33.3)

1 (50.0)

3 (42.9)

Did the Subject Discontinue the Study?

2 (100)

2 (66.7)

1 (50.0)

5 (71.4)

Discontinued due to AE?

0

1 (33.3)

0

1 (14.3)

Subject Died?

2 (100)

0

1 (50.0)

3 (42.9)

gtsummary

data_in <- dataAll$ADSL

# Identify flag variables ending in "FL"
varDMFL <- grep("FL$", colnames(data_in), value = TRUE)

# Get label replacements: named list of formulas
varDMFLLabel <- setNames(
  sub(" Flag$", "", labelVars[varDMFL]),
  varDMFL
)
label_list <- map2(varDMFL, varDMFLLabel, ~ as.formula(paste0(.x, ' ~ "', .y, '"')))

# Optional: Ensure all flag variables are factors
data_in[varDMFL] <- lapply(data_in[varDMFL], factor)

# Generate the table
data_in %>%
  select(TRT01P, all_of(varDMFL)) %>%
  tbl_summary(
    by = TRT01P,
    type = all_of(varDMFL) ~ "categorical",
    statistic = all_categorical() ~ "{n} ({p}%)",
    label = label_list,
    missing = "no"
  ) %>%
  add_overall(last = TRUE, col_label = "All subjects") %>%
  modify_caption("**Table: Subject Disposition**")
Table: Subject Disposition
Characteristic Placebo
N = 2
1
Xanomeline High Dose
N = 3
1
Xanomeline Low Dose
N = 2
1
All subjects1
Safety Population



    Y 2 (100%) 3 (100%) 2 (100%) 7 (100%)
Intent-to-Treat Population



    Y 2 (100%) 3 (100%) 2 (100%) 7 (100%)
Efficacy Population



    N 1 (50%) 0 (0%) 0 (0%) 1 (14%)
    Y 1 (50%) 3 (100%) 2 (100%) 6 (86%)
Completers of Week 8 Population



    N 1 (50%) 0 (0%) 0 (0%) 1 (14%)
    Y 1 (50%) 3 (100%) 2 (100%) 6 (86%)
Completers of Week 16 Population



    N 1 (50%) 2 (67%) 1 (50%) 4 (57%)
    Y 1 (50%) 1 (33%) 1 (50%) 3 (43%)
Completers of Week 24 Population



    N 1 (50%) 2 (67%) 1 (50%) 4 (57%)
    Y 1 (50%) 1 (33%) 1 (50%) 3 (43%)
Did the Subject Discontinue the Study?



     0 (0%) 1 (33%) 1 (50%) 2 (29%)
    Y 2 (100%) 2 (67%) 1 (50%) 5 (71%)
Discontinued due to AE?



     2 (100%) 2 (67%) 2 (100%) 6 (86%)
    Y 0 (0%) 1 (33%) 0 (0%) 1 (14%)
Subject Died?



     0 (0%) 3 (100%) 1 (50%) 4 (57%)
    Y 2 (100%) 0 (0%) 1 (50%) 3 (43%)
1 n (%)

Demographics

inTextSummaryTable

# data of interest
data_in <- subset(dataAll$ADSL, SAFFL == "Y")

# variables of interest
# Note: if available: ethnicity is included
varsDM <- c(
  "SEX", "AGE", "AGEGR1",
  "RACE", "ETHNIC",
  "HEIGHTBL", "WEIGHTBL", 
  "BMIBL", "BMIBLGR1"
)

# Sort variables according to corresponding numeric variable
data_in$AGEGR1 <- with(data_in, reorder(AGEGR1, AGEGR1N))
data_in$RACE <- with(data_in, reorder(RACE, RACEN))
data_in$TRT01P <- with(data_in, reorder(TRT01P, TRT01PN))

## Define set of statistics of interest:
statsDM <- getStatsData(
  data = data_in, var = varsDM,
  # different for continuous and categorical variable
  # type = c(cont = "median (range)", cat = "n (%)"),
  type = c(cont = "n", cont = "mean (sd)",cont = "median\n(range)", 
         cat = "n (%)"),
  # for categorical variable, statistic name (here: 'n (%)')
  # should not be included in the table
  args = list(cat = list(includeName = FALSE))
)

## create the table:

getSummaryStatisticsTable(
  data = data_in, 
  # variables to summarize
  var = varsDM, 
  varGeneralLab = "Parameter",
  # column
  colVar = "TRT01P", colTotalInclude = TRUE, colTotalLab = "All subjects",
  # statistics
  stats = statsDM,
  statsGeneralLab = "",
  labelVars = labelVars,
  # if only one category, should be included in separated row (e.g. RACE: White)
  rowAutoMerge = FALSE,
  rowInclude0 = FALSE, emptyValue = 0,
  title = tools::toTitleCase("Table: Demographic Data (safety Analysis Set)")
  # file = file.path("tables_CSR", "Table_demographicData.docx")
)

Table: Demographic Data (Safety Analysis Set)

Parameter

Placebo
(N=2)

Xanomeline Low Dose
(N=2)

Xanomeline High Dose
(N=3)

All subjects
(N=7)

Variable group

Sex

F

1 (50.0)

2 (100)

2 (66.7)

5 (71.4)

M

1 (50.0)

0

1 (33.3)

2 (28.6)

Age

n

2

2

3

7

Mean (SD)

82.0 (9.9)

78.0 (2.8)

66.7 (8.7)

74.3 (9.8)

Median
(range)

82.0
(75,89)

78.0
(76,80)

69.0
(57,74)

75.0
(57,89)

Pooled Age Group 1

<65

0

0

1 (33.3)

1 (14.3)

65-80

1 (50.0)

2 (100)

2 (66.7)

5 (71.4)

>80

1 (50.0)

0

0

1 (14.3)

Race

WHITE

2 (100)

2 (100)

2 (66.7)

6 (85.7)

BLACK OR AFRICAN AMERICAN

0

0

1 (33.3)

1 (14.3)

Ethnicity

NOT HISPANIC OR LATINO

2 (100)

2 (100)

3 (100)

7 (100)

Baseline Height (cm)

n

2

2

3

7

Mean (SD)

167.65 (14.35)

155.55 (6.29)

163.00 (10.83)

162.20 (10.25)

Median
(range)

167.65
(157.5,177.8)

155.55
(151.1,160.0)

158.80
(154.9,175.3)

158.80
(151.1,177.8)

Baseline Weight (kg)

n

2

2

3

7

Mean (SD)

59.65 (17.61)

54.45 (12.80)

68.50 (17.77)

61.96 (15.04)

Median
(range)

59.65
(47.2,72.1)

54.45
(45.4,63.5)

66.70
(51.7,87.1)

63.50
(45.4,87.1)

Baseline BMI (kg/m^2)

n

2

2

3

7

Mean (SD)

20.90 (2.69)

22.75 (7.14)

25.53 (4.37)

23.41 (4.53)

Median
(range)

20.90
(19.0,22.8)

22.75
(17.7,27.8)

27.80
(20.5,28.3)

22.80
(17.7,28.3)

Pooled Baseline BMI Group 1

<25

2 (100)

1 (50.0)

1 (33.3)

4 (57.1)

25-<30

0

1 (50.0)

2 (66.7)

3 (42.9)

gtsummary

# Subset Safety Analysis Set
data_in <- subset(dataAll$ADSL, SAFFL == "Y")

# Variables of interest
varsDM <- c(
  "SEX", "AGE", "AGEGR1",
  "RACE", "ETHNIC",
  "HEIGHTBL", "WEIGHTBL", 
  "BMIBL", "BMIBLGR1"
)

# Reorder factor levels
data_in <- data_in %>%
  mutate(
    AGEGR1 = fct_reorder(AGEGR1, AGEGR1N),
    RACE = fct_reorder(RACE, RACEN),
    TRT01P = fct_reorder(TRT01P, TRT01PN)
  )

# Identify variable types
cont_vars <- varsDM[sapply(data_in[varsDM], is.numeric)]
cat_vars  <- setdiff(varsDM, cont_vars)

# Format type list
type_list <- c(
  lapply(cont_vars, function(x) as.formula(paste0(x, " ~ 'continuous2'"))),
  lapply(cat_vars,  function(x) as.formula(paste0(x, " ~ 'categorical'")))
)

# Format label list
label_list <- lapply(varsDM, function(x) {
  lbl <- labelVars[[x]]
  if (is.null(lbl)) lbl <- x
  as.formula(paste0(x, " ~ '", lbl, "'"))
})

# Build table
tbl <- data_in %>%
  select(all_of(c("TRT01P", varsDM))) %>%
  tbl_summary(
    by = TRT01P,
    type = type_list,
    statistic = list(
      all_continuous2() ~ c("Mean (SD)" = "{mean} ({sd})",
                            "Median" = "{median} ",
                            "(Min - Max)" = "({min} - {max})"),
      all_categorical() ~ "{n} ({p}%)"
    ),
    label = label_list,
    missing = "no"
  ) %>%
  add_overall(last = TRUE, col_label = "All subjects") %>%
  modify_caption("**Table: Demographic Data (Safety Analysis Set)**") %>%
  bold_labels()

tbl
Table: Demographic Data (Safety Analysis Set)
Characteristic Placebo
N = 2
1
Xanomeline Low Dose
N = 2
1
Xanomeline High Dose
N = 3
1
All subjects1
Sex



    F 1 (50%) 2 (100%) 2 (67%) 5 (71%)
    M 1 (50%) 0 (0%) 1 (33%) 2 (29%)
Age



    Mean (SD) 82 (10) 78 (3) 67 (9) 74 (10)
    Median 82 78 69 75
    (Min - Max) (75 - 89) (76 - 80) (57 - 74) (57 - 89)
Pooled Age Group 1



    <65 0 (0%) 0 (0%) 1 (33%) 1 (14%)
    65-80 1 (50%) 2 (100%) 2 (67%) 5 (71%)
    >80 1 (50%) 0 (0%) 0 (0%) 1 (14%)
Race



    WHITE 2 (100%) 2 (100%) 2 (67%) 6 (86%)
    BLACK OR AFRICAN AMERICAN 0 (0%) 0 (0%) 1 (33%) 1 (14%)
Ethnicity



    NOT HISPANIC OR LATINO 2 (100%) 2 (100%) 3 (100%) 7 (100%)
Baseline Height (cm)



    Mean (SD) 168 (14) 156 (6) 163 (11) 162 (10)
    Median 168 156 159 159
    (Min - Max) (158 - 178) (151 - 160) (155 - 175) (151 - 178)
Baseline Weight (kg)



    Mean (SD) 60 (18) 54 (13) 69 (18) 62 (15)
    Median 60 54 67 64
    (Min - Max) (47 - 72) (45 - 64) (52 - 87) (45 - 87)
Baseline BMI (kg/m^2)



    Mean (SD) 20.9 (2.7) 22.8 (7.1) 25.5 (4.4) 23.4 (4.5)
    Median 20.9 22.8 27.8 22.8
    (Min - Max) (19.0 - 22.8) (17.7 - 27.8) (20.5 - 28.3) (17.7 - 28.3)
Pooled Baseline BMI Group 1



    <25 2 (100%) 1 (50%) 1 (33%) 4 (57%)
    25-<30 0 (0%) 1 (50%) 2 (67%) 3 (43%)
1 n (%)

Baseline disease characteristics

inTextSummaryTable

# data of interest
data_in <- subset(dataAll$ADSL, SAFFL == "Y")

# create table
getSummaryStatisticsTable(
    data = data_in,
    var = c("DURDIS", "EDUCLVL"), varGeneralLab = "Parameter", 
    colVar = "TRT01P", colTotalInclude = TRUE, colTotalLab = "All subjects",
    stats = getStats("median\n(range)"), statsGeneralLab = "",
    rowAutoMerge = FALSE,
    labelVars = labelVars,
    title = tools::toTitleCase("Table: Baseline Disease Characteristics (safety analysis set)")
    # file = file.path("tables_CSR", "Table_BaselineCharacteristics.docx")
)

Table: Baseline Disease Characteristics (Safety Analysis Set)

Parameter

Placebo
(N=2)

Xanomeline High Dose
(N=3)

Xanomeline Low Dose
(N=2)

All subjects
(N=7)

Duration of Disease (Months)

20.65
(17.6,23.7)

31.4
(2.2,32.1)

35.6
(31.4,39.8)

31.4
(2.2,39.8)

Years of Education

13
(12,14)

15
(10,16)

12
(12,12)

12
(10,16)

gtsummary

# Subset data
data_in <- subset(dataAll$ADSL, SAFFL == "Y")

# Variables of interest
vars <- c("DURDIS", "EDUCLVL")

# Identify variable types
cont_vars <- vars[sapply(data_in[vars], is.numeric)]
cat_vars <- setdiff(vars, cont_vars)

# Set types: "continuous2" for median + range on separate row
type_list <- c(
  lapply(cont_vars, function(x) as.formula(paste0(x, " ~ 'continuous2'"))),
  lapply(cat_vars, function(x) as.formula(paste0(x, " ~ 'categorical'")))
)

# Set labels
label_list <- lapply(vars, function(x) {
  lbl <- labelVars[[x]]
  if (is.null(lbl)) lbl <- x
  as.formula(paste0(x, " ~ '", lbl, "'"))
})

# Create table
tbl <- data_in %>%
  select(all_of(c("TRT01P", vars))) %>%
  tbl_summary(
    by = TRT01P,
    type = type_list,
    statistic = list(
      all_continuous2() ~ c("Mean (SD)" = "{mean} ({sd})",
                            "Median" = "{median} ",
                            "(Min - Max)" = "({min} - {max})"),
      all_categorical() ~ "{n} ({p}%)"
    ),
    label = label_list,
    missing = "no"
  ) %>%
  add_overall(last = TRUE, col_label = "All subjects") %>%
  modify_caption("**Table: Baseline Disease Characteristics (Safety Analysis Set)**") %>%
  bold_labels()

# View the table
tbl
Table: Baseline Disease Characteristics (Safety Analysis Set)
Characteristic Placebo
N = 2
Xanomeline High Dose
N = 3
Xanomeline Low Dose
N = 2
All subjects
Duration of Disease (Months)



    Mean (SD) 21 (4) 22 (17) 36 (6) 25 (12)
    Median 21 31 36 31
    (Min - Max) (18 - 24) (2 - 32) (31 - 40) (2 - 40)
Years of Education



    Mean (SD) 13.00 (1.41) 13.67 (3.21) 12.00 (0.00) 13.00 (2.08)
    Median 13.00 15.00 12.00 12.00
    (Min - Max) (12.00 - 14.00) (10.00 - 16.00) (12.00 - 12.00) (10.00 - 16.00)

Medical History and Concomitant Diseases

inTextSummaryTable

data_in <- subset(dataAll$ADCM, SAFFL == "Y")

# sort variable according to corresponding numeric variables
data_in$TRTA <- with(data_in, reorder(TRTA, TRTAN))

# Terms should be in lower-case
data_in$CMDECOD <- simpleCap(tolower(data_in$CMDECOD))
data_in$CMCLAS <- simpleCap(tolower(data_in$CMCLAS))
        
getSummaryStatisticsTable(
    data = data_in,
    colVar = "TRTA", colTotalInclude = TRUE, colTotalLab = "All subjects",
    rowVar = c("CMCLAS", "CMDECOD"), 
    # include total across generic terms and across ATC4 classes
    rowVarTotalInclude = c("CMCLAS", "CMDECOD"), 
    rowTotalLab = "Any prior and concomitant medication",
    stats = getStats("n (%)"),
    # sort rows based on counts of subjects in the total column 
    rowOrder = "total",
    labelVars = labelVars,
    emptyValue = 0,
    title = tools::toTitleCase(paste("Prior and concomitant therapies",
        "by medication class and generic term (safety analyis set)"
    ))
    # file = file.path("tables_CSR", "Table_CM.docx")
)

Prior and Concomitant Therapies by Medication Class and Generic Term (Safety Analyis Set)

Medication Class

Xanomeline Low Dose
(N=2)

Xanomeline High Dose
(N=1)

All subjects
(N=3)

Standardized Medication Name

Any prior and concomitant medication

2 (100)

1 (100)

3 (100)

Systemic hormonal preparations, excl.

2 (100)

1 (100)

3 (100)

Hydrocortisone

2 (100)

1 (100)

3 (100)

Uncoded

2 (100)

1 (100)

3 (100)

Uncoded

2 (100)

1 (100)

3 (100)

Respiratory system

1 (50.0)

0

1 (33.3)

Salbutamol sulfate

1 (50.0)

0

1 (33.3)