I am working on a brilliant application that takes a DNA sequence (for example, "ACTGACTG"), performs some calculations, and displays the result when a button is clicked. When I store an object Biostrings::DNAStringin an object reactiveValues, my brilliant application only responds to changes if the number of characters in the sequence changes, for example. if "AA" is entered first, the schedule does not change if "CC" is entered, but changes if "AAAA" is entered. It reacts to all changes if I store the object as a symbol. Here's a simplified example:
library(shiny)
library(shinyBS)
library(Biostrings)
library(ggplot2)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
ref_seqs <- textInput("ref_seqs", "Sequence", width = "100%",
value = NULL, placeholder = "ATGCTGCTGGTTATTAGATTAGT"),
run_guide <- bsButton("run", 'Run', type = "action",
style = "success", block = TRUE)
),
mainPanel(
plotOutput("reference")
)
)
)
server <- function(input, output) {
ref <- reactiveValues(sq = NULL)
dat <- reactive({
req(input$run)
chrs <- strsplit(as.character(ref$sq),"")[[1]]
data.frame(label = chrs, x = seq_along(chrs))
})
observeEvent(input$run, {
ref$sq <- Biostrings::DNAString(input$ref_seqs)
})
output$reference <- renderPlot({
ggplot(dat(), aes(x = x, y = factor(1), label = label)) + geom_text(size = 12)
})
}
shinyApp(ui = ui, server = server)
If I comment out the line ref$sq <- Biostrings::DNAString(input$ref_seqs)and uncomment the line below it, the plot is updated after the changes.
- , ? Do reactiveValues ? !