insightsengineering / teal.slice

Reproducible slice module for teal applications
https://insightsengineering.github.io/teal.slice/
Other
11 stars 5 forks source link

Add filter is minimised to a single button in active filters #599

Closed vedhav closed 2 months ago

vedhav commented 3 months ago

Closes #592

Please checkout to these branches before testing:

  1. teal - 669_insertUI@main
  2. teal.slice - remove_add_filters_ui@669_insertUI@main

Example shiny app to test:

pkgload::load_all("teal.slice")
library(shinyjs)

# create a FilteredData object
data(miniACC, package = "MultiAssayExperiment")
datasets <- init_filtered_data(list(iris = iris, mtcars = mtcars, MAE = miniACC))

# setting initial state
set_filter_state(
  datasets = datasets,
  filter = teal_slices(
    teal_slice(dataname = "iris", varname = "Species", selected = "virginica", keep_na = FALSE),
    teal_slice(dataname = "mtcars", id = "4 cyl", title = "4 Cylinders", expr = "cyl == 4"),
    teal_slice(dataname = "mtcars", varname = "mpg", selected = c(20.0, 25.0), keep_na = FALSE, keep_inf = FALSE),
    teal_slice(
      dataname = "MAE", varname = "years_to_birth", selected = c(30, 50), keep_na = TRUE
    ),
    teal_slice(
      dataname = "MAE", varname = "vital_status", selected = "1", keep_na = FALSE
    ),
    teal_slice(
      dataname = "MAE", varname = "gender", selected = "female", keep_na = TRUE
    ),
    teal_slice(
      dataname = "MAE", varname = "ARRAY_TYPE", selected = "", keep_na = TRUE
    )
  )
)

ui <- fluidPage(
  shinyjs::useShinyjs(),
  fluidRow(
    column(
      width = 9,
      tabsetPanel(
        tabPanel(title = "iris", dataTableOutput("iris_table")),
        tabPanel(title = "mtcars", dataTableOutput("mtcars_table"))
      )
    ),
    # ui for the filter panel
    column(width = 3, datasets$ui_filter_panel("filter_panel"))
  )
)

server <- function(input, output, session) {
  # this is the shiny server function for the filter panel and the datasets
  # object can now be used inside the application
  datasets$srv_filter_panel("filter_panel")

  # get the filtered datasets and put them inside reactives for analysis
  iris_filtered_data <- reactive(datasets$get_data(dataname = "iris", filtered = TRUE))
  mtcars_filtered_data <- reactive(datasets$get_data(dataname = "mtcars", filtered = TRUE))

  output$iris_table <- renderDataTable(iris_filtered_data())
  output$mtcars_table <- renderDataTable(mtcars_filtered_data())
}

shinyApp(ui, server)

Example teal app to test

pkgload::load_all("teal.slice")
pkgload::load_all("teal")
library(teal.modules.general)

# create a FilteredData object
data(miniACC, package = "MultiAssayExperiment")

data <- teal_data(
  iris = iris,
  mtcars = mtcars,
  MAE = miniACC
)

app <- init(
  data = data,
  modules = tm_variable_browser()
)

shinyApp(app$ui, app$server)
vedhav commented 3 months ago

I see that the teal app fails. I'm looking into this now.

vedhav commented 3 months ago

Nevermind, It works fine. I was in the wrong teal branch 🤦🏽