Take a look at the [reactiveGeneSetSelect()] module to select gene sets but also enable the user to first filter the genesets to choose from based on some global criteria.

geneSetSelect(
  input,
  output,
  session,
  src,
  server = TRUE,
  maxOptions = Inf,
  sep = "_::_"
)

geneSetSelectUI(id, label = "Select Gene Set")

updateGeneSetSelect(
  session,
  id,
  label = NULL,
  choices = NULL,
  selected = NULL,
  options = list(),
  server = FALSE
)

gs.render.select.ui(
  ns,
  choices,
  server = TRUE,
  maxOptions = 1000,
  sep = "_::_"
)

gs.select.choices(mg, sep = "_::_")

Arguments

input, output, session

the shiny-required bits for the module

src

A [SparrowResultContainer()] object

server

logical indicating wether the options should be generated in the server module, default: `TRUE`

maxOptions

a paremeter used to customize the `GeneSetSelect::selectizeInput` UI element to configure the maximum number of elements to include in the select dropdown, the remainder of the genesets will be loaded from the server side. Default: `Inf` for all.

sep

the string used to concatenate geneset `collection` and `name` to generate a uniqe string for a geneset

id

the 'naked' module id

label

the label for the [shiny::selectizeInput()]

choices

the output of `gs.select.choices(SparrowResult)`

selected

The initially selected value (or multiple values if multiple = TRUE). If not specified then defaults to the first value for single-select lists and no values for multiple select lists.

options

A list of options. See the documentation of selectize.js for possible options (character option values inside base::I() will be treated as literal JavaScript code; see renderDataTable() for details).

ns

the namespace function for this module

mg

`SparrowResult` to build options for

Value

a reactive list of information about the selected geneset.

collection

the collection its from

name

the name within the collection

stats

a data.frame of "contrast statistics" for the features in the geneset

select.id

the shiny id for this module

sep

the separator used to key the collection,name string for this geneset

a properly wired `[shiny::selectizeInput()]` UI element.

`data.table` to populate `choices` of `selectizeInput`

Details

This code was inspired from the dynamicSelectShinyModule.R gist.

Functions

  • geneSetSelectUI: the ui for the module

  • updateGeneSetSelect: update geneSetSelect externally. with new choices

  • gs.render.select.ui: Internal function to build a `selectizeInput` widget that is specific to a SparrowResult.

  • gs.select.choices: Internal function to build a `data.frame` used to populate geneset choices for a select input.

    Note that when returning a data.frame for the choices from `gs.select.choice()`, we need a column called `"value"` and a column called `"label"`.

    * `value`: the value that is sent back when an item is selected * `label`: athe text that appears in the selection after its triggered

Module Return

Returns information about the `geneSetSelect` object

Examples

sres <- sparrow::exampleSparrowResult()
app <- shiny::shinyApp(
  ui = shiny::shinyUI(shiny::fluidPage(
    exampleUISetup(),
    title = "Gene Set Select",
    geneSetSelectUI("mod"))),
  server = function(input, output, session) {
    src <- shiny::reactive(SparrowResultContainer(sres))
    shiny::callModule(geneSetSelect, "mod", src)
  })
if (interactive()) {
  shiny::runApp(app)
}