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

fix tm_g_lineplot #270

Merged
merged 6 commits into from
Apr 8, 2024
Merged

fix tm_g_lineplot #270

merged 6 commits into from
Apr 8, 2024

Conversation

gogonzo
Copy link
Contributor

@gogonzo gogonzo commented Apr 3, 2024

closes #264

Check the app

pkgload::load_all("goshawk")
pkgload::load_all("teal.goshawk")

data <- teal_data()
data <- within(data, {
  library(dplyr)
  library(stringr)
  library(nestcolor)
  # 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"]]
})
datanames <- c("ADSL", "ADLB")
datanames(data) <- datanames
join_keys(data) <- default_cdisc_join_keys[datanames]
app <- teal::init(
  data = data,
  modules = teal::modules(
    teal.goshawk::tm_g_gh_lineplot(
      label = "Line Plot",
      dataname = "ADLB",
      param_var = "PARAMCD",
      param = choices_selected(c("ALT", "CRP", "IGA"), "ALT"),
      shape_choices = c("SEX", "RACE"),
      xaxis_var = choices_selected("AVISITCD", "AVISITCD"),
      yaxis_var = choices_selected(c("AVAL", "BASE", "CHG", "PCHG"), "AVAL"),
      trt_group = choices_selected(c("ARM", "ACTARM"), "ARM"),
      hline_arb = c(20.5, 19.5),
      hline_arb_color = c("red", "green"),
      hline_arb_label = c("A", "B")
    )
  )
)

shinyApp(app$ui, app$server)

@gogonzo gogonzo changed the title 264 fix lineplot@main fix tm_g_lineplot Apr 3, 2024
@gogonzo gogonzo added bug Something isn't working core labels Apr 3, 2024
Copy link
Contributor

github-actions bot commented Apr 3, 2024

badge

Code Coverage Summary

Filename                                 Stmts    Miss  Cover    Missing
-------------------------------------  -------  ------  -------  ---------
R/tm_g_gh_boxplot.R                        359     359  0.00%    175-602
R/tm_g_gh_correlationplot.R                570     570  0.00%    227-905
R/tm_g_gh_density_distribution_plot.R      285     285  0.00%    135-471
R/tm_g_gh_lineplot.R                       555     555  0.00%    159-799
R/tm_g_gh_scatterplot.R                    252     252  0.00%    144-449
R/tm_g_gh_spaghettiplot.R                  304     304  0.00%    192-564
R/toggleable_slider.R                      154     154  0.00%    72-243
R/utils-arbitrary_lines.r                  125     125  0.00%    19-175
R/utils-data_constraints.r                 190     190  0.00%    2-257
R/utils-keep_range_slider_updated.r         23      23  0.00%    8-38
R/utils-maptrt.r                             9       9  0.00%    24-36
R/utils-templ_ui.r                          48      48  0.00%    2-73
R/utils.R                                   39      39  0.00%    12-83
R/zzz.R                                      2       2  0.00%    2-3
TOTAL                                     2915    2915  0.00%

Diff against main

Filename                Stmts    Miss  Cover
--------------------  -------  ------  --------
R/tm_g_gh_lineplot.R      -21     -21  +100.00%
TOTAL                     -21     -21  +100.00%

Results for commit: 9aa9d94

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@kartikeyakirar kartikeyakirar self-assigned this Apr 5, 2024
R/tm_g_gh_lineplot.R Outdated Show resolved Hide resolved
R/tm_g_gh_lineplot.R Outdated Show resolved Hide resolved
Copy link
Contributor

@kartikeyakirar kartikeyakirar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this on a sample app, and the bug is resolved. @gogonzo, everything looks great, with just a minor suggestion to consider.

@gogonzo gogonzo enabled auto-merge (squash) April 8, 2024 11:17
@gogonzo gogonzo merged commit eecbaa3 into main Apr 8, 2024
19 checks passed
@gogonzo gogonzo deleted the 264_fix_lineplot@main branch April 8, 2024 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: tm_g_gh_lineplot is not working
2 participants