Skip to content

Bug of prepare_boxly when there are >=2 variables selected in define_observation(var = ..., ...) #51

Description

@LittleBeannie

The following code provide a minimal sufficient example for debuging:

adsl <- r2rtf::r2rtf_adsl |> 
  filter(TRT01P %in% c("Placebo", "Xanomeline High Dose")) |>
  mutate(TRT01P = factor(TRT01P,
                         levels = c("Placebo", "Xanomeline High Dose"),
                         labels = c("Control", "Experimental")),
         TRT01A = factor(TRT01A,
                         levels = c("Placebo", "Xanomeline High Dose"),
                         labels = c("Control", "Experimental")),
         RACE = stringr::str_to_sentence(RACE))

adlb <- boxly_adlb |> 
  filter(TRTA %in% c("Placebo", "Xanomeline High Dose")) |>
  mutate(TRTA = factor(TRTA,
                       levels = c("Placebo", "Xanomeline High Dose"),
                       labels = c("Control", "Experimental"))) |>
  rename(TRT01A = TRTA)

meta <- meta_adam(population = adsl,
                      observation = adlb) |>
  define_plan(plan = plan(analysis = "lab_boxplot",
                          population = "apat",
                          observation = "wk12",
                          parameter = "alp;alt;bili;sodium;urate")) |>
  define_population(name = "apat",
                    group = "TRT01A",
                    subset = SAFFL == "Y",
                    label = "APaT Population") |>
  define_observation(name = "wk12",
                     group = "TRT01A",
                     # when var only has 1 variable selected, the code is correct
                     # var = "PARAM",
                     # when var has more than 2 variables selected, the code gives error in prepare_boxly
                     var = c("PARAM", "USUBJID"),
                     subset = SAFFL == "Y",
                     label = "") |>
  define_analysis(name = "lab_boxplot",
                  label = "Interactive Box Plot",
                  x = "AVISITN", 
                  y = "CHG") |>
  define_parameter(name = "alp",
                   label = "Alanine Aminotransferase (U/L)",
                   subset = PARAM == "Alanine Aminotransferase (U/L)") |>
  define_parameter(name = "alt",
                   label = "Alkaline Phosphatase (U/L)",
                   subset = PARAM == "Alkaline Phosphatase (U/L)") |>
  define_parameter(name = "bili",
                   label = "Bilirubin (umol/L)",
                   subset = PARAM == "Bilirubin (umol/L)") |>
  define_parameter(name = "sodium",
                   label = "Sodium (mmol/L)",
                   subset = PARAM == "Sodium (mmol/L)") |>
  define_parameter(name = "urate",
                   label = "Urate (umol/L)",
                   subset = PARAM == "Urate (umol/L)") |>
  meta_build()

meta |>
  prepare_boxly(population = "apat",
                observation = "wk12",
                analysis = "lab_boxplot",
                filter_var = "PARAM",
                hover_var_outlier = c("USUBJID", 
                                      metalite::collect_adam_mapping(meta, meta$plan$analysis)$y
                                      )
                ) |>
  boxly()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions