You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.6 KiB

library(shiny)
library(Seurat)
library(shinyFiles)
library(ggplot2)
# Define UI for application
ui <- fluidPage(
# Application title
titlePanel("scMonitor"),
sidebarLayout(
sidebarPanel(
shinyFilesButton("file", label="Select File", title="Select a Seurat Object", multiple=F),
uiOutput('groupby'),
uiOutput('facetby')
),
mainPanel(
plotOutput("umapPlot")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
dades<-reactiveValues()
dades$seu<-NULL
volumes <- c(Home = fs::path_home(), "R Installation" = R.home(), getVolumes()())
shinyFileChoose(input, 'file', roots=volumes)
observe({
if (!is.integer(input$file)){
print(parseFilePaths(volumes, input$file))
dades$seu<-readRDS(parseFilePaths(volumes, input$file)$datapath)
}
})
output$groupby<-renderUI({
if (!is.null(dades$seu)){
selectInput("groupby", "GroupBy", c("Default", colnames(dades$seu@meta.data)))
}
})
output$facetby<-renderUI({
if (!is.null(dades$seu)){
selectInput("facetby", "FacetBy", c("None", colnames(dades$seu@meta.data)))
}
})
output$umapPlot <- renderPlot({
observeEvent(dades$seu, {})
if (!is.null(dades$seu)){
plot<-DimPlot(dades$seu,
group.by = if(input$groupby != "Default"){input$groupby}else{NULL},
split.by=if(input$facetby != "None"){input$facetby}else{NULL})+
theme(aspect.ratio=1)
plot
}
})
}
# Run the application
shinyApp(ui = ui, server = server)