Commit ad2f3310 authored by Stevenn Volant's avatar Stevenn Volant
Browse files

correction bug diag plot

parent c4e30c3b
This diff is collapsed.
...@@ -3,6 +3,7 @@ if (!require(rNVD3)) { ...@@ -3,6 +3,7 @@ if (!require(rNVD3)) {
install.packages('rNVD3') install.packages('rNVD3')
library(rNVD3) library(rNVD3)
} }
library(plotly)
if (!require(psych)) { if (!require(psych)) {
install.packages('psych') install.packages('psych')
library(psych) library(psych)
...@@ -155,6 +156,7 @@ shinyServer(function(input, output,session) { ...@@ -155,6 +156,7 @@ shinyServer(function(input, output,session) {
counts = NULL counts = NULL
CheckTarget = FALSE CheckTarget = FALSE
normFactors = NULL normFactors = NULL
CT_noNorm = NULL
data = dataInput()$data data = dataInput()$data
target = dataInputTarget() target = dataInputTarget()
...@@ -167,8 +169,9 @@ shinyServer(function(input, output,session) { ...@@ -167,8 +169,9 @@ shinyServer(function(input, output,session) {
counts = tmp$counts counts = tmp$counts
CheckTarget = tmp$CheckTarget CheckTarget = tmp$CheckTarget
normFactors = tmp$normFactors normFactors = tmp$normFactors
CT_noNorm = tmp$CT_noNorm
} }
return(list(counts=counts,CheckTarget=CheckTarget,normFactors=normFactors)) return(list(counts=counts,CheckTarget=CheckTarget,normFactors=normFactors,CT_noNorm=CT_noNorm))
}) })
...@@ -436,14 +439,14 @@ shinyServer(function(input, output,session) { ...@@ -436,14 +439,14 @@ shinyServer(function(input, output,session) {
## Export in .csv ## Export in .csv
output$ExportCounts <- downloadHandler( output$ExportCounts <- downloadHandler(
filename = function() { 'NomrCounts.csv' }, filename = function() { 'NormCounts.csv' },
content = function(file){write.csv(dataMergeCounts()$counts, file, sep='\t')} content = function(file){write.csv(dataMergeCounts()$counts, file)}
) )
## Export in .csv ## Export in .csv
output$ExportRelative <- downloadHandler( output$ExportRelative <- downloadHandler(
filename = function() { 'RelativeAb.csv' }, filename = function() { 'RelativeAb.csv' },
content = function(file){write.csv(dataMergeCounts()$counts/colSums(dataMergeCounts()$counts), file,, sep='\t')} content = function(file){write.csv(dataMergeCounts()$counts/colSums(dataMergeCounts()$counts), file)}
) )
...@@ -805,11 +808,12 @@ shinyServer(function(input, output,session) { ...@@ -805,11 +808,12 @@ shinyServer(function(input, output,session) {
ResDiffAnal <-eventReactive(input$RunDESeq,{ ResDiffAnal <-eventReactive(input$RunDESeq,{
counts = dataMergeCounts()$counts counts = dataMergeCounts()$counts
CT_noNorm = dataMergeCounts()$CT_noNorm
normFactors = dataMergeCounts()$normFactors normFactors = dataMergeCounts()$normFactors
target = dataInputTarget() target = dataInputTarget()
design = GetDesign(input) design = GetDesign(input)
Get_dds_object(input,counts,target,design,normFactors) Get_dds_object(input,counts,target,design,normFactors,CT_noNorm)
}) })
...@@ -983,6 +987,33 @@ output$exportPDFVisu <- downloadHandler( ...@@ -983,6 +987,33 @@ output$exportPDFVisu <- downloadHandler(
} }
) )
#### Export Visu
output$exportVisu <- downloadHandler(
filename <- function() { paste(input$PlotVisuSelect,paste('meta16S',input$Exp_format_Visu,sep="."),sep="_") },
content <- function(file) {
BaseContrast = read.table(namesfile,header=TRUE)
taxo = input$TaxoSelect
if(input$Exp_format_Visu=="png") png(file, width = input$widthVisuExport, height = input$heightVisuExport)
if(input$Exp_format_Visu=="pdf") pdf(file, width = input$widthVisuExport/96, height = input$heightVisuExport/96)
if(input$Exp_format_Visu=="eps") postscript(file, width = input$widthVisuExport/96, height = input$heightVisuExport/96)
if(input$Exp_format_Visu=="svg") svg(file, width = input$widthVisuExport/96, height = input$heightVisuExport/96)
if(input$PlotVisuSelect=="Barplot") print(Plot_Visu_Barplot(input,ResDiffAnal())$gg)
if(input$PlotVisuSelect=="Heatmap"){
if(input$HeatMapType=="Counts") print(Plot_Visu_Heatmap(input,ResDiffAnal(),export=TRUE))
if(input$HeatMapType=="Log2FC") print(Plot_Visu_Heatmap_FC(input,BaseContrast,ResDiffAnal(),export=TRUE))
}
if(input$PlotVisuSelect=="Boxplot") print(Plot_Visu_Boxplot(input,ResDiffAnal()))
if(input$PlotVisuSelect=="Diversity") print(Plot_Visu_Diversity(input,ResDiffAnal(),type="point"))
if(input$PlotVisuSelect=="Rarefaction") print( Plot_Visu_Rarefaction(input,ResDiffAnal(),ranges$x,ranges$y,ylab=taxo))
dev.off()
}
)
##################################################### #####################################################
## ##
## DIFF TABLES ## DIFF TABLES
...@@ -1139,11 +1170,15 @@ output$RunButton <- renderUI({ ...@@ -1139,11 +1170,15 @@ output$RunButton <- renderUI({
##################################################### #####################################################
output$PlotVisu <- renderChart({ output$PlotVisuBar <- renderChart({
resDiff = ResDiffAnal() resDiff = ResDiffAnal()
if(!is.null(resDiff$dds)) Plot_Visu_Barplot(input,resDiff) if(!is.null(resDiff$dds)) Plot_Visu_Barplot(input,resDiff)$plotd3
}) },env=new.env())
# output$PlotVisu <- renderPlotly({
# resDiff = ResDiffAnal()
# if(!is.null(resDiff$dds)) Plot_Visu_Barplot(input,resDiff)
# })
output$heatmap <- renderD3heatmap({ output$heatmap <- renderD3heatmap({
resDiff = ResDiffAnal() resDiff = ResDiffAnal()
...@@ -1155,7 +1190,7 @@ output$RunButton <- renderUI({ ...@@ -1155,7 +1190,7 @@ output$RunButton <- renderUI({
if(input$HeatMapType=="Log2FC") resplot = Plot_Visu_Heatmap_FC(input,BaseContrast,resDiff) if(input$HeatMapType=="Log2FC") resplot = Plot_Visu_Heatmap_FC(input,BaseContrast,resDiff)
} }
return(resplot) return(resplot)
}) },env=new.env())
...@@ -1169,6 +1204,27 @@ output$RunButton <- renderUI({ ...@@ -1169,6 +1204,27 @@ output$RunButton <- renderUI({
resDiff = ResDiffAnal() resDiff = ResDiffAnal()
if(!is.null(resDiff$dds)) Plot_Visu_Diversity(input,resDiff,type="point") if(!is.null(resDiff$dds)) Plot_Visu_Diversity(input,resDiff,type="point")
}) })
ranges <- reactiveValues(x = NULL, y = NULL)
output$RarefactionPlot <- renderPlot({
resDiff = ResDiffAnal()
taxo = input$TaxoSelect
if(!is.null(resDiff)) Plot_Visu_Rarefaction(input,resDiff,ranges$x,ranges$y,ylab=taxo)
}, height = reactive(input$heightVisu))
observeEvent(input$RarefactionPlot_dblclick, {
brush <- input$RarefactionPlot_brush
if (!is.null(brush)) {
ranges$x <- c(brush$xmin, brush$xmax)
ranges$y <- c(brush$ymin, brush$ymax)
} else {
ranges$x <- NULL
ranges$y <- NULL
}
})
output$SelectVarBoxDiv <- renderUI({ output$SelectVarBoxDiv <- renderUI({
...@@ -1185,7 +1241,7 @@ output$RunButton <- renderUI({ ...@@ -1185,7 +1241,7 @@ output$RunButton <- renderUI({
output$plotVisu <- renderUI({ output$plotVisu <- renderUI({
res=NULL res=NULL
if(input$PlotVisuSelect=="Barplot") res = showOutput("PlotVisu") if(input$PlotVisuSelect=="Barplot") res = showOutput("PlotVisuBar")
if(input$PlotVisuSelect=="Heatmap") res = d3heatmapOutput("heatmap", height = input$heightVisu+10) if(input$PlotVisuSelect=="Heatmap") res = d3heatmapOutput("heatmap", height = input$heightVisu+10)
if(input$PlotVisuSelect=="Boxplot") res = plotOutput("Boxplot", height = input$heightVisu+10) if(input$PlotVisuSelect=="Boxplot") res = plotOutput("Boxplot", height = input$heightVisu+10)
if(input$PlotVisuSelect=="Diversity") res = plotOutput("DiversityPlot", height = input$heightVisu+10) if(input$PlotVisuSelect=="Diversity") res = plotOutput("DiversityPlot", height = input$heightVisu+10)
...@@ -1200,25 +1256,7 @@ output$RunButton <- renderUI({ ...@@ -1200,25 +1256,7 @@ output$RunButton <- renderUI({
# if(!is.null(resDiff$dds)) Plot_Visu_Diversity(input,resDiff,type="box") # if(!is.null(resDiff$dds)) Plot_Visu_Diversity(input,resDiff,type="box")
# }) # })
ranges <- reactiveValues(x = NULL, y = NULL)
output$RarefactionPlot <- renderPlot({
resDiff = ResDiffAnal()
taxo = input$TaxoSelect
if(!is.null(resDiff)) Plot_Visu_Rarefaction(input,resDiff,ranges$x,ranges$y,ylab=taxo)
}, height = reactive(input$heightVisu))
observeEvent(input$RarefactionPlot_dblclick, {
brush <- input$RarefactionPlot_brush
if (!is.null(brush)) {
ranges$x <- c(brush$xmin, brush$xmax)
ranges$y <- c(brush$ymin, brush$ymax)
} else {
ranges$x <- NULL
ranges$y <- NULL
}
})
output$TaxoToPlotVisu <- renderUI({ output$TaxoToPlotVisu <- renderUI({
......
library(shinydashboard) library(shinydashboard)
if (!require(rNVD3)) { # if (!require(rNVD3)) {
install.packages('rNVD3') # install.packages('rNVD3')
library(rNVD3) # library(rNVD3)
} # }
if (!require(psych)) { if (!require(psych)) {
install.packages('psych') install.packages('psych')
library(psych) library(psych)
...@@ -376,10 +376,13 @@ body <- dashboardBody( ...@@ -376,10 +376,13 @@ body <- dashboardBody(
box(title = "Appearance", width = NULL, status = "primary", solidHeader = TRUE,collapsible = TRUE,collapsed= TRUE, box(title = "Appearance", width = NULL, status = "primary", solidHeader = TRUE,collapsible = TRUE,collapsed= TRUE,
sliderInput("heightVisu", h6(strong("Height")),min=100,max=4000,value = 800), sliderInput("heightVisu", h6(strong("Height")),min=100,max=4000,value = 800),
################## ##################
## BOXPLOT ## BOXPLOT
################## ##################
conditionalPanel(condition="input.PlotVisuSelect=='Boxplot'", conditionalPanel(condition="input.PlotVisuSelect=='Boxplot'",
radioButtons("ScaleBoxplot","Scales",c("Fixed"="fixed","Free"="free"),inline=TRUE),
checkboxInput("CheckAddPointsBox","Add points",value=TRUE) checkboxInput("CheckAddPointsBox","Add points",value=TRUE)
), ),
...@@ -419,7 +422,24 @@ body <- dashboardBody( ...@@ -419,7 +422,24 @@ body <- dashboardBody(
radioButtons(inputId = "SensPlotVisu",label = h6(strong("Orientation")),choices = c("Vertical" = "Vertical", "Horizontal" = "Horizontal"),selected = "Vertical",inline = TRUE) radioButtons(inputId = "SensPlotVisu",label = h6(strong("Orientation")),choices = c("Vertical" = "Vertical", "Horizontal" = "Horizontal"),selected = "Vertical",inline = TRUE)
) )
),
box(title = "Export", width = NULL, status = "primary", solidHeader = TRUE,collapsible = TRUE,collapsed= TRUE,
##################
## BARPLOT
##################
conditionalPanel(condition="input.PlotVisuSelect=='Barplot'",
radioButtons("positionBarPlot","Position",c("Grouped"="fill","Stacked"="dodge"),inline=TRUE)
),
selectInput("Exp_format_Visu",h5(strong("Export format")),c("png"="png","pdf"="pdf","eps"="eps","svg"="svg"), multiple = FALSE),
fluidRow(
column(width=6,numericInput("heightVisuExport", "Height (in px)",min=100,max=NA,value = 500,step =1)),
column(width=6,numericInput("widthVisuExport", "Width (in px)",min=100,max=NA,value = 500,step =1))
),
downloadButton("exportVisu", "Export")
) )
) )
) )
), ),
......
Supports Markdown
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