Skip to contents

[Experimental]

This defines the server part for the assay specification.

Usage

assaySpecServer(id, assays, exclude_assays = character())

Arguments

id

(string) the shiny module id.

assays

(reactive character)
available assays in the currently selected experiment.

exclude_assays

(character)
names of the assays which should not be included in choices in the teal module.

Value

The chosen assay as a reactive string.

See also

assaySpecInput() for the module UI.

Examples

ui <- function(id,
               datasets) {
  ns <- NS(id)
  teal.widgets::standard_layout(
    encoding = div(
      experimentSpecInput(
        ns("experiment"),
        datasets,
        "MAE"
      ),
      assaySpecInput(
        ns("assay"),
        label_assays = "Please choose assay"
      )
    ),
    output = textOutput(ns("result"))
  )
}

server <- function(id, datasets) {
  moduleServer(id, module = function(input, output, session) {
    experiment <- experimentSpecServer(
      "experiment",
      datasets,
      "MAE"
    )
    assay <- assaySpecServer(
      "assay",
      experiment$assays,
      exclude_assays = c("counts", "cpm", "tpm", "bla")
    )
    output$result <- renderPrint({
      assay()
    })
  })
}

my_app <- function() {
  mae <- hermes::multi_assay_experiment
  mae_name <- "MAE"
  mae_data <- dataset(mae_name, mae)
  data <- teal_data(mae_data)
  app <- init(
    data = data,
    modules = modules(
      module(
        label = "assaySpec example",
        server = server,
        ui = ui,
        filters = "all"
      )
    )
  )
  shinyApp(app$ui, app$server)
}
if (interactive()) {
  my_app()
}