Commit 9436935d authored by Bagueneau Mathias's avatar Bagueneau Mathias
Browse files

- Changements sur la page Genes

parent 1b8184c1
......@@ -76,6 +76,7 @@ sidebar <- dashboardSidebar(
uiOutput("fchoice4"), br(),
uiOutput("group"), br(),
radioButtons("gographtype", label="Choose a graph type :", choices=c("Dotplot"="dplot", "Barplot"="bplot", "Emapplot" = "eplot")), br(),
radioButtons("ontology", label="Choose an ontology :", choices=c("Biological Process"="BP", "Molecular Function"="MF", "Cellular Component" = "CC")), br(),
br(), actionButton("gogo", icon = icon("far fa-arrow-alt-circle-right"), label="Do Gene Ontology")
)
)
......@@ -181,10 +182,11 @@ body <- dashboardBody(
)
),
# Genes Item --------
tabItem(tabName="genes_item", align="center",
tabItem(tabName="genes_item", align="left",
conditionalPanel(condition= "output.fileUploaded",
br(), br(),
plotOutput("goplot", height = 850)
fluidRow(column(align="center", width = 6, plotOutput("goplot", height = 600),uiOutput(align="left","dlgenegraph")),
column(align="center", width = 6, dataTableOutput("dtgenes"),uiOutput(align="left","dlgenedt")))
)
),
......@@ -281,18 +283,18 @@ server <- function(input, output, session) {
})
## Graphs & Tables Generations --------
## Graphs & one table Generations --------
markersData <- reactive ({
wrfile()@misc$markers[[input$fsel]]
})
factorsplotData <- reactive ({
factorsplotData <- reactive ({ # Left Graph Visu page
scalex <- scale_x_continuous(limits = c(min(wrfile()@reductions[[input$graph]]@cell.embeddings[,1]), max(wrfile()@reductions[[input$graph]]@cell.embeddings[,1])))
scaley <- scale_y_continuous(limits = c(min(wrfile()@reductions[[input$graph]]@cell.embeddings[,1]), max(wrfile()@reductions[[input$graph]]@cell.embeddings[,1])))
withProgress(DimPlot(object = wrfile(), label=FALSE, pt.size = input$ptsize, reduction=input$graph, group.by = input$fsel), message = "Plot Generation", value=1) + NoLegend() + theme_bw()+ theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank()) + NoAxes() + ggtitle(paste(file_path_sans_ext(filedata$name),"-", input$fsel)) + scalex + scaley #+ aes(text=Cells(wrfile()))
})
numericsplotData <- reactive ({
numericsplotData <- reactive ({ # Right Graph Visu page
scalex <- scale_x_continuous(limits = c(min(wrfile()@reductions[[input$graph]]@cell.embeddings[,1]), max(wrfile()@reductions[[input$graph]]@cell.embeddings[,1])))
scaley <- scale_y_continuous(limits = c(min(wrfile()@reductions[[input$graph]]@cell.embeddings[,1]), max(wrfile()@reductions[[input$graph]]@cell.embeddings[,1])))
if (input$featuresel =="d") {
......@@ -306,11 +308,11 @@ server <- function(input, output, session) {
})
miniplot_compareData <- reactive ({
miniplot_compareData <- reactive ({ # Mini Graph 1 Compare page
withProgress(DimPlot(object = wrfile(), label=TRUE, pt.size = input$ptsize_compare, legend="none", reduction=input$graph_compare, group.by = input$fsel2), message = "Plot Generation", value=1) + theme_bw() + theme(panel.grid.major=element_blank(),plot.title = element_text(size=12),panel.grid.minor=element_blank(),plot.background=element_blank()) + NoAxes() + NoLegend()
})
miniplot_compare2Data <- reactive ({
miniplot_compare2Data <- reactive ({ # Mini Graph 2 Compare page
if (input$choice_compare == "features_compare") {
if (input$featuresel2 =="d2") {
withProgress(FeaturePlot(object = wrfile(), cols=c("lightgrey",plasma(200)), pt.size = input$ptsize_compare, features = input$nsel2, reduction = input$graph_compare), message = "Plot Generation", value=1) + theme_bw()+ NoLegend() + NoAxes() + theme(panel.grid.major=element_blank(),plot.title = element_text(size=12),panel.grid.minor=element_blank(),plot.background=element_blank())
......@@ -320,7 +322,7 @@ server <- function(input, output, session) {
}
})
plot1_compareData <- reactive ({
plot1_compareData <- reactive ({ # Left Graph Compare page
scalex <- scale_x_continuous(limits = c(min(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,1]), max(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,1])))
scaley <- scale_y_continuous(limits = c(min(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,1]), max(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,1])))
......@@ -342,7 +344,7 @@ server <- function(input, output, session) {
}
})
plot2_compareData <- reactive ({
plot2_compareData <- reactive ({ # Right Graph Compare page
# df.colors <- data.frame(class=unique(eval(parse(text=paste0("wrfile()@meta.data$",input$fsel2)))), color="viridis"(length(unique(eval(parse(text=paste0("wrfile()@meta.data$",input$fsel2)))))))
scalex <- scale_x_continuous(limits = c(min(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,1]), max(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,1])))
scaley <- scale_y_continuous(limits = c(min(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,1]), max(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,1])))
......@@ -366,7 +368,7 @@ server <- function(input, output, session) {
}
})
cells_to_plot1 <- reactiveValues()
cells_to_plot1 <- reactiveValues() # Data for Compare graphs
cells_to_plot2 <- reactiveValues()
## Graphs & Tables Outputs --------
......@@ -383,7 +385,7 @@ server <- function(input, output, session) {
output$markers_table <- renderDataTable ({
req(wrfile())
req(markersData() != "")
datatable(markersData()[c(6,3,4,2,1,5)], filter="top", caption = paste("Table 1 : All significant markers for the factor :", input$fsel ,"| Test used : MAST" )) %>% formatRound(columns=c(2,3,4), digits=3) %>% formatSignif(columns=c(6,5), digits=3)
datatable(markersData()[c(6,3,4,2,1,5)], filter="top", caption = paste("Table : All significant markers for the factor :", input$fsel ,"| Test used : MAST" )) %>% formatRound(columns=c(2,3,4), digits=3) %>% formatSignif(columns=c(6,5), digits=3)
})
output$miniplot_compare <- renderPlot({
......@@ -434,30 +436,50 @@ server <- function(input, output, session) {
})
## Genes Page --------
observeEvent(input$gogo, {
if (is.null(input$group_genepage)) {
showModal(modalDialog("You must choose at least one group to do the Gene Ontology.", title=strong("Warning !"), easyClose=TRUE, footer = NULL ))
}
})
goplotData <- reactive ({
req(input$gogo)
genes <- wrfile()@misc$markers[[input$fsel4]]$cluster == input$group_genepage
genes <- wrfile()@misc$markers[[input$fsel4]]$gene[genes]
genes <- bitr(genes, fromType = "SYMBOL",
toType = "ENTREZID",
OrgDb = org.Hs.eg.db,
drop = TRUE)
ego <- withProgress(enrichGO(gene = genes$ENTREZID, OrgDb = "org.Hs.eg.db", keyType= "ENTREZID", ont = "BP", readable = TRUE), message = "Loading Gene Ontology...", value=1)
if (input$gographtype == "dplot") {
dotplot(ego)
} else if (input$gographtype == "bplot") {
barplot(ego, drop=TRUE)
req(!is.null(input$group_genepage))
if (is.null(wrfile()@misc$markers[[input$fsel4]])) {
showModal(modalDialog("The markers may have not been calculated for this factor yet.", title=strong("Warning !"), easyClose=TRUE, footer = NULL ))
} else {
emapplot(ego)
genes <- wrfile()@misc$markers[[input$fsel4]]$cluster == input$group_genepage
genes <- wrfile()@misc$markers[[input$fsel4]]$gene[genes]
genes <- bitr(genes, fromType = "SYMBOL",toType = "ENTREZID",OrgDb = org.Hs.eg.db,drop = TRUE)
ego <- withProgress(enrichGO(gene = genes$ENTREZID, OrgDb = "org.Hs.eg.db", keyType= "ENTREZID", ont = input$ontology, readable = TRUE), message = "Loading Gene Ontology...", value=1)
if (input$gographtype == "dplot") {
dotplot(ego) + ggtitle(paste(file_path_sans_ext(filedata$name),"-",input$ontology,"-",input$fsel4)) + theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank())
} else if (input$gographtype == "bplot") {
barplot(ego, drop=TRUE) + ggtitle(paste(file_path_sans_ext(filedata$name),"-",input$ontology,"-",input$fsel4)) + theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank())
} else {
emapplot(ego) + ggtitle(paste(file_path_sans_ext(filedata$name),"-",input$ontology,"-",input$fsel4)) + theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank())
}
}
})
output$goplot <-renderPlot ({
req(wrfile())
goplotData()
})
dtgoData <- reactive ({
filegene <- wrfile()
Idents(filegene) <- as.factor(paste0(eval(parse(text=paste0("filegene@meta.data$",input$fsel4)))))
dtgenes <- data.table(filegene@misc$markers[[input$fsel4]]$gene[which(eval(parse(text=paste0("filegene@misc$markers$",input$fsel4,"$cluster"))) %in% input$group_genepage)])
})
output$dtgenes <-renderDataTable ({
req(wrfile())
req(!is.null(input$group_genepage))
datatable(dtgoData(), filter="top", caption = "Table : Markers for the selected group(s)")
})
## Information Genes text ----
# output$genes_analyse <- renderText({
# req(wrfile())
......@@ -520,6 +542,41 @@ server <- function(input, output, session) {
}
)
output$dlgenegraph <- renderUI ({ # Genes Page
req(goplotData() !="")
downloadButton("dl_gene", label="")
})
output$dl_gene <- downloadHandler(
filename = function() {
if (input$gographtype == "dplot") {
paste0(file_path_sans_ext(filedata$name),"_",input$ontology,"_dotplot_",input$fsel4,".png")
} else if (input$gographtype == "bplot") {
paste0(file_path_sans_ext(filedata$name),"_",input$ontology,"_barplot_",input$fsel4,".png")
} else {
paste0(file_path_sans_ext(filedata$name),"_",input$ontology,"_emapplot_",input$fsel4,".png")
}
},
content = function(file) {
png(file, width = 800, height = 600)
print(goplotData())
dev.off()
}
)
output$dlgenedt <- renderUI ({ # Genes Page
req(dtgoData() !="")
downloadButton("dl_godt", label="")
})
output$dl_godt <- downloadHandler(
filename = function() {
paste0(file_path_sans_ext(filedata$name),"_datatable_",input$fsel4,".csv")
},
content = function(file) {
write.csv(dtgoData(), file)
}
)
output$dl_compare1 <- downloadHandler( # Compare Page
filename = function() {
if (input$choice_compare == "f_compare") {
......@@ -709,7 +766,7 @@ server <- function(input, output, session) {
req(wrfile())
choice <- unique(eval(parse(text=paste0("wrfile()@meta.data$",input$fsel4))))
req(!is.na(choice))
selectInput("group_genepage", "Choose a group :", multiple = FALSE, choices = choice[order(choice)])
selectInput("group_genepage", "Choose a group :", multiple = TRUE, choices = choice[order(choice)])
})
## Help messages --------
......@@ -802,7 +859,7 @@ The HeatMap is exportable in .svg.", title=strong("HeatMap page Help"), easyClos
# In the 2 cases :
output$markers_compare <- renderDataTable ({
req(wrfile())
withProgress(datatable(df[c(1,4,5,3,2,6)], rownames=FALSE, filter="top", caption = "Table 2 : Significant markers of your query | Test used : MAST" ), message = "Render DataTable", value=1) %>% formatRound(columns=c(1,2,3,4), digits=3) %>% formatSignif(columns=c(6,5), digits=3)
withProgress(datatable(df[c(1,4,5,3,2,6)], rownames=FALSE, filter="top", caption = "Table : Significant markers of your query | Test used : MAST" ), message = "Render DataTable", value=1) %>% formatRound(columns=c(1,2,3,4), digits=3) %>% formatSignif(columns=c(6,5), digits=3)
})
output$dlmarkbutton_compare <- renderUI ({
downloadButton("dlmarkers_compare", label="")
......
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