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

[Issue]: Plot Aesthetic Settings does not do anything for tm_g_gh_density_distribution_plot #234

Open
3 tasks done
m7pr opened this issue Aug 11, 2023 · 2 comments
Open
3 tasks done

Comments

@m7pr
Copy link
Contributor

m7pr commented Aug 11, 2023

What is your question?

video1042041576.mp4

Should Include rug plot or Rotate X-axis Label options under Plot Aesthetic Settings be doing anything for tm_g_gh_density_distribution_plot?

library(dplyr)

# original ARM value = dose value
arm_mapping <- list(
  "A: Drug X" = "150mg QD",
  "B: Placebo" = "Placebo",
  "C: Combination" = "Combination"
)
ADSL <- goshawk::rADSL
ADLB <- goshawk::rADLB
var_labels <- lapply(ADLB, function(x) attributes(x)$label)
ADLB <- ADLB %>%
  dplyr::mutate(
    AVISITCD = dplyr::case_when(
      AVISIT == "SCREENING" ~ "SCR",
      AVISIT == "BASELINE" ~ "BL",
      grepl("WEEK", AVISIT) ~ paste("W", stringr::str_extract(AVISIT, "(?<=(WEEK ))[0-9]+")),
      TRUE ~ as.character(NA)
    ),
    AVISITCDN = dplyr::case_when(
      AVISITCD == "SCR" ~ -2,
      AVISITCD == "BL" ~ 0,
      grepl("W", AVISITCD) ~ as.numeric(gsub("[^0-9]*", "", AVISITCD)),
      TRUE ~ as.numeric(NA)
    ),
    AVISITCD = factor(AVISITCD) %>% reorder(AVISITCDN),
    TRTORD = dplyr::case_when(
      ARMCD == "ARM C" ~ 1,
      ARMCD == "ARM B" ~ 2,
      ARMCD == "ARM A" ~ 3
    ),
    ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))]),
    ARM = factor(ARM) %>% reorder(TRTORD),
    ACTARM = as.character(arm_mapping[match(ACTARM, names(arm_mapping))]),
    ACTARM = factor(ACTARM) %>% reorder(TRTORD)
  )

attr(ADLB[["ARM"]], "label") <- var_labels[["ARM"]]
attr(ADLB[["ACTARM"]], "label") <- var_labels[["ACTARM"]]

app <- teal::init(
  data = teal.data::cdisc_data(
    teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- goshawk::rADSL"),
    teal.data::cdisc_dataset(
      "ADLB",
      ADLB,
      code = "ADLB <- goshawk::rADLB
              var_labels <- lapply(ADLB, function(x) attributes(x)$label)
              ADLB <- ADLB %>%
                dplyr::mutate(AVISITCD = dplyr::case_when(
                    AVISIT == 'SCREENING' ~ 'SCR',
                    AVISIT == 'BASELINE' ~ 'BL',
                    grepl('WEEK', AVISIT) ~
                      paste('W', stringr::str_extract(AVISIT, '(?<=(WEEK ))[0-9]+')),
                    TRUE ~ as.character(NA)),
                  AVISITCDN = dplyr::case_when(
                    AVISITCD == 'SCR' ~ -2,
                    AVISITCD == 'BL' ~ 0,
                    grepl('W', AVISITCD) ~ as.numeric(gsub('[^0-9]*', '', AVISITCD)),
                    TRUE ~ as.numeric(NA)),
                  AVISITCD = factor(AVISITCD) %>% reorder(AVISITCDN),
                  TRTORD = dplyr::case_when(
                    ARMCD == 'ARM C' ~ 1,
                    ARMCD == 'ARM B' ~ 2,
                   ARMCD == 'ARM A' ~ 3),
                 ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))]),
                 ARM = factor(ARM) %>% reorder(TRTORD),
                 ACTARM = as.character(arm_mapping[match(ACTARM, names(arm_mapping))]),
                 ACTARM = factor(ACTARM) %>% reorder(TRTORD))
               attr(ADLB[['ARM']], 'label') <- var_labels[['ARM']]
               attr(ADLB[['ACTARM']], 'label') <- var_labels[['ACTARM']]",
      vars = list(arm_mapping = arm_mapping)
    ),
    check = TRUE
  ),
  modules = teal::modules(
    teal.goshawk::tm_g_gh_density_distribution_plot(
      label = "Density Distribution Plot",
      dataname = "ADLB",
      param_var = "PARAMCD",
      param = choices_selected(c("ALT", "CRP", "IGA"), "ALT"),
      xaxis_var = choices_selected(c("AVAL", "BASE", "CHG", "PCHG"), "AVAL"),
      trt_group = choices_selected(c("ARM", "ACTARM"), "ARM"),
      color_manual = c(
        "150mg QD" = "#000000",
        "Placebo" = "#3498DB",
        "Combination" = "#E74C3C"
      ),
      color_comb = "#39ff14",
      comb_line = TRUE,
      plot_height = c(500, 200, 2000),
      font_size = c(12, 8, 20),
      line_size = c(1, .25, 3),
      hline_arb = c(.02, .05),
      hline_arb_color = c("red", "black"),
      hline_arb_label = c("Horizontal Line A", "Horizontal Line B")
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

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.
@npaszty
Copy link
Contributor

npaszty commented Aug 11, 2023

only one that doesn't affect the plot is the rotation checkbox. the others do.
correlation plot has similar UI and it does rotate the values.

@npaszty
Copy link
Contributor

npaszty commented Jul 24, 2024

@m7pr
I continue to observe this from my testing today. isn't this a goshawk issue versus a teal.goshawk issue?

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

No branches or pull requests

2 participants