So I'm trying to load several large datasets with future/promises like I saw in How to use future/promises to read rds files in background to decrease initial loading latency in IE11 but I'm pretty sure I'm doing it wrong. Currently I'm having a very slow page load, and then "subscript out of bounds" errors for each of my plots. Why? I don't have a clue. I'm assuming I've got some sort of syntax error, but I can't spot it. Help appreciated!
library(shiny)
library(Seurat)
library(shinyWidgets)
library(promises)
library(future)
plan(multisession)
promise_1 <- future(readRDS("data/sample1.rds"))
promise_2 <- future(readRDS("data/sample2.rds"))
promise_3 <- future(readRDS("data/sample3.rds"))
promise_4 <- future(readRDS("data/sample4.rds"))
promise_5 <- future(readRDS("data/sample5.rds"))
promise_6 <- future(readRDS("data/sample6.rds"))
promise_7 <- future(readRDS("data/sample7.rds"))
# Define UI for application
ui <- fluidPage(
# Application title
titlePanel("scRNAseq data browser"),
fluidRow(
column(4,
sidebarPanel(
radioButtons("dataset", label = h3("Dataset"),
choices = list("sample1" = "promise_1", "sample3" = "promise_3", "sample2" = "promise_2", "sample4" = "promise_4", "sample6" = "promise_6", "sample5" = "promise_5", "sample7" = "promise_7"),
selected = "promise_1"),
helpText("Enter gene names in CAPS. Gene names must be exact."),
textInput("gene2", label = "Gene Name", value = "GAPDH"),
textInput("gene3", label = "Gene Name", value = "GAPDH"),
textInput("gene4", label = "Gene Name", value = "GAPDH")
)
),
column(8,
column(6,
mainPanel(
plotOutput("dimPlot1", width = "150%"),
plotOutput("genePlot2", width = "150%")
)
),
column(6,
mainPanel(
plotOutput("genePlot3", width = "150%"),
plotOutput("genePlot4", width = "150%")
)
)
)
)
)
server <- function(input, output, session) {
output$dimPlot1 <- renderPlot({
DimPlot(input$dataset, reduction = "umap", group.by = "ShortID", label = T, label.size = 4)
})
output$genePlot2 <- renderPlot({
FeaturePlot(input$dataset, features = (input$gene2), reduction = "umap")
})
output$genePlot3 <- renderPlot({
FeaturePlot(input$dataset, features = (input$gene3), reduction = "umap")
})
output$genePlot4 <- renderPlot({
FeaturePlot(input$dataset, features = (input$gene4), reduction = "umap")
})
# output$res <- renderPrint({
# input$search
# })
}
# Run the application
shinyApp(ui = ui, server = server)