Hello,
I face an issue with my shiny app, indeed I have a numericInput that dynamically add a list of two inputs (one textInput and one SelectizeInput). I then use updateSelectizeInput in order to update the selectizeInput. My problem is that in the first place the selectizeInput is not fill with anything. It only works after clicking one time one the numericInput. Here is my code :
ui side :
tabPanel("Integration metrics", icon = icon("layer-group"),
sidebarLayout(
sidebarPanel(selectizeInput("IntegrationChoice","Which object do you want to choose ?", choices =character(0)),
radioButtons("ScinaOrNot","Do you want to annotate your cells using SCINA",choices = c("Yes", "No"), selected = "No"),
conditionalPanel("input.ScinaOrNot == 'Yes'",radioButtons("FileOrList", "From what kind of list do you want to pass the markers for automatic annotation",choices =c("File", "List"))),
conditionalPanel(condition = "input.ScinaOrNot == 'Yes' && input.FileOrList == 'File'", fileInput("MarkerFileList", "Upload file")),
conditionalPanel("input.ScinaOrNot == 'Yes'",textInput("AnnotationName","Name for your annotation (mandatory)")),
conditionalPanel(condition = "input.ScinaOrNot == 'Yes' && input.FileOrList == 'List'", numericInput("NumberCellType","How many cell type do you want to annotate ?", value = 1, min = 1)),
conditionalPanel(condition = "input.ScinaOrNot == 'Yes' && input.FileOrList == 'List'",uiOutput('PanelNumberCellType')),
conditionalPanel("input.ScinaOrNot == 'Yes'",radioButtons("AllowUnknown", "Allow unknown annotation (advised)", choices = c("Yes","No"), selected = "Yes")),
conditionalPanel("input.ScinaOrNot == 'Yes'",radioButtons("AllowOverlap","Allow overlap of markers between cell types", choices = c("Yes","No"), selected = "Yes")),
conditionalPanel("input.ScinaOrNot == 'Yes'",actionButton("AutomaticAnnotationIntMetrics", "Annotate")),
br(),
br(),
conditionalPanel("input.ScinaOrNot == 'Yes'",downloadButton("ProbabilitiesScina", "Download probabilities")),
width = 2),
server side :
observeEvent(input$NumberCellType,{
output$PanelNumberCellType <- renderUI({
tagList(
lapply(seq(1,input$NumberCellType), function(i){
tagList(
textInput(paste("CT", i, sep="_"), "Give a name to your cell type"),
selectizeInput(paste("markersCT",i,sep="_"), "Give some markers (between 2 and 20 is advised)",choices=character(0), multiple = T),
)
})
)
})
lapply(seq(1,input$NumberCellType), function(i){
updateSelectizeInput(session,paste("markersCT",i,sep="_"),choices=genes, server = TRUE)
})
})
Thanks in advance for the help
Loïc