insightsengineering / teal.gallery

A Gallery of Exploratory Web Apps used for Analyzing Clinical Trial Data
https://insightsengineering.github.io/teal.gallery/
Other
29 stars 7 forks source link

[Question]: Unable to to launch sample apps beyond basic-teal #11

Closed ElijT closed 1 year ago

ElijT commented 1 year ago

What is your question?

I am discovering the teal packages and wanted to try locally the apps using the teal gallery.

I install the packages and dependencies but when I am trying to launch apps with teal.gallery::launch_app() I have the following error. The error is present in all app except basic-teal.

teal.gallery::list_apps() [1] "basic-teal" "early-dev" "efficacy" "exploratory" "longitudinal" "patient-profile" "python" "RNA-seq" "safety"
teal.gallery::launch_app("safety") Finding R package dependencies ... Done! [INFO] 2023-02-22 14:39:19.0994 pid:18429 token:[] teal.modules.general Initializing tm_front_page Error in module(label = label, server = srv_front_page, ui = ui_front_page, :

filters = NULL indicates that the module doesn't need any data while it has the data in formals. Please specify filters with the names of needed datasets or exclude data from the arguments.

For reference below if my sessionInfo()

R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 13.0.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] teal.goshawk_0.1.14.9009          goshawk_0.1.14.9008               stringr_1.5.0                     DescTools_0.99.48                 sparkline_2.0                    
 [6] nestcolor_0.1.0.9005              teal.osprey_0.1.14                osprey_0.1.15                     teal.modules.general_0.2.15.9016  shinyTree_0.2.7                  
[11] ggmosaic_0.3.3                    ggplot2_3.4.1                     teal.modules.clinical_0.8.14.9019 tern_0.7.10                       rtables_0.5.3.4                  
[16] formatters_0.3.4.19               dplyr_1.1.0                       scda.2022_0.1.3.9016              scda_0.1.5.9007                   teal_0.12.0                      
[21] teal.transform_0.2.0              magrittr_2.0.3                    teal.data_0.1.2                   shiny_1.7.4                      

loaded via a namespace (and not attached):
  [1] colorspace_2.1-0          ellipsis_0.3.2            class_7.3-21              mmrm_0.2.2.9010           estimability_1.4.1        gld_2.6.6                
  [7] rstudioapi_0.14           proxy_0.4-27              remotes_2.4.2             DT_0.27                   ggrepel_0.9.3             fansi_1.0.4              
 [13] mvtnorm_1.1-3             splines_4.2.0             cachem_1.0.6              rootSolve_1.8.2.3         knitr_1.42                jsonlite_1.8.4           
 [19] mcr_1.3.2                 broom_1.0.3               geepack_1.3.9             compiler_4.2.0            httr_1.4.4                emmeans_1.8.4-1          
 [25] backports_1.4.1           assertthat_0.2.1          Matrix_1.5-3              fastmap_1.1.0             lazyeval_0.2.2            cli_3.6.0                
 [31] later_1.3.0               htmltools_0.5.4           tools_4.2.0               coda_0.19-4               gtable_0.3.1              glue_1.6.2               
 [37] lmom_2.9                  Rcpp_1.0.10               cellranger_1.1.0          jquerylib_0.1.4           vctrs_0.5.2               nlme_3.1-162             
 [43] teal.logger_0.1.1         crosstalk_1.2.0           xfun_0.37                 rbibutils_2.2.13          mime_0.12                 lifecycle_1.0.3          
 [49] renv_0.16.0               staged.dependencies_0.2.8 MASS_7.3-58.2             scales_1.2.1              promises_1.2.0.1          parallel_4.2.0           
 [55] tern.gee_0.1.0            expm_0.999-7              yaml_2.3.7                curl_5.0.0                Exact_3.2                 memoise_2.0.1            
 [61] teal.slice_0.2.0          robslopes_1.1.2           teal.widgets_0.2.0        sass_0.4.5                stringi_1.7.12            e1071_1.7-13             
 [67] checkmate_2.1.0           teal.reporter_0.1.1       boot_1.3-28.1             teal.gallery_0.1.0.9003   Rdpack_2.4                rlang_1.0.6              
 [73] pkgconfig_2.0.3           evaluate_0.20             lattice_0.20-45           fontawesome_0.5.0         purrr_1.0.1               htmlwidgets_1.6.1        
 [79] cowplot_1.1.1             tidyselect_1.2.0          logger_0.2.2              R6_2.5.1                  generics_0.1.3            pillar_1.8.1             
 [85] withr_2.5.0               survival_3.5-3            tibble_3.1.8              crayon_1.5.2              shinyWidgets_0.7.6        utf8_1.2.3               
 [91] plotly_4.10.1             rmarkdown_2.20            readxl_1.4.2              grid_4.2.0                data.table_1.14.8         digest_0.6.31            
 [97] tern.mmrm_0.2.1           xtable_1.8-4              numDeriv_2016.8-1.1       tidyr_1.3.0               httpuv_1.6.9              munsell_0.5.0            
[103] viridisLite_0.4.1         bslib_0.4.2               shinyjs_2.1.0       

Thaks for the help!

Code of Conduct

Contribution Guidelines

Security Policy

pawelru commented 1 year ago

Hi @ElijT would you be able to paste here the outcome of traceback() after error? That would speed-up the process of identifying what was wrong in your case - most likely some outdated package but let's see.

ElijT commented 1 year ago

Sure, here the outcome:

traceback() 20: stop("\nfilters = NULL indicates that the module doesn't need any data while it has the data in formals.", "\nPlease specify filters with the names of needed datasets or exclude data from the arguments.") 19: module(label = label, server = srv_front_page, ui = ui_front_page, ui_args = args, server_args = list(tables = tables, show_metadata = show_metadata), filters = if (show_metadata) "all" else NULL) 18: tm_front_page(label = "Study Information", header_text = c(Info about data source = "Random data are used that have been created with the 'scda' R package"), tables = list(NEST packages used = data.frame(Packages = c("teal.modules.general", "teal.modules.clinical", "scda", "scda.2022")))) 17: modules(tm_front_page(label = "Study Information", header_text = c(Info about data source = "Random data are used that have been created with the 'scda' R package"), tables = list(NEST packages used = data.frame(Packages = c("teal.modules.general", "teal.modules.clinical", "scda", "scda.2022")))), tm_data_table("Data Table"), tm_variable_browser("Variable Browser"), tm_t_summary(label = "Demographic Table", dataname = "ADSL", arm_var = cs_arm_var, summarize_vars = choices_selected(choices = variable_choices(ADSL, demog_vars_adsl), selected = c("SEX", "AGE", "RACE"))), modules(label = "Adverse Events", tm_t_events_summary(label = "AE Summary", dataname = "ADAE", arm_var = cs_arm_var, flag_var_anl = choices_selected(choices = variable_choices("ADAE", ae_anl_vars), selected = ae_anl_vars, keep_order = TRUE), flag_var_aesi = choices_selected(choices = variable_choices("ADAE", aesi_vars), selected = aesi_vars, keep_order = TRUE), add_total = TRUE), tm_t_events(label = "AE by Term", dataname = "ADAE", arm_var = cs_arm_var, 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"), tm_t_events_by_grade(label = "AE Table by Grade", dataname = "ADAE", arm_var = cs_arm_var, llt = choices_selected(choices = variable_choices(ADAE, c("AEDECOD")), selected = c("AEDECOD")), hlt = choices_selected(choices = variable_choices(ADAE, c("AEBODSYS", "AESOC")), selected = "AEBODSYS"), ... 16: isTRUE(lhs) 15: .Call(c_check_list, x, any.missing, all.missing, len, min.len, max.len, unique, names, null.ok) %and% checkListTypes(x, types) 14: checkmate::check_list(modules) 13: teal::init(data = cdisc_data(cdisc_dataset("ADSL", ADSL, code = "ADSL <- synthetic_cdisc_data(\"latest\")$adsl", vars = list(char_vars_adsl = char_vars_adsl)), cdisc_dataset("ADAE", ADAE, code = ADAE_code), cdisc_dataset("ADAETTE", ADAETTE, code = ADAETTE_code), cdisc_dataset("ADEX", ADEX, code = ADEX_code), cdisc_dataset("ADLB", ADLB, code = "ADLB <- synthetic_cdisc_data(\"latest\")$adlb"), cdisc_dataset("ADEG", ADEG, code = "ADEG <- synthetic_cdisc_data(\"latest\")$adeg"), cdisc_dataset("ADVS", ADVS, code = ADVS_code), cdisc_dataset("ADCM", ADCM, code = "ADCM <- synthetic_cdisc_data(\"latest\")$adcm %>% mutate(CMSEQ = as.integer(CMSEQ))"), check = TRUE), modules = modules(tm_front_page(label = "Study Information", header_text = c(Info about data source = "Random data are used that have been created with the 'scda' R package"), tables = list(NEST packages used = data.frame(Packages = c("teal.modules.general", "teal.modules.clinical", "scda", "scda.2022")))), tm_data_table("Data Table"), tm_variable_browser("Variable Browser"), tm_t_summary(label = "Demographic Table", dataname = "ADSL", arm_var = cs_arm_var, summarize_vars = choices_selected(choices = variable_choices(ADSL, demog_vars_adsl), selected = c("SEX", "AGE", "RACE"))), modules(label = "Adverse Events", tm_t_events_summary(label = "AE Summary", dataname = "ADAE", arm_var = cs_arm_var, flag_var_anl = choices_selected(choices = variable_choices("ADAE", ae_anl_vars), selected = ae_anl_vars, keep_order = TRUE), flag_var_aesi = choices_selected(choices = variable_choices("ADAE", aesi_vars), selected = aesi_vars, keep_order = TRUE), ... 12: ..stacktraceon..({ options(shiny.useragg = FALSE) library(dplyr) library(scda) library(scda.2022) library(teal.modules.general) library(teal.modules.clinical) library(nestcolor) library(sparkline) ADSL <- synthetic_cdisc_data("latest")$adsl date_vars_adsl <- names(ADSL)[vapply(ADSL, function(x) { inherits(x, c("Date", "POSIXct", "POSIXlt")) }, logical(1))] char_vars_adsl <- names(Filter(isTRUE, sapply(ADSL, is.character))) ADAE <- synthetic_cdisc_data("latest")$adae ADAETTE <- synthetic_cdisc_data("latest")$adaette ADAETTE <- ADAETTE %>% mutate(is_event = case_when(grepl("TOT", .data$PARAMCD, fixed = TRUE) ~ TRUE, TRUE ~ CNSR == 0)) %>% mutate(n_events = case_when(grepl("TOT", .data$PARAMCD, fixed = TRUE) ~ as.integer(.data$AVAL), TRUE ~ as.integer(is_event))) %>% ... 11: eval(exprs, envir) 10: eval(exprs, envir) 9: sourceUTF8(fullpath, envir = new.env(parent = sharedEnv)) 8: func(fname, ...) 7: appObj() 6: shinyAppDir_appR("app.R", appDir, options = options) 5: shinyAppDir(x) 4: as.shiny.appobj.character(appDir) 3: as.shiny.appobj(appDir) 2: shiny::runApp(file.path(temp_location, app_name), ...) 1: teal.gallery::launch_app("safety")

Thanks for the support,

ElijT commented 1 year ago

Some additionnal information. As error was occuring at " tm_front_page", i got the app code and deleted the corresponding module. In that case the 'app<-' code was working but when I launched the server with 'shinyApp(app$ui, app$server)' I got the following error.

Listening on http://127.0.0.1:5295 Warning: Error in : Assertion on 'data' failed: Must inherit from class 'tdata', but has class 'list'. 3: runApp 2: print.shiny.appobj 1: On the browser, no data was present (see below). image

pawelru commented 1 year ago

It seems that the issue is with the outdated version of teal. Can you please pull the latest devel version - i.e. remotes::install_github("insightsengineering/teal") and say if that helps. I will continue my investigation where to put minimal version requirement so that it won't happen in the future.

ElijT commented 1 year ago

I cross check and have the latest version of teal 0.12.0. For sake of verification, I downgraded to version 0.11.0 and then it didn't work requiring an update to v0.12.0. Reupgrading lead to the initial issue...

pawelru commented 1 year ago

My point here is to upgrade it to be > 0.12.0, in particular: >= 0.12.0.9012. You can do that installing pkg directly from GH using main branch -> remotes::install_github("insightsengineering/teal") or using staged.dependencies as mentioned in the README file. A little bit of background now. These apps are based on development version of pkgs for now - as a next step we would work to version them and add latest release but most likely it would take a while.

ElijT commented 1 year ago

Hi Pawelru, Thanks for the help! Actually quite a few packages were based on latest release and not current version. I have updated packages and voilà! If anyone stumble accross the same issue, here are the specific set of teal packages :

remotes::install_github("insightsengineering/teal@bbb2e17") remotes::install_github("insightsengineering/tern.mmrm@233e3f359") remotes::install_github("insightsengineering/formatters@8672bca") remotes::install_github("insightsengineering/teal.modules.clinical@b63ba64") remotes::install_github("insightsengineering/teal.modules.general@89d22f0") remotes::install_github("insightsengineering/teal.transform@c07e750")

Thanks again for pointing out to the correct answer 🥇