Commit 1abdad2a authored by Bagueneau Mathias's avatar Bagueneau Mathias
Browse files

- Ajout du choix de fichier : upload ou données contenues dans ./data/

parent ccff0e8f
......@@ -129,6 +129,7 @@ sidebar <- dashboardSidebar(
h4(align="center", "Control Panel"),
div(actionLink("help1", "", icon = icon("far fa-question-circle")), align="center"),
fileInput(inputId="file1", label="Upload your *.rds file :", accept = ".rds", placeholder=""),
uiOutput("selectfile"),
conditionalPanel(condition= "output.fileUploaded", align="center",
radioButtons(inputId="graph", label= "Choose the graph mode :", c("t-SNE" = "tsne", "UMAP" = "umap")),
checkboxInput(inputId="show_clusters", label="Clusters informations", value=FALSE),
......@@ -221,8 +222,6 @@ ui <- dashboardPage(
sidebar,
body
)
### ----------------------------- Server logic -----------------------------------------------------
......@@ -230,12 +229,17 @@ server <- function(input, output, session) {
options(shiny.maxRequestSize = 2500*1024^2, spinner.color="#9ae0df", spinner.type=1)
## Upload a file --------
## Upload and gestion of files --------
filedata <- reactiveValues()
observe ({
infile <- input$file1
if (is.null(infile)) {return (NULL)}
filedata$data <- readRDS(infile$datapath)
if (!is.null(input$file1)) {
infile <- input$file1
if (is.null(infile)) {return (NULL)}
filedata$data <- readRDS(infile$datapath)
} else {
req(input$file)
filedata$data <- readRDS(paste0("./data/",input$file))
}
genesList <- filedata$data@assays$SCT@data@Dimnames[1]
updateSelectizeInput(session, "genes", choices = genesList[[1]], selected = "IGKC")
updateSelectizeInput(session, "genes2", choices = genesList[[1]], selected = "IGKC")
......@@ -246,10 +250,17 @@ server <- function(input, output, session) {
})
outputOptions(output, 'fileUploaded', suspendWhenHidden=FALSE)
## Select File --
output$selectfile <- renderUI ({
req(is.null(input$file1))
selectInput(inputId="file", label="Or choose a file :", choices = c("",list.files(path = "./data",full.names = FALSE,recursive = FALSE)))
})
## Graphs & Tables Generations --------
markersData <- reactive ({
t <- paste0("markers",str_extract(input$fsel,"(\\d.*)"))
filedata$data@misc[[t]]
t <- paste0("Resolution.",str_extract(input$fsel,"(\\d.*)"))
filedata$data@misc$markers[[t]]
})
factorsplotData <- reactive ({
......@@ -330,7 +341,7 @@ server <- function(input, output, session) {
output$markers_table <- renderDataTable ({
req(filedata$data)
req(markersData() != "")
datatable(markersData()[c(3,4,2,1,5)]) %>% formatRound(columns=c(3,4,2,1,5), digits=5)
datatable(markersData()[c(6,3,4,2,1,5)]) %>% formatRound(columns=c(3,4,2,1,5), digits=5)
})
......@@ -350,11 +361,11 @@ server <- function(input, output, session) {
})
heatmapData <- reactive ({
req(input$goheatmap)
t <- paste0("markers",str_extract(input$fsel3,"(\\d.*)"))
t <- paste0("Resolution.",str_extract(input$fsel3,"(\\d.*)"))
validate(
need(filedata$data@misc[[t]] != "", "The markers may have not been calculated yet. Please use a file with markers.")
need(filedata$data@misc$markers[[t]] != "", "The markers may have not been calculated for this factor yet.")
)
topgenes <- filedata$data@misc[[t]] %>% group_by(cluster) %>% top_n(n = input$top_number, wt = avg_logFC)
topgenes <- filedata$data@misc$markers[[t]] %>% group_by(cluster) %>% top_n(n = input$top_number, wt = avg_logFC)
datascale <- ScaleData(object = filedata$data, features = topgenes$gene)
DoHeatmap(object = datascale, features = topgenes$gene, group.by=input$fsel3) + NoLegend() + ggtitle(paste(input$file1$name,"- HeatMap -", input$fsel3,"- top",input$top_number,"genes"))
})
......@@ -568,7 +579,7 @@ server <- function(input, output, session) {
output$markbutton <- renderUI ({
req(filedata$data)
req(input$choice_compare == "f_compare")
actionButton(inputId="findmarkers", label=strong("Find Markers"))
actionButton(inputId="findmarkers", label=strong("Find Markers"), icon = icon("fas fa-bookmark"))
})
observeEvent(input$findmarkers, {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment