Skip to content

picks version for tm_g_events_term_id#329

Closed
m7pr wants to merge 13 commits into
mainfrom
redesign_extraction@main
Closed

picks version for tm_g_events_term_id#329
m7pr wants to merge 13 commits into
mainfrom
redesign_extraction@main

Conversation

@m7pr

@m7pr m7pr commented Mar 5, 2026

Copy link
Copy Markdown
Contributor
image
devtools::load_all("../teal")
devtools::load_all("../teal.data")
devtools::load_all("../osprey")
devtools::load_all("../teal.picks")
devtools::load_all(".")

data <- teal_data() %>%
  within({
    ADSL <- rADSL
    ADAE <- rADAE
  })

join_keys(data) <- default_cdisc_join_keys[names(data)]

app <- init(
  data = data,
  modules = modules(
    tm_g_events_term_id(
      label = "Common AE (picks)",
      term_var = picks(
        datasets("ADAE"),
        variables(
          choices = is_categorical(min.len = 2),
          selected = "AEDECOD",
          multiple = FALSE
        )
      ),
      arm_var = picks(
        datasets("ADSL"),
        variables(
          choices = is_categorical(min.len = 2),
          selected = "ACTARMCD",
          multiple = FALSE
        )
      ),
      plot_height = c(600, 200, 2000)
    )
  )
)

shiny::shinyApp(app$ui, app$server)

Comment thread R/tm_g_events_term_id.R
@m7pr m7pr changed the title [WIP] picks version for tm_g_events_term_id picks version for tm_g_events_term_id May 27, 2026
@m7pr
m7pr marked this pull request as ready for review May 27, 2026 11:12
@github-actions

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

badge

Code Coverage Summary

Filename                         Stmts    Miss  Cover    Missing
-----------------------------  -------  ------  -------  -------------------------------------------------
R/tm_g_ae_oview.R                  271     210  22.51%   90-94, 98-102, 169-402
R/tm_g_ae_sub.R                    288     288  0.00%    60-379
R/tm_g_butterfly.R                 371     371  0.00%    125-534
R/tm_g_decorate.R                   42      42  0.00%    17-91
R/tm_g_events_term_id_picks.R      305     305  0.00%    23-406
R/tm_g_events_term_id.R            289     247  14.53%   131-407
R/tm_g_heat_bygrade.R              293     293  0.00%    136-459
R/tm_g_patient_profile.R           691     691  0.00%    159-913
R/tm_g_spiderplot.R                322     322  0.00%    100-464
R/tm_g_swimlane.R                  332     288  13.25%   65, 124-459
R/tm_g_waterfall.R                 414     374  9.66%    80-82, 141-569
R/utils_picks.R                     90      37  58.89%   18, 29-30, 55-76, 102, 106, 122-126, 146, 152-156
R/utils.R                           64      59  7.81%    31-73, 107-201
R/zzz.R                              3       3  0.00%    4-7
TOTAL                             3775    3530  6.49%

Diff against main

Filename                         Stmts    Miss  Cover
-----------------------------  -------  ------  --------
R/tm_g_ae_oview.R                  +46     -15  +22.51%
R/tm_g_events_term_id_picks.R     +305    +305  +100.00%
R/tm_g_events_term_id.R            +18     -24  +14.53%
R/tm_g_swimlane.R                  -13     -57  +13.25%
R/tm_g_waterfall.R                 -15     -55  +9.66%
R/utils_picks.R                    +90     +37  +58.89%
R/utils.R                          -21     -21  +1.93%
TOTAL                             +410    +170  +6.34%

Results for commit: 726b039

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@github-actions

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Unit Tests Summary

 1 files   5 suites   0s ⏱️
17 tests 12 ✅ 5 💤 0 ❌
49 runs  44 ✅ 5 💤 0 ❌

Results for commit 726b039.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
shinytest2-tm_g_events_term_id 👶 $+0.18$ $+5$ $+5$ $0$ $0$
tm_g_ae_oview 👶 $+0.16$ $+9$ $0$ $0$ $0$
tm_g_events_term_id 👶 $+0.08$ $+8$ $0$ $0$ $0$
tm_g_swimlane_waterfall_picks 👶 $+0.12$ $+14$ $0$ $0$ $0$
Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
shinytest2-tm_g_events_term_id 👶 $+0.07$ e2e_tm_g_events_term_id_changing_term_var_changes_the_plot_and_does_not_throw_validation_errors.
shinytest2-tm_g_events_term_id 👶 $+0.01$ e2e_tm_g_events_term_id_deselection_of_term_var_throws_validation_error.
shinytest2-tm_g_events_term_id 👶 $+0.03$ e2e_tm_g_events_term_id_initializes_and_renders_a_plot
shinytest2-tm_g_events_term_id 👶 $+0.01$ e2e_tm_g_events_term_id_sort_updates_title
shinytest2-tm_g_events_term_id 👶 $+0.05$ e2e_tm_g_events_term_id_starts_with_expected_label_and_encoding_selections.
tm_g_ae_oview 👶 $+0.04$ tm_g_ae_oview_argument_verification_fails_when_arm_var_is_neither_picks_or_choices_selected
tm_g_ae_oview 👶 $+0.05$ tm_g_ae_oview_argument_verification_fails_when_flag_var_anl_is_neiter_picks_or_choices_selected
tm_g_ae_oview 👶 $+0.06$ tm_g_ae_oview_module_creation_creates_a_teal_module_using_choices_selected
tm_g_ae_oview 👶 $+0.02$ tm_g_ae_oview_module_creation_creates_a_teal_module_using_picks
tm_g_events_term_id 👶 $+0.04$ tm_g_events_term_id_builds_a_teal_module_with_picks_encodings
tm_g_events_term_id 👶 $+0.03$ tm_g_events_term_id_rejects_multiple_variable_selection
tm_g_swimlane_waterfall_picks 👶 $+0.08$ tm_g_swimlane_builds_a_teal_module_with_picks_encodings
tm_g_swimlane_waterfall_picks 👶 $+0.04$ tm_g_waterfall_builds_a_teal_module_with_picks_encodings

Results for commit d5e54c3

♻️ This comment has been updated with latest results.

m7pr and others added 5 commits May 27, 2026 18:31
Merge branch 'redesign_extraction@main' of https://github.com/insightsengineering/teal.osprey into redesign_extraction@main

# Conflicts:
#	R/tm_g_events_term_id_picks.R
#	man/tm_g_events_term_id.Rd
# Pull Request

This partially closes #330 

I based my changes [in this
PR](#329).


Please compare both modules with this example app (requires to have
teal.picks installed, osprey)


```
library("teal")
library("teal.picks")
devtools::load_all()

data <- teal_data() %>%
  within({
    library(dplyr)
    ADSL <- teal.data::rADSL
    ADAE <- teal.data::rADAE
    .add_event_flags <- function(dat) {
      dat <- dat %>%
        mutate(
          TMPFL_SER = AESER == "Y",
          TMPFL_REL = AEREL == "Y",
          TMPFL_GR5 = AETOXGR == "5",
          AEREL1 = (AEREL == "Y" & ACTARM == "A: Drug X"),
          AEREL2 = (AEREL == "Y" & ACTARM == "B: Placebo")
        )
      labels <- c(
        "Serious AE", "Related AE", "Grade 5 AE",
        "AE related to A: Drug X", "AE related to B: Placebo"
      )
      cols <- c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2")
      for (i in seq_along(labels)) {
        attr(dat[[cols[i]]], "label") <- labels[i]
      }
      dat
    }
    ADAE <- .add_event_flags(ADAE)
  })

join_keys(data) <- default_cdisc_join_keys[names(data)]

app <- init(
  data = data,
  modules = modules(
    tm_g_ae_oview(
      label = "Common AE (picks)",
      flag_var_anl = teal.picks::picks(
        teal.picks::datasets("ADAE"),
        teal.picks::variables(
           choices = c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2"),
          selected = "TMPFL_SER"
        )
      ),
      arm_var = teal.picks::picks(
        teal.picks::datasets("ADSL"),
        teal.picks::variables(
          choices = teal.picks::is_categorical(min.len = 2),
          selected = "ACTARMCD"
        )
      ),
      plot_height = c(600, 200, 2000)
    ),
    # Default method (old) for comparison
    tm_g_ae_oview(
      label = "Common AE (default)",
      dataname = "ADAE",
      flag_var_anl = teal.transform::choices_selected(
        selected = "AEREL1",
        choices = teal.transform::variable_choices(
          data[["ADAE"]],
          c("TMPFL_SER", "TMPFL_REL", "TMPFL_GR5", "AEREL1", "AEREL2")
        )
      ),
      arm_var = teal.transform::choices_selected(
        selected = "ACTARMCD",
        choices = c("ACTARM", "ACTARMCD")
      ),
      plot_height = c(600, 200, 2000)
    )
  )
)

shinyApp(app$ui, app$server)
```

I refactored the `tm_g_ae_oview` module to create a generic, keep the
default for `teal.transform` and add a method for picks variable
selection. The module works as expected and setting the variables is
better with picks. The issue reported in the similar PR on the plot
dimensions is fixed if we set the plot dimensions in the module. The ui
of the picks ui components is different and it breaks, in my opinion,
the color pattern of the teal app.


<img width="1843" height="900" alt="image"
src="https://github.com/user-attachments/assets/0a61a8bd-10e7-456c-aff0-ed2d5a099d47"
/>
<img width="1843" height="900" alt="image"
src="https://github.com/user-attachments/assets/0a61a8bd-10e7-456c-aff0-ed2d5a099d47"
/>


Here the teal.transform module

<img width="1843" height="900" alt="image"
src="https://github.com/user-attachments/assets/8ce901a8-f106-4bf3-844c-b23358210b33"
/>
<img width="1843" height="900" alt="image"
src="https://github.com/user-attachments/assets/8ce901a8-f106-4bf3-844c-b23358210b33"
/>


I added simple tests for the module as well

---------

Signed-off-by: Oriol Senan  <35930244+osenan@users.noreply.github.com>
Co-authored-by: osenan <oriol@praenoscere.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com>
@averissimo averissimo self-assigned this Jul 7, 2026
@osenan

osenan commented Jul 9, 2026

Copy link
Copy Markdown

This Pull Request is replaced by #341

@osenan osenan closed this Jul 9, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Allow modules to use teal.picks

4 participants