selectsizeInput working slow for 27000 entries

...
In my shinny app ui the drop down is working very slow . I am using 27000 entries in drop down i am using selectizeInput and then updateSelectizeInput to update value

my code - in ui.R

selectizeInput("Gene_name", "Select Genes", NULL,
                   multiple = F,  options = list(placeholder = "Select 
                   Gene", maxOptions = 27000))

in server.R

updateSelectizeInput(session, 'Gene_name', 
                    choices = Gene_Choices, selected=Gene_Choices[1],
                    server = TRUE)

datatype of Gene_Choices is "character" with arround 26000 entries. Dropdown is taking very longer time to show entries. Thanks for any help in advance.

Can you pull the gene list from a database for performance? Where are you getting the gene list now?

maxOptions of 27,000 will be slow to render in the browser. You want to show only first 1,000 or so then as the user searches, Shiny will reference a reactive like this. Note, you initialize the selectizeInput as NULL, then use an observe to update the drop-down and set server=TRUE so it's not all rendered on the front-end but still allows the user to search the list of genes.

  genes <- reactive({
    genes_df <- get_gene_symbols()
  })


selectizeInput('genes', 'Genes', choices = NULL, multiple = TRUE)

 observe({
    updateSelectizeInput(session = session, inputId = 'genes', choices = data.frame(value = genes()$gene_symbol, label = genes()$gene_symbol), server = TRUE)
  })
2 Likes