'I am having trouble multiple keywords separated by comma which can be used as a successful input in the function - does anyone have ideas?

This is UMAP function and by entering the colors names you can color the clusters but it is not working. It says that it sees only one color and 20 are needed. This is Seurat package.

This is the function that I used originally without shiny and it works

DimPlot(data, reduction = "umap", cols = c(colors[30], colors[1], colors[2], colors[28], colors[3], 
                                       colors[4], colors[5], "mistyrose", "lightpink4",  colors[21], "grey", colors[7], colors[9], colors[11], colors[24], colors[26], "magenta" ,"gold", "mistyrose2"), split.by = "orig.ident") 

This code below if from the shiny app I am making

server <- function(input, output) {

col = renderText({ input$label.color })
cols <-  reactive({input$cols})

output$value <- renderText({ input$cols})

  output$tsneplot<-renderPlot({
    input$ts
    if (input$spl == "NULL") {
      isolate(DimPlot(data, seed = input$seed.use,reduction = "tsne",pt.size=input$pt.size, label = T, repel = T, label.size = input$label.size, cells = NULL, cols = NULL, label.color = "red"))
    } else {
      isolate(DimPlot(data, reduction = "tsne",pt.size= input$pt.size, split.by = input$spl ,cells = NULL, cols = c(cols()), label = T, label.size = input$label.size, label.color = col(), repel = T ))
    }
  })
  

}

I have seen the output value of text cols it shows exactly in the upper portion of the code below but for some reason while it is in the app and running the dimplot function it thinks it is only one string. Without the concept of shiny it works the code is tested but in the shiny platform it is not.

enter image description here



Solution 1:[1]

To examine what value cols() actually returns in your app, you can include a console-like output in your test version:

ui <- fluidPage(
    ## ...
    verbatimTextOutput('log')
    ## ...
)


server <- function(input, output, session) {
    ## ...
    output$log <- renderPrint(cols()) 
    ## ...
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 I_O