insightsengineering / teal.modules.clinical

Provides teal modules for the standard clinical trials outputs
https://insightsengineering.github.io/teal.modules.clinical/
Other
32 stars 17 forks source link

Option to not show `<Missing>` columns in tm_t_events etc. #477

Closed nikolas-burkoff closed 2 years ago

nikolas-burkoff commented 2 years ago

Original post

@shajoezhu @ClaudiaCarlucci

In this app, some ARM values are missing and some other ARMCD values are missing. In older versions these missing values were not shown in the table - but now in tm_t_events we get an error about missing values.

The expectation is now to use tern::explicit_na (or tern::df_explicit_na) but then we end up seeing <Missing> columns which we would rather not see. These are shown in multiple modules such as tm_t_events, tm_t_events_summary, tm_t_summary,...

It is possible to filter these out using the filter panel but this is cumbersome as the filters need to be changed whether ARM, ARMCD or both are selected (as if ARM is selected we want all rows of data which do not have missing ARM, irrespective of the value in ARMCD). This is particularly difficult for novice end users in filter panels with lots of other filters already in (as in a real use case)

Is it possible to have an option in the encoding panel to not show these?

Note I think this is distinct from (but related to) https://github.com/insightsengineering/teal.modules.clinical/issues/473 as the arguments there seem not to affect the columns but only the rows

Awkward to have to keep manipulating filters

The missing option (which is only available in tm_t_summary - and default value can be set by app developer) but isn't available in others: image

image
library(dplyr)
library(scda)
library(teal.modules.clinical)

adsl <- synthetic_cdisc_data("latest")$adsl
adae <- synthetic_cdisc_data("latest")$adae
adsl$ARM[1:10] <- NA
adsl$ARMCD[21:40] <- NA
adsl$ARM <- tern::explicit_na(adsl$ARM)
adsl$ARMCD <- tern::explicit_na(adsl$ARMCD)

adsl$SEX[51:60] <- NA
adsl$SEX <- tern::explicit_na(adsl$SEX)

app <- teal::init(
  data = cdisc_data(
    cdisc_dataset("ADSL", adsl, code = 'ADSL <- synthetic_cdisc_data("latest")$adsl'),
    cdisc_dataset("ADAE", adae, code = 'ADAE <- synthetic_cdisc_data("latest")$adae'),
    check = FALSE
  ),
  modules = modules(
    tm_t_summary(
      label = "Demographic Table",
      dataname = "ADSL",
      arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
      add_total = TRUE,
      summarize_vars = choices_selected(
        c("SEX", "RACE", "BMRKR2", "EOSDY", "DCSREAS", "AGE"),
        c("SEX", "RACE")
      )
    ),
    tm_t_events(
      label = "Adverse Event Table",
      dataname = "ADAE",
      arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
      llt = choices_selected(
        choices = variable_choices(adae, c("AETERM", "AEDECOD")),
        selected = c("AEDECOD")
      ),
      hlt = choices_selected(
        choices = variable_choices(adae, c("AEBODSYS", "AESOC")),
        selected = "AEBODSYS"
      ),
      add_total = TRUE,
      event_type = "adverse event"
    )
  )
)

shinyApp(app$ui, app$server)

TODO

gogonzo commented 2 years ago

Related to: https://github.com/insightsengineering/coredev-tasks/issues/363

nikolas-burkoff commented 2 years ago

Related to, but distinct from: as in the referenced issue we are concerned with dynamically handling levels which are filtered out by the app users in the filter panel, whereas here we have a specific level given by the app developer denoting missing (instead of NA) which we don't want to see in the table irrespective of the filter panel state

gogonzo commented 2 years ago

@shajoezhu can we close it in favour of:

shajoezhu commented 2 years ago

After communicating this with PO and the SME team, we have decided not to implement this change. As the change is relating to filtering in the encoding step, and we should separate the encoding step and setting up filters.