Commit 57f3e020 authored by svolant's avatar svolant
Browse files

summary plot

parent aee2f965
......@@ -1119,11 +1119,13 @@ CheckCountsTable <- function(counts)
######################################################
Plot_Visu_Scatterplot<- function(input,resDiff,export=FALSE,lmEst = FALSE){
Plot_Visu_Scatterplot<- function(input,resDiff,export=FALSE,lmEst = FALSE,CorEst=FALSE){
plot = NULL
regCoef = NULL
Rsq = NULL
cor.est = NULL
cor.pvalue = NULL
dds = resDiff$dds
counts = as.data.frame(round(counts(dds, normalized = TRUE)))
target = as.data.frame(resDiff$target)
......@@ -1142,7 +1144,7 @@ CheckCountsTable <- function(counts)
symbol_var = if (PchBy == "None" || is.null(PchBy)) NULL else data[,PchBy]
size_var = if (PointSize == "None" || is.null(PointSize)) NULL else data[,PointSize]
if(!export && !input$AddRegScatter && !lmEst){
if(!export && !input$AddRegScatter && !lmEst && !CorEst){
plot = scatterD3(x = x_var,
y = y_var,
lab = rownames(data),
......@@ -1163,7 +1165,7 @@ CheckCountsTable <- function(counts)
}
if(export || input$AddRegScatter){
if(!lmEst ){
if(!lmEst && !CorEst){
col_var = if (ColBy== "None" || is.null(ColBy)) 1 else data[,ColBy]
symbol_var = if (PchBy == "None" || is.null(PchBy)) factor(rep(1,nrow(data))) else data[,PchBy]
size_var = if (PointSize == "None" || is.null(PointSize)) 1 else data[,PointSize]
......@@ -1175,7 +1177,7 @@ CheckCountsTable <- function(counts)
return(plot)
}
}
if(lmEst)
if(lmEst && !CorEst)
{
res = lm(y_var~x_var)
sumRes = summary(res)
......@@ -1184,6 +1186,14 @@ CheckCountsTable <- function(counts)
Rsq = sumRes$r.squared
return(list(regCoef=regCoef,Rsq = Rsq))
}
if(CorEst)
{
print(head(data))
cor.est = cor(as.matrix(data),method = input$CorMeth)
#cor.pvalue = cor.test(data,method = input$CorMeth)
return(list(cor.est=cor.est))
}
}
......
......@@ -73,6 +73,12 @@ if (!require(genefilter)) {
biocLite("genefilter")
library(genefilter)
}
if (!require(googleVis)) {
install.packages('googleVis')
library(googleVis)
}
library(shinyjs)
# Allow to upload 50M files
options(shiny.maxRequestSize=50*1024^2)
......@@ -355,13 +361,51 @@ shinyServer(function(input, output,session) {
{
tabBox(width = NULL, selected = "Count table",
tabPanel("Count table",dataTableOutput("DataCounts")),
tabPanel("Taxonomy",dataTableOutput("DataTaxo"))
tabPanel("Taxonomy",dataTableOutput("DataTaxo")),
tabPanel("Summary",h5(strong("Percentage of annotation")),htmlOutput("SummaryView"),
br(),h5(strong("Number of features by level:")),plotOutput("SummaryViewBarplot",width = 1200,height=500))
)
}
})
output$SummaryView <- renderGvis({
data = dataInput()$data
taxo = data$taxo
counts = data$counts
res = NULL
if(!is.null(data$counts) && !is.null(data$taxo) && nrow(data$counts)>0 && nrow(data$taxo)>0)
{
tmpPercent = round(apply(is.na(taxo),2,table)["FALSE",]/nrow(counts)*100,2)
df <- data.frame(Label = colnames(taxo),Value = tmpPercent)
res = gvisGauge(df,options=list(min=0, max=100, greenFrom=80,
greenTo=100, yellowFrom=60, yellowTo=80,
redFrom=0, redTo=60, width=1200, height=300))
}
return(res)
})
output$SummaryViewBarplot <- renderPlot({
data = dataInput()$data
taxo = data$taxo
counts = data$counts
res = NULL
if(!is.null(data$counts) && !is.null(data$taxo) && nrow(data$counts)>0 && nrow(data$taxo)>0)
{
colors=rep(c("#1f77b4","#aec7e8","#ff7f0e","#ffbb78", "#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b",
"#c49c94","#e377c2","#f7b6d2","#7f7f7f", "#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"),ceiling(ncol(taxo)/20))
tmp = apply(taxo,2,unique)
nbfeatures = as.numeric(lapply(tmp,length)) -as.numeric(lapply(lapply(tmp,is.na),any))
df <- data.frame(Label = colnames(taxo),Count = nbfeatures)
df$Label = factor(df$Label,levels =colnames(taxo) )
res = ggplot(df,aes(x=Label,y=Count,fill=Label))+geom_bar(stat="identity")
res = res + theme_bw() + xlab("Taxonomy") + scale_fill_manual(values=colors) + guides(fill=FALSE)
}
return(res)
})
#####################################################
##
## TARGET FILE
......@@ -1278,6 +1322,13 @@ output$RunButton <- renderUI({
pageLength = 10,scrollX=TRUE
))
## Correlation coefficients Table
output$CorTable <- renderDataTable(
Plot_Visu_Scatterplot(input,ResDiffAnal(),CorEst=TRUE)$cor.est,
options = list(lengthMenu = list(c(10, 50, -1), c('10', '50', 'All')),
pageLength = 10,scrollX=TRUE
))
output$lmEquation <- renderPrint({
res = Plot_Visu_Scatterplot(input,ResDiffAnal(),lmEst=TRUE)
coef = res$regCoef
......@@ -1320,18 +1371,18 @@ output$RunButton <- renderUI({
})
output$SelectVarBoxDiv <- renderUI({
selectVar = input$VisuVarInt
if(!is.null(selectVar))
{
selectInput("VarBoxDiv", h6(strong("By")),selectVar)
}
})
#
# output$SelectVarBoxDiv <- renderUI({
#
# selectVar = input$VisuVarInt
#
# if(!is.null(selectVar))
# {
# selectInput("VarBoxDiv", h6(strong("By")),selectVar)
# }
#
# })
#
output$plotVisu <- renderUI({
res=NULL
......
......@@ -70,6 +70,12 @@ if (!require(genefilter)) {
library(genefilter)
}
if (!require(googleVis)) {
install.packages('googleVis')
library(googleVis)
}
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Home", tabName = "Home", icon = icon("home")),
......@@ -403,23 +409,29 @@ body <- dashboardBody(
conditionalPanel(condition="input.PlotVisuSelect=='Scatterplot' && !input.AddRegScatter",
useShinyjs(),
br(),
p(actionButton("scatterD3-reset-zoom", HTML("<span class='glyphicon glyphicon-search' aria-hidden='true'></span> Reset Zoom")),Align="right")
p(actionButton("scatterD3-reset-zoom", HTML("<span class='glyphicon glyphicon-search' aria-hidden='true'></span> Reset Zoom")),Align="right"),
box(title = "Correlation table", width = NULL, status = "primary", solidHeader = TRUE,collapsible = TRUE,collapsed= TRUE,
dataTableOutput("CorTable")
)
),
conditionalPanel(condition="input.PlotVisuSelect=='Scatterplot' && input.AddRegScatter",
column(width=6,
br(),
box(title = "Regression coefficients", width = NULL, status = "primary", solidHeader = TRUE,collapsible = TRUE,collapsed= TRUE,
dataTableOutput("lmRegScatter")
)
fluidRow(
column(width=6,
br(),
box(title = "Regression coefficients", width = NULL, status = "primary", solidHeader = TRUE,collapsible = TRUE,collapsed= TRUE,
dataTableOutput("lmRegScatter")
)
),
column(width=6,br(),htmlOutput("lmEquation"))
)
)
),
column(width=3,
box(title = "Select your plot", width = NULL, status = "primary", solidHeader = TRUE,collapsible = FALSE,collapsed= FALSE,
selectizeInput("PlotVisuSelect","",c("Barplot"="Barplot","Heatmap"="Heatmap","Boxplot"="Boxplot","Scatterplot"="Scatterplot","Diversity"="Diversity","Rarefaction"="Rarefaction"),selected = "Scatterplot")
selectizeInput("PlotVisuSelect","",c("Barplot"="Barplot","Heatmap"="Heatmap","Boxplot"="Boxplot","Scatterplot"="Scatterplot","Diversity"="Diversity","Rarefaction"="Rarefaction"),selected = "Barplot")
),
......@@ -436,6 +448,7 @@ body <- dashboardBody(
),
conditionalPanel(condition="input.PlotVisuSelect=='Scatterplot' ",
uiOutput("VarIntVisuScatter"),
radioButtons("CorMeth","Correlation method",c("Pearson" = "pearson","Spearman" = "spearman"),inline=TRUE),
checkboxInput("AddRegScatter","Add regression line",FALSE)
),
conditionalPanel(condition="input.PlotVisuSelect!='Rarefaction' && input.PlotVisuSelect!='Diversity' && input.PlotVisuSelect!='Scatterplot'",
......@@ -483,10 +496,10 @@ body <- dashboardBody(
conditionalPanel(condition="input.PlotVisuSelect=='Diversity'",
selectizeInput("WhichDiv",h6(strong("Diversity")),c('Alpha','Beta','Gamma'),selected = c('Alpha','Beta','Gamma'),multiple=TRUE),
checkboxInput("AddBoxplotDiv","AddBoxplot",value=FALSE)
),
conditionalPanel(condition="input.PlotVisuSelect=='Diversity' && input.AddBoxplotDiv",
uiOutput("SelectVarBoxDiv")
)
# conditionalPanel(condition="input.PlotVisuSelect=='Diversity' && input.AddBoxplotDiv",
# uiOutput("SelectVarBoxDiv")
# )
),
......
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