Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: How does one change the x-axis label for plots using tm_g_ipp? #915

Open
3 tasks done
krissy-bios opened this issue Jan 5, 2024 · 3 comments
Open
3 tasks done
Labels
bug Something isn't working sme

Comments

@krissy-bios
Copy link

What happened?

How do I change the x-axis label for the timepoint variable? One feature of teal that we love is the ability to select the x-axis variable from a drop down menu since we have varying definitions of timepoint in our study. However, there doesn't appear to be a way to change the x-axis label associated with this variable. This is a bug, or an oversight, because it creates incorrect plots if the label "Visit" is the appropriate selection. Nor does it allow me to add the units of the visit variable to the axis label, which is also important. In addition, it is feasible to also create plots across the age of the individual, not simply the time. Retaining the x-axis simply as a timepoint variable prevents one from utilizing the graphing future to its fullest extent. Please let me know if I am missing this in the documentation or if this is a change that may be made in the program itself. Thank you!

sessionInfo()

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.
@krissy-bios krissy-bios added the bug Something isn't working label Jan 5, 2024
@lcd2yyz lcd2yyz transferred this issue from insightsengineering/teal Jan 9, 2024
@lcd2yyz lcd2yyz added the sme label Jan 9, 2024
@lcd2yyz
Copy link

lcd2yyz commented Jan 9, 2024

Thanks @krissy-bios for reporting and sharing your broader use case, we'll look into it.

@edelarua
Copy link
Contributor

edelarua commented Jan 9, 2024

Hi @krissy-bios,

Although this does not fix some of the displayed text hard-coded into the options panel for the module, please note that for now you can customize the x-axis text via the ggplot2_args argument as follows (using the module example code as an example):

library(nestcolor)

ADSL <- tmc_ex_adsl %>%
  dplyr::slice(1:20) %>%
  df_explicit_na()
ADLB <- tmc_ex_adlb %>%
  dplyr::filter(USUBJID %in% ADSL$USUBJID) %>%
  df_explicit_na() %>%
  dplyr::filter(AVISIT != "SCREENING")

app <- init(
  data = cdisc_data(
    ADSL = ADSL,
    ADLB = ADLB,
    code = "
      ADSL <- tmc_ex_adsl %>% dplyr::slice(1:20) %>% df_explicit_na()
      ADLB <- tmc_ex_adlb %>% dplyr::filter(USUBJID %in% ADSL$USUBJID) %>%
        df_explicit_na() %>% dplyr::filter(AVISIT != \"SCREENING\")
    "
  ),
  modules = modules(
    tm_g_ipp(
      label = "Individual Patient Plot",
      dataname = "ADLB",
      arm_var = choices_selected(
        value_choices(ADLB, "ARMCD"),
        "ARM A"
      ),
      paramcd = choices_selected(
        value_choices(ADLB, "PARAMCD"),
        "ALT"
      ),
      aval_var = choices_selected(
        variable_choices(ADLB, c("AVAL", "CHG")),
        "AVAL"
      ),
      avalu_var = choices_selected(
        variable_choices(ADLB, c("AVALU")),
        "AVALU",
        fixed = TRUE
      ),
      id_var = choices_selected(
        variable_choices(ADLB, c("USUBJID")),
        "USUBJID",
        fixed = TRUE
      ),
      visit_var = choices_selected(
        variable_choices(ADLB, c("AVISIT")),
        "AVISIT"
      ),
      base_var = choices_selected(
        variable_choices(ADLB, c("BASE")),
        "BASE",
        fixed = TRUE
      ),
      add_baseline_hline = FALSE,
      separate_by_obs = FALSE,
      ggplot2_args = teal.widgets::ggplot2_args(
        labs = list(x = "Custom x-axis text")
      )
    )
  )
)
if (interactive()) {
  shinyApp(ui = app$ui, server = app$server)
}

Let me know if this helps!

@nicolekjones
Copy link

Hi, chiming in here (I work along side Krissy :D) :

Would this solve this issue? In the example we're using three different visit variables. So would need to dynamically update the x-axis label based on what variable is selected as the visit variable. Please see example below on how how we implement tm_g_ipp:

 tm_g_ipp(
    label = "Lab Plots",
    dataname = "LabFindings",
    arm_var = choices_selected(
      value_choices(adlb, "COHORT"),
      "P1"
    ),
    paramcd = choices_selected(
      value_choices(adlb, c("PARAM"), var_label = c("PARAM"))
    ),
    aval_var = choices_selected(
      variable_choices(adlb, c("AVAL", "CHG", "PCHG")),
      "CHG"
    ),
    avalu_var = choices_selected(
      variable_choices(adlb, c("AVALU")),
      "AVALU",
      fixed = TRUE
    ),
    id_var = choices_selected(
      variable_choices(adlb, c("SUBJID")),
      "SUBJID",
      fixed = TRUE
    ),
    visit_var = choices_selected(
      variable_choices(adlb, c("AVISIT", "ADY1", "ADY2","AGEASS")),
      "AVISIT"
    ),
    base_var = choices_selected(
      variable_choices(adlb, c("BASE")),
      "BASE",
      fixed = TRUE
    ),
    add_baseline_hline = FALSE,
    separate_by_obs = FALSE,
    plot_height = c(400L, 400L, 5000L)
  )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sme
Projects
None yet
Development

No branches or pull requests

4 participants