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

[Bug]: Error creating a Teal app - Validation fail in FilteredData constructor #492

Closed
3 tasks done
vedhav opened this issue Nov 24, 2023 · 10 comments · Fixed by insightsengineering/teal.modules.hermes#349 or insightsengineering/teal.modules.hermes#351
Labels
bug Something isn't working core

Comments

@vedhav
Copy link
Contributor

vedhav commented Nov 24, 2023

What happened?

Note: Using the current refactor now
When running the example app for teal.modules.hermes::adtteSpecServer the validation fails with this error:

Listening on http://127.0.0.1:6616
Warning: Error in self$get_data: Assertion on 'dataname' failed: Must be a subset of the empty set, i.e. also empty.
  3: runApp
  2: print.shiny.appobj
  1: <Anonymous>

On the main branch the error is:

Warning: Error in validate_dataset_args: Assertion on 'dataset_args' failed: Must be of type 'list', not 'NULL'.

Example app

ui <- function(id) {
  ns <- NS(id)

  teal.widgets::standard_layout(
    encoding = uiOutput(ns("encoding_ui")),
    output = verbatimTextOutput(ns("summary"))
  )
}

server <- function(id, data, filter_panel_api) {
  checkmate::assert_class(data, "reactive")
  checkmate::assert_class(shiny::isolate(data()), "teal_data")
  moduleServer(id, function(input, output, session) {
    output$asdf <- renderUI({
      div(
        experimentSpecInput(session$ns("experiment"), data, mae_name = "MAE"),
        assaySpecInput(session$ns("assay")),
        geneSpecInput(session$ns("genes"), funs = list(Mean = colMeans)),
        adtteSpecInput(session$ns("adtte"))
      )
    })
    experiment <- experimentSpecServer(
      "experiment",
      data = data,
      filter_panel_api = filter_panel_api,
      mae_name = "MAE"
    )
    assay <- assaySpecServer(
      "assay",
      assays = experiment$assays
    )
    genes <- geneSpecServer(
      "genes",
      funs = list(Mean = colMeans),
      gene_choices = experiment$genes
    )
    adtte <- adtteSpecServer(
      "adtte",
      data = data,
      adtte_name = "ADTTE",
      mae_name = "MAE",
      adtte_vars = list(
        aval = "AVAL",
        avalu = "AVALU",
        is_event = "is_event",
        paramcd = "PARAMCD",
        usubjid = "USUBJID"
      ),
      experiment_data = experiment$data,
      experiment_name = experiment$name,
      assay = assay,
      genes = genes,
      probs = reactive({
        0.5
      })
    )
    output$summary <- renderPrint({
      binned_adtte_subset <- adtte$binned_adtte_subset()
      summary(binned_adtte_subset)
    })
  })
}

my_app <- function() {
  data <- teal_data()
  data <- within(data, {
    ADTTE <- teal.modules.hermes::rADTTE %>%
      dplyr::mutate(is_event = .data$CNSR == 0)
    MAE <- hermes::multi_assay_experiment
  })
  datanames <- c("ADTTE", "MAE")
  datanames(data) <- datanames
  join_keys(data) <- default_cdisc_join_keys[datanames]

  app <- init(
    data = data,
    modules = modules(
      module(
        label = "adtteSpec example",
        server = server,
        ui = ui,
        datanames = "all"
      )
    )
  )
  shinyApp(app$ui, app$server)
}

if (interactive()) {
  my_app()
}

sessionInfo()

R version 4.3.0 (2023-04-21)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 14.1.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

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

time zone: Asia/Kolkata
tzcode source: internal

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

other attached packages:
 [1] teal.modules.hermes_0.1.5.9007 teal_0.14.0.9024              
 [3] teal.transform_0.4.0.9007      teal.slice_0.4.0.9024         
 [5] teal.data_0.3.0.9015           shinytest2_0.3.1              
 [7] ggplot2_3.4.4                  magrittr_2.0.3                
 [9] testthat_3.2.0                 shiny_1.8.0                   

loaded via a namespace (and not attached):
  [1] splines_4.3.0               later_1.3.1                
  [3] hermes_1.6.0                filelock_1.0.2             
  [5] bitops_1.0-7                tibble_3.2.1               
  [7] R.oo_1.25.0                 XML_3.99-0.15              
  [9] lifecycle_1.0.4             Rdpack_2.6                 
 [11] edgeR_4.0.1                 doParallel_1.0.17          
 [13] rprojroot_2.0.4             processx_3.8.2             
 [15] lattice_0.22-5              MultiAssayExperiment_1.28.0
 [17] backports_1.4.1             limma_3.58.1               
 [19] plotly_4.10.3               sass_0.4.7                 
 [21] rmarkdown_2.25              jquerylib_0.1.4            
 [23] yaml_2.3.7                  remotes_2.4.2.1            
 [25] httpuv_1.6.12               sessioninfo_1.2.2          
 [27] pkgbuild_1.4.2              DBI_1.1.3                  
 [29] RColorBrewer_1.1-3          abind_1.4-5                
 [31] pkgload_1.3.3               zlibbioc_1.48.0            
 [33] R.cache_0.16.0              GenomicRanges_1.54.1       
 [35] purrr_1.0.2                 R.utils_2.12.3             
 [37] BiocGenerics_0.48.1         RCurl_1.98-1.13            
 [39] styler_1.10.2               rappdirs_0.3.3             
 [41] circlize_0.4.15             GenomeInfoDbData_1.2.11    
 [43] IRanges_2.36.0              S4Vectors_0.40.1           
 [45] ggrepel_0.9.4               teal.widgets_0.4.1.9008    
 [47] teal.reporter_0.2.1.9012    shinyvalidate_0.1.3        
 [49] codetools_0.2-19            DelayedArray_0.28.0        
 [51] xml2_1.3.5                  DT_0.30                    
 [53] tidyselect_1.2.0            shape_1.4.6                
 [55] shinyRadioMatrix_0.2.1      shinyWidgets_0.8.0         
 [57] BiocFileCache_2.10.1        matrixStats_1.1.0          
 [59] stats4_4.3.0                jsonlite_1.8.7             
 [61] GetoptLong_1.0.5            ellipsis_0.3.2             
 [63] survival_3.5-7              iterators_1.0.14           
 [65] foreach_1.5.2               progress_1.2.2             
 [67] tools_4.3.0                 rtables_0.6.5.9013         
 [69] Rcpp_1.0.11                 glue_1.6.2                 
 [71] gridExtra_2.3               teal.code_0.4.1.9009       
 [73] SparseArray_1.2.2           xfun_0.41                  
 [75] MatrixGenerics_1.14.0       usethis_2.2.2              
 [77] ggfortify_0.4.16            GenomeInfoDb_1.38.1        
 [79] dplyr_1.1.4                 withr_2.5.2                
 [81] formatR_1.14                fastmap_1.1.1              
 [83] fansi_1.0.5                 shinyjs_2.1.0              
 [85] callr_3.7.3                 digest_0.6.33              
 [87] R6_2.5.1                    mime_0.12                  
 [89] colorspace_2.1-0            biomaRt_2.58.0             
 [91] RSQLite_2.3.3               R.methodsS3_1.8.2          
 [93] utf8_1.2.4                  tidyr_1.3.0                
 [95] generics_0.1.3              data.table_1.14.8          
 [97] prettyunits_1.2.0           httr_1.4.7                 
 [99] htmlwidgets_1.6.3           S4Arrays_1.2.0             
[101] pkgconfig_2.0.3             gtable_0.3.4               
[103] blob_1.2.4                  ComplexHeatmap_2.18.0      
[105] XVector_0.42.0              brio_1.1.3                 
[107] htmltools_0.5.7             teal.logger_0.1.3.9007     
[109] profvis_0.3.8               clue_0.3-65                
[111] scales_1.2.1                Biobase_2.62.0             
[113] png_0.1-8                   knitr_1.45                 
[115] rstudioapi_0.15.0           rjson_0.2.21               
[117] curl_5.1.0                  checkmate_2.3.0            
[119] cachem_1.0.8                GlobalOptions_0.1.2        
[121] stringr_1.5.1               parallel_4.3.0             
[123] miniUI_0.1.1.1              shinycssloaders_1.0.0      
[125] AnnotationDbi_1.64.1        desc_1.4.2                 
[127] pillar_1.9.0                grid_4.3.0                 
[129] logger_0.2.2                vctrs_0.6.4                
[131] urlchecker_1.0.1            promises_1.2.1             
[133] tern_0.9.2.9017             dbplyr_2.4.0               
[135] xtable_1.8-4                cluster_2.1.4              
[137] evaluate_0.23               cli_3.6.1                  
[139] locfit_1.5-9.8              compiler_4.3.0             
[141] rlang_1.1.2                 crayon_1.5.2               
[143] formatters_0.5.4.9003       ps_1.7.5                   
[145] forcats_1.0.0               fs_1.6.3                   
[147] stringi_1.8.2               viridisLite_0.4.2          
[149] assertthat_0.2.1            Biostrings_2.70.1          
[151] munsell_0.5.0               lazyeval_0.2.2             
[153] devtools_2.4.5              Matrix_1.6-3               
[155] hms_1.1.3                   bit64_4.0.5                
[157] KEGGREST_1.42.0             statmod_1.5.0              
[159] SummarizedExperiment_1.32.0 rbibutils_2.2.16           
[161] fontawesome_0.5.2           broom_1.0.5                
[163] memoise_2.0.1               bslib_0.6.0                
[165] bit_4.0.5

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.
@donyunardi
Copy link
Contributor

Please check again as update was made and we don't have the validate_dataset_args function anymore in the refactor branch.

@vedhav
Copy link
Contributor Author

vedhav commented Dec 1, 2023

After using the refactor branch. We get a new error and I've edited the issue description with it.

@chlebowa
Copy link
Contributor

chlebowa commented Dec 1, 2023

I get a different one 🤔

Error in module(label = "adtteSpec example", server = server, ui = ui,  : 
  Called from module(label = "adtteSpec example", ...)
  `ui` with `data` or `datasets` argument is no longer accepted.
  If some `ui` inputs depend on data, please move the logic to your `server` instead.
  Possible solutions are renderUI() or updateXyzInput() functions.

As expected.

@chlebowa
Copy link
Contributor

chlebowa commented Dec 1, 2023

Right. After modifying the ui function in the example (not exactly current refactor, is it?), I get the same error.

Warning: Error in self$get_data: Assertion on 'dataname' failed: Must be a subset of the empty set, i.e. also empty.

It is raised here:
teal::srv_teal() > teal:::teal_data_to_filtered_data() > teal.slice::init_filtered_data() > teal.slice:::FilteredData$new() > teal.slice:::FilteredData$set_dataset()

In the last call one of the arguments is passed self$get_data(parent_dataname, filtered = TRUE) and therein lies the problem.

@chlebowa
Copy link
Contributor

chlebowa commented Dec 1, 2023

All of this is because the datasets are ADTTE and MAE.

The error is not triggered when ADSL is included in the app.

Now, who messed with examples in tmh? 😠

@chlebowa
Copy link
Contributor

chlebowa commented Dec 1, 2023

Then there's another bug in experimentSpecInput. Do I have to look at blame?

@vedhav
Copy link
Contributor Author

vedhav commented Dec 1, 2023

Then there's another bug in experimentSpecInput. Do I have to look at blame?

Well looks like I'm the guilty one. In my defense, this was back when we were passing teal_data into UI and reactive(<teal_data>) into the server, so by convention, this function was a module UI function.
Screenshot 2023-12-02 at 2 35 12 AM

vedhav pushed a commit to insightsengineering/teal.modules.hermes that referenced this issue Dec 1, 2023
Fixes [this
issue](insightsengineering/teal.slice#492)

Modified example for `adtteSpec` to also include `ADSL` dataset.
:exclamation: I had to take it from `teal.data` so it's probably not the
ideal solution.
Adapted `experimentSpec` to new `teal_data` class.
@vedhav
Copy link
Contributor Author

vedhav commented Dec 1, 2023

btw I'm using this cool VS code extension GitLens that does blame on every active line which is so cool and helpful.

@donyunardi
Copy link
Contributor

@vedhav Can we close this now?

@vedhav
Copy link
Contributor Author

vedhav commented Jan 25, 2024

@donyunardi insightsengineering/teal.modules.hermes#351 should close it. Not sure how this was missed during example app changes (probably because they are non tm_* examples)

danielinteractive added a commit to insightsengineering/teal.modules.hermes that referenced this issue Feb 13, 2024
Closes insightsengineering/teal.slice#492

We don't accept data in module UI anymore & there was a missing dataname
in one example.

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Daniel Sabanes Bove <[email protected]>
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
3 participants