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

[UAT] tm_t_coxreg: bad error message due to certain input combinations #57

Closed cicdguy closed 2 years ago

cicdguy commented 3 years ago

Original Message

to reproduce:

library(random.cdisc.data)

ADSL  <- radsl(cached = TRUE)
ADTTE <- radtte(cached = TRUE)
arm_ref_comp = list(
  ACTARMCD = list(
    ref = "ARM B",
    comp = c("ARM A", "ARM C")
  ),
  ARM = list(
    ref = "B: Placebo",
    comp = c("A: Drug X", "C: Combination")
  )
)

app <- init(
  data = cdisc_data(
    cdisc_dataset("ADSL", ADSL, code = 'ADSL <- radsl(cached = TRUE)'),
    cdisc_dataset("ADTTE", ADTTE, code = 'ADTTE <- radtte(cached = TRUE)'),
    check = TRUE
  ),
  modules = root_modules(
    tm_t_coxreg(
      label = "Cox Reg.",
      dataname = "ADTTE",
      arm_var = choices_selected(c("ARM", "ARMCD", "ACTARMCD"), "ARM"),
      arm_ref_comp = arm_ref_comp,
      paramcd = choices_selected(
        value_choices(ADTTE, "PARAMCD", "PARAM"), "OS"
      ),
      strata_var = choices_selected(
        c("COUNTRY", "STRATA1", "STRATA2"), "STRATA1"
      ),
      cov_var    = choices_selected(
        c("AGE", "BMRKR1", "BMRKR2", "REGION1"), "AGE"
      ),
      multivariate = TRUE
    )
  )
)

shinyApp(app$ui, app$server)
user/3035/files/44109a80-bebc-11eb-92ea-169a4b7e8956) Provenance: ``` Creator: junlue ``` # Definition of Done
yli110-stat697 commented 2 years ago

So after tern refactoring, this still gave a error message, but the message is a bit more informative now.

Screen Shot 2022-01-30 at 12 32 07 AM

@shajoezhu and @junlueZH do you think this is acceptable or we should have some sort of validation to capture this?

shajoezhu commented 2 years ago

Thanks for looking into this @yli110-stat697 ! I think this is definitely an improvement. Though, I think the error message currently is too cluttered. I wonder if we can use different colour or bold font to make it more easy for users to identify the key message: "The model seems to have ... strata varaibles"

I am thinking of to make the use of package "crayon", see https://www.r-bloggers.com/2018/07/coloured-output-in-the-r-console/ for example.

@junlueZH and @pawelru , what do you think? any suggestions? Thanks!

pawelru commented 2 years ago

crayon won't work as it's intended to be used in the console and we can see here some piece of HTML code. I see your point of enhancing formatting so that the key error message would be more visible. Will create a separate task for it.

EDIT: https://github.com/insightsengineering/teal.devel/issues/232

shajoezhu commented 2 years ago

Thanks @pawelru !

@yli110-stat697 , I will mark this issue is blocked, and revisit it once https://github.com/insightsengineering/teal.devel/issues/232 is completed.

shajoezhu commented 2 years ago

much improved error message

image