Commit 62861858 authored by Bagueneau Mathias's avatar Bagueneau Mathias
Browse files

- Suppression de l'actualisation intempestive des pages Heatmap, Genes et Compare

parent bda07c44
......@@ -841,69 +841,67 @@ server <- function(input, output, session) {
observeEvent (input$gographs, {
cells_to_plot1 <- reactive({ # Data for Compare Left Graph
# Data for Compare Left Graph
if (input$add %% 2 != 0) {
subset1 <- SubsetData(object = wrfile(), cells=rownames(wrfile()@meta.data)[which(eval(parse(text=paste0("wrfile()@meta.data$",input$fsel2))) %in% input$library1_compare)] )
selectedCells <- SubsetData(object = subset1, cells=rownames(subset1@meta.data)[which(eval(parse(text=paste0("subset1@meta.data$",input$add_factor))) %in% input$add_group1)])
cells_to_plot1 <- SubsetData(object = subset1, cells=rownames(subset1@meta.data)[which(eval(parse(text=paste0("subset1@meta.data$",input$add_factor))) %in% input$add_group1)])
} else {
selectedCells <- SubsetData(object = wrfile(), cells=rownames(wrfile()@meta.data)[which(eval(parse(text=paste0("wrfile()@meta.data$",input$fsel2))) %in% input$library1_compare)] )
cells_to_plot1 <- SubsetData(object = wrfile(), cells=rownames(wrfile()@meta.data)[which(eval(parse(text=paste0("wrfile()@meta.data$",input$fsel2))) %in% input$library1_compare)] )
}
return(selectedCells)
})
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[,2]), max(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,2])))
# Left Graph Compare page
scalex1 <- scale_x_continuous(limits = c(min(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,1]), max(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,1])))
scaley1 <- scale_y_continuous(limits = c(min(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,2]), max(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,2])))
if (input$choice_compare == "f_compare") {
withProgress(DimPlot(object = wrfile(), cells=rownames(cells_to_plot1()@meta.data), label=FALSE, pt.size = input$ptsize_compare, reduction=input$graph_compare, group.by = input$fsel2, cols= c(as.character(eval(parse(text=paste0("alldf()$",input$fsel2,"$color")))[which(eval(parse(text=paste0("alldf()$",input$fsel2,"$group"))) %in% input$library1_compare)]), "#000000")), message = "Plot Generation", value=1) + NoLegend() + theme_bw() + NoAxes() + ggtitle(paste(file_path_sans_ext(filedata$name),"-",input$fsel2)) + scalex + scaley + theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank()) + theme(aspect.ratio = 1)
plot1_compareData <- withProgress(DimPlot(object = wrfile(), cells=rownames(cells_to_plot1@meta.data), label=FALSE, pt.size = input$ptsize_compare, reduction=input$graph_compare, group.by = input$fsel2, cols= c(as.character(eval(parse(text=paste0("alldf()$",input$fsel2,"$color")))[which(eval(parse(text=paste0("alldf()$",input$fsel2,"$group"))) %in% input$library1_compare)]), "#000000")), message = "Plot Generation", value=1) + NoLegend() + theme_bw() + NoAxes() + ggtitle(paste(file_path_sans_ext(filedata$name),"-",input$fsel2)) + scalex1 + scaley1 + theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank()) + theme(aspect.ratio = 1)
} else {
palette.full <- c("lightgrey", plasma(200))
if (input$featuresel2 =="d2") {
data.max.global <- max(FetchData(wrfile(), input$nsel2))
data.max.local <- max(FetchData(cells_to_plot1(), input$nsel2))
data.max.local <- max(FetchData(cells_to_plot1, input$nsel2))
palette.local <- palette.full[1:ceiling(length(palette.full) * data.max.local / data.max.global)]
withProgress(FeaturePlot(object = wrfile(), cells=rownames(cells_to_plot1()@meta.data), cols=palette.local, pt.size = input$ptsize_compare, features = input$nsel2, reduction = input$graph_compare), message = "Plot Generation", value=1) + theme_bw()+ NoAxes() + ggtitle(paste(file_path_sans_ext(filedata$name),"-", input$nsel2))+ theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank()) + scalex + scaley + theme(aspect.ratio = 1)
plot1_compareData <- withProgress(FeaturePlot(object = wrfile(), cells=rownames(cells_to_plot1@meta.data), cols=palette.local, pt.size = input$ptsize_compare, features = input$nsel2, reduction = input$graph_compare), message = "Plot Generation", value=1) + theme_bw()+ NoAxes() + ggtitle(paste(file_path_sans_ext(filedata$name),"-", input$nsel2))+ theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank()) + scalex1 + scaley1 + theme(aspect.ratio = 1)
} else if (input$featuresel2 =="g2") {
gene.max.global <- max(FetchData(wrfile(), input$genes2))
gene.max.local <- max(FetchData(cells_to_plot1(), input$genes2))
gene.max.local <- max(FetchData(cells_to_plot1, input$genes2))
palette.local <- palette.full[1:ceiling(length(palette.full) * gene.max.local / gene.max.global)]
withProgress(FeaturePlot(object = wrfile(), cols=palette.local, cells=rownames(cells_to_plot1()@meta.data), pt.size = input$ptsize_compare, features = input$genes2, reduction = input$graph_compare), message = "Plot Generation", value=1) + theme_bw() + NoAxes() + ggtitle(paste(file_path_sans_ext(filedata$name),"-", input$genes2))+ theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank()) +scalex + scaley+ theme(aspect.ratio = 1)
plot1_compareData <- withProgress(FeaturePlot(object = wrfile(), cols=palette.local, cells=rownames(cells_to_plot1@meta.data), pt.size = input$ptsize_compare, features = input$genes2, reduction = input$graph_compare), message = "Plot Generation", value=1) + theme_bw() + NoAxes() + ggtitle(paste(file_path_sans_ext(filedata$name),"-", input$genes2))+ theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank()) +scalex1 + scaley1 + theme(aspect.ratio = 1)
}
}
})
cells_to_plot2 <- reactive({ # Data for Compare Right Graph
# Data for Compare Right Graph
if (input$add %% 2 != 0) {
subset2 <- SubsetData(object = wrfile(), cells=rownames(wrfile()@meta.data)[which(eval(parse(text=paste0("wrfile()@meta.data$",input$fsel2))) %in% input$library2_compare)] )
selectedCells2 <- SubsetData(object = subset2, cells=rownames(subset2@meta.data)[which(eval(parse(text=paste0("subset2@meta.data$",input$add_factor))) %in% input$add_group2)])
cells_to_plot2 <- SubsetData(object = subset2, cells=rownames(subset2@meta.data)[which(eval(parse(text=paste0("subset2@meta.data$",input$add_factor))) %in% input$add_group2)])
} else {
selectedCells2 <- SubsetData(object = wrfile(), cells=rownames(wrfile()@meta.data)[which(eval(parse(text=paste0("wrfile()@meta.data$",input$fsel2))) %in% input$library2_compare)] )
cells_to_plot2 <- SubsetData(object = wrfile(), cells=rownames(wrfile()@meta.data)[which(eval(parse(text=paste0("wrfile()@meta.data$",input$fsel2))) %in% input$library2_compare)] )
}
return(selectedCells2)
})
plot2_compareData <- reactive ({ # Right 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[,2]), max(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,2])))
# Right Graph Compare page
scalex2 <- scale_x_continuous(limits = c(min(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,1]), max(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,1])))
scaley2 <- scale_y_continuous(limits = c(min(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,2]), max(wrfile()@reductions[[input$graph_compare]]@cell.embeddings[,2])))
if (input$choice_compare == "f_compare") {
withProgress(DimPlot(object = wrfile(), cells=rownames(cells_to_plot2()@meta.data), pt.size = input$ptsize_compare, reduction=input$graph_compare, group.by = input$fsel2, cols= c(as.character(eval(parse(text=paste0("alldf()$",input$fsel2,"$color")))[which(eval(parse(text=paste0("alldf()$",input$fsel2,"$group"))) %in% input$library2_compare)]), "#000000")), message = "Plot Generation", value=1) + NoLegend() + theme_bw() + NoAxes() + ggtitle(paste(file_path_sans_ext(filedata$name),"-", input$fsel2))+ theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank()) + scalex + scaley+ theme(aspect.ratio = 1)
plot2_compareData <- withProgress(DimPlot(object = wrfile(), cells=rownames(cells_to_plot2@meta.data), pt.size = input$ptsize_compare, reduction=input$graph_compare, group.by = input$fsel2, cols= c(as.character(eval(parse(text=paste0("alldf()$",input$fsel2,"$color")))[which(eval(parse(text=paste0("alldf()$",input$fsel2,"$group"))) %in% input$library2_compare)]), "#000000")), message = "Plot Generation", value=1) + NoLegend() + theme_bw() + NoAxes() + ggtitle(paste(file_path_sans_ext(filedata$name),"-", input$fsel2))+ theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank()) + scalex2 + scaley2 + theme(aspect.ratio = 1)
} else {
palette.full <- c("lightgrey", plasma(200))
if (input$featuresel2 =="d2") {
data.max.global <- max(FetchData(wrfile(), input$nsel2))
data.max.local <- max(FetchData(cells_to_plot2(), input$nsel2))
data.max.local <- max(FetchData(cells_to_plot2, input$nsel2))
palette.local <- palette.full[1:ceiling(length(palette.full) * data.max.local / data.max.global)]
withProgress(FeaturePlot(object = wrfile(), cells=rownames(cells_to_plot2()@meta.data), cols=palette.local, pt.size = input$ptsize_compare, features = input$nsel2, reduction = input$graph_compare), message = "Plot Generation", value=1) + theme_bw() + NoAxes() + ggtitle(paste(file_path_sans_ext(filedata$name),"-", input$nsel2))+ theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank()) + scalex + scaley + theme(aspect.ratio = 1)
plot2_compareData <- withProgress(FeaturePlot(object = wrfile(), cells=rownames(cells_to_plot2@meta.data), cols=palette.local, pt.size = input$ptsize_compare, features = input$nsel2, reduction = input$graph_compare), message = "Plot Generation", value=1) + theme_bw() + NoAxes() + ggtitle(paste(file_path_sans_ext(filedata$name),"-", input$nsel2))+ theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank()) + scalex2 + scaley2 + theme(aspect.ratio = 1)
} else if (input$featuresel2 =="g2") {
gene.max.global <- max(FetchData(wrfile(), input$genes2))
gene.max.local <- max(FetchData(cells_to_plot2(), input$genes2))
gene.max.local <- max(FetchData(cells_to_plot2, input$genes2))
palette.local <- palette.full[1:ceiling(length(palette.full) * gene.max.local / gene.max.global)]
withProgress(FeaturePlot(object = wrfile(), cols=palette.local, cells=rownames(cells_to_plot2()@meta.data), pt.size = input$ptsize_compare, features = input$genes2, reduction = input$graph_compare), message = "Plot Generation", value=1) + theme_bw() + NoAxes() + ggtitle(paste(file_path_sans_ext(filedata$name),"-", input$genes2))+ theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank()) + scalex + scaley + theme(aspect.ratio = 1)
plot2_compareData <- withProgress(FeaturePlot(object = wrfile(), cols=palette.local, cells=rownames(cells_to_plot2@meta.data), pt.size = input$ptsize_compare, features = input$genes2, reduction = input$graph_compare), message = "Plot Generation", value=1) + theme_bw() + NoAxes() + ggtitle(paste(file_path_sans_ext(filedata$name),"-", input$genes2))+ theme(panel.grid.major=element_blank(),plot.title = element_text(size=18),panel.grid.minor=element_blank(),plot.background=element_blank()) + scalex2 + scaley2 + theme(aspect.ratio = 1)
}
}
})
......@@ -911,18 +909,18 @@ server <- function(input, output, session) {
output$plot1_compare <- renderPlotly ({ # Output Graph 1
req(wrfile())
if (input$choice_compare == "features_compare") {
ggplotly(plot1_compareData(),tooltip ="none") %>% config(displaylogo = F, modeBarButtonsToRemove = c('resetScale2d', 'toggleSpikelines', 'toImage', 'hoverCompareCartesian','hoverClosestCartesian'))
ggplotly(plot1_compareData,tooltip ="none") %>% config(displaylogo = F, modeBarButtonsToRemove = c('resetScale2d', 'toggleSpikelines', 'toImage', 'hoverCompareCartesian','hoverClosestCartesian'))
} else {
ggplotly(plot1_compareData(),tooltip = c("colour","x","y")) %>% config(displaylogo = F, modeBarButtonsToRemove = c('resetScale2d', 'toggleSpikelines', 'toImage', 'hoverCompareCartesian','hoverClosestCartesian'))
ggplotly(plot1_compareData,tooltip = c("colour","x","y")) %>% config(displaylogo = F, modeBarButtonsToRemove = c('resetScale2d', 'toggleSpikelines', 'toImage', 'hoverCompareCartesian','hoverClosestCartesian'))
}
})
output$plot2_compare <- renderPlotly ({ # Output Graph 1
output$plot2_compare <- renderPlotly ({ # Output Graph 2
req(wrfile())
if (input$choice_compare == "features_compare") {
ggplotly(plot2_compareData(),tooltip ="none") %>% config(displaylogo = F, modeBarButtonsToRemove = c('resetScale2d', 'toggleSpikelines', 'toImage', 'hoverCompareCartesian','hoverClosestCartesian'))
ggplotly(plot2_compareData,tooltip ="none") %>% config(displaylogo = F, modeBarButtonsToRemove = c('resetScale2d', 'toggleSpikelines', 'toImage', 'hoverCompareCartesian','hoverClosestCartesian'))
} else {
ggplotly(plot2_compareData(),tooltip = c("colour","x","y")) %>% config(displaylogo = F, modeBarButtonsToRemove = c('resetScale2d', 'toggleSpikelines', 'toImage', 'hoverCompareCartesian','hoverClosestCartesian'))
ggplotly(plot2_compareData,tooltip = c("colour","x","y")) %>% config(displaylogo = F, modeBarButtonsToRemove = c('resetScale2d', 'toggleSpikelines', 'toImage', 'hoverCompareCartesian','hoverClosestCartesian'))
}
})
......@@ -946,7 +944,7 @@ server <- function(input, output, session) {
},
content = function(file) {
svg(file)
print(plot1_compareData())
print(plot1_compareData)
dev.off()
}
)
......@@ -965,11 +963,26 @@ server <- function(input, output, session) {
},
content = function(file) {
svg(file)
print(plot2_compareData())
print(plot2_compareData)
dev.off()
}
)
# Barcodes data
cbar1Data <- reactive ({
barcodes1 <- data.table(Cells(cells_to_plot1))
names(barcodes1)[[1]] <- "Barcodes"
return (barcodes1)
})
cbar2Data <- reactive ({
barcodes2 <- data.table(Cells(cells_to_plot2))
names(barcodes2)[1] <- "Barcodes"
return (barcodes2)
})
output$dl_comparebarcodes1 <- downloadHandler( # Download Barcodes 1
filename = function() {
paste0(file_path_sans_ext(filedata$name),"_selectedbarcodes.csv")
......@@ -998,18 +1011,7 @@ server <- function(input, output, session) {
})
## Compare Page - Barcodes data --------
cbar1Data <- reactive ({
barcodes1 <- data.table(Cells(cells_to_plot1()))
names(barcodes1)[[1]] <- "Barcodes"
return (barcodes1)
})
cbar2Data <- reactive ({
barcodes2 <- data.table(Cells(cells_to_plot2()))
names(barcodes2)[1] <- "Barcodes"
return (barcodes2)
})
## Compare Page - FindMarkers --------
output$markbutton <- renderUI ({
......
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