Commit 79ab161a authored by Stevenn Volant's avatar Stevenn Volant
Browse files

Couleur barplot + diversity

parent 443ea37e
......@@ -268,8 +268,7 @@ CheckCountsTable <- function(counts)
## Diagnostic Plots
Plot_diag <- function(input,resDiff)
{
#colors = c("dodgerblue","firebrick1","MediumVioletRed","SpringGreen")
colors = c("SpringGreen","dodgerblue","black","firebrick1")
VarInt = input$VarInt
dds = resDiff$dds
counts = resDiff$counts
......@@ -282,10 +281,8 @@ CheckCountsTable <- function(counts)
if(ncol(group)>0 && nrow(counts)>0)
{
## If more than 4 levels for one factor
if(length(VarInt)>1) maxFact =max(sapply(group,FUN=function(x) length(levels(x))))
else maxFact = length(levels(group))
if(maxFact>=4) colors = rainbow(maxFact)
colors = rep(c("#1f77b4","#aec7e8","#ff7f0e","#ffbb78", "#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b",
"#c49c94","#e377c2","#f7b6d2","#7f7f7f", "#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"),ceiling(nrow(target)/20))
if(input$DiagPlot=="barplotTot") res = barplotTot(input,counts,group = group, col=colors)
if(input$DiagPlot=="barplotNul") res = barPlotNul(input,counts, group = group, col=colors)
......@@ -295,7 +292,7 @@ CheckCountsTable <- function(counts)
#if(input$DiagPlot=="Sfactors") diagSFactors(input,dds,frame=1)
if(input$DiagPlot=="SfactorsVStot") res = diagSFactors(input,dds,normFactors,CT_noNorm,frame=2)
if(input$DiagPlot=="pcaPlot") res = PCAPlot_meta(input,dds, group, type.trans = input$TransType, col = colors)
if(input$DiagPlot=="pcoaPlot") res = PCoAPlot_meta(input,dds, group)
if(input$DiagPlot=="pcoaPlot") res = PCoAPlot_meta(input,dds, group, col = colors)
if(input$DiagPlot=="clustPlot") res = HCPlot(input,dds,group,type.trans=input$TransType)
}
......@@ -430,15 +427,16 @@ CheckCountsTable <- function(counts)
## barplot total
barplotTot <- function(input,counts, group, cex.names = 1, col = c("lightblue","orange", "MediumVioletRed", "SpringGreen"))
{
ncol1 <- ncol(group) == 1
par(cex=input$cexTitleDiag,mar=c(6,6,4,5))
barplot(colSums(counts), cex.names = cex.names, main = "Total mapped read count per sample", ylab = "Total mapped read count",
ylim = c(0, max(colSums(counts)) * 1.2), density = if (ncol1) {NULL}
else {15},
angle = if (ncol1) {NULL}
else {c(-45, 0, 45, 90)[as.integer(group[, 2])]}, col = col[as.integer(group[, 1])], las = 2)
else {seq(0,160,length.out =nlevels(group[, 2]))[as.integer(group[, 2])]}, col = col[as.integer(group[, 1])], las = 2)
legend("topright", levels(group[, 1]), fill = col[1:nlevels(group[,1])], bty = "n")
if (!ncol1) legend("topleft", levels(group[, 2]), density = 15,col = 1, angle = c(-45, 0, 45, 90)[1:nlevels(group[, 2])], bty = "n")
if (!ncol1) legend("topleft", levels(group[, 2]), density = 15,col = 1, angle = seq(0,160,length.out =nlevels(group[, 2]))[1:nlevels(group[, 2])], bty = "n")
}
......@@ -457,14 +455,14 @@ CheckCountsTable <- function(counts)
density = if (ncol1) {NULL}
else {15},
angle = if (ncol1) {NULL}
else {c(-45, 0, 45, 90)[as.integer(group[, 2])]},
else {seq(0,160,length.out =nlevels(group[, 2]))[as.integer(group[, 2])]},
cex.names = cex.names, ylab = "Proportion of null counts",
main = "Proportion of null counts per sample",
ylim = c(0, 1.2 * ifelse(max(percentage) == 0, 1, max(percentage))))
abline(h = percentage.allNull, lty = 2, lwd = 2)
legend("topright", levels(group[, 1]), fill = col[1:nlevels(group[,1])], bty = "n")
if (!ncol1) legend("topleft", levels(group[, 2]), density = 15, col = 1, angle = c(-45, 0, 45, 90)[1:nlevels(group[, 2])], bty = "n")
if (!ncol1) legend("topleft", levels(group[, 2]), density = 15, col = 1, angle = seq(0,160,length.out =nlevels(group[, 2]))[1:nlevels(group[, 2])], bty = "n")
}
......@@ -524,11 +522,11 @@ CheckCountsTable <- function(counts)
density = if (ncol1) {NULL}
else {15},
angle = if (ncol1) {NULL}
else {c(-45, 0, 45, 90)[as.integer(group[, 2])]})
else {seq(0,160,length.out =nlevels(group[, 2]))[as.integer(group[, 2])]})
legend("topright", levels(group[, 1]), fill = col[1:nlevels(group[,1])], bty = "n")
if (!ncol1) legend("topleft", levels(group[, 2]), density = 15, col = 1,
angle = c(-45, 0, 45, 90)[1:nlevels(group[, 2])], bty = "n")
angle = seq(0,160,length.out =nlevels(group[, 2]))[1:nlevels(group[, 2])], bty = "n")
for (i in 1:length(seqname)) text(x[i], maj[i]/2, seqname[i], cex=input$cexLabelDiag, srt = 90, adj = 0)
}
......@@ -1098,10 +1096,13 @@ CheckCountsTable <- function(counts)
gamma <- TaxoNumber(counts_tmp_combined, targetInt$AllVar)
beta = gamma/alpha - 1
nb = length(alpha)
dataTmp = data.frame(value=c(alpha,beta,gamma),
diversity = c(rep("Alpha",nb),rep("Beta",nb),rep("Gamma",nb)),
Var = as.character(rep(names(alpha),3)),
X = as.character(rep(targetInt[,VarIntBoxDiv],3)))
# dataTmp = data.frame(value=c(alpha,beta,gamma),
# diversity = c(rep("Alpha",nb),rep("Beta",nb),rep("Gamma",nb)),
# Var = as.character(rep(names(alpha),3)),
# X = as.character(rep(targetInt[,VarIntBoxDiv],3)))
dataTmp = data.frame(value=c(alpha,beta,gamma),
diversity = c(rep("Alpha",nb),rep("Beta",nb),rep("Gamma",nb)),
Var = as.character(rep(names(alpha),3)))
## Merge targetInt et dataTmp par rapport à Var
# VectX = c()
......
......@@ -113,7 +113,7 @@ shinyServer(function(input, output,session) {
## Create base for contrast
rand = floor(runif(1,0,1e9))
namesfile = tempfile(pattern = "BaseContrast", tmpdir = tempdir(), fileext = "")
#paste("/srv/shiny-server/sample-apps/meta16s/BaseContrast_",rand,".txt",sep="")
#paste("/srv/shiny-server/sample-apps/SHAMAN/BaseContrast_",rand,".txt",sep="")
file.create(namesfile,showWarnings=FALSE)
#namesfile = "www/All_Contrast.txt"
......@@ -788,7 +788,7 @@ shinyServer(function(input, output,session) {
if(!is.null(resDiff))
{
box(title="Contrasts (advanced user)",width = NULL, status = "primary", solidHeader = TRUE,collapsible = TRUE,collapsed = TRUE,
box(title="Contrasts (advanced user)",width = NULL, status = "primary", solidHeader = TRUE,collapsible = TRUE,collapsed = FALSE,
fluidRow(
column(width=12,
fileInput('fileContrast', h6(strong('Select a file of contrasts')),width="60%")
......@@ -888,7 +888,7 @@ shinyServer(function(input, output,session) {
## Run DESeq2 via RunDESeq button
observeEvent(input$RunDESeq,{
ResDiffAnal()
withProgress(message="Analysis in progress...",ResDiffAnal())
})
......@@ -1011,7 +1011,7 @@ shinyServer(function(input, output,session) {
#### Export Diag
output$exportdiag <- downloadHandler(
filename <- function() { paste(input$DiagPlot,paste('meta16S',input$Exp_format,sep="."),sep="_") },
filename <- function() { paste(input$DiagPlot,paste('SHAMAN',input$Exp_format,sep="."),sep="_") },
content <- function(file) {
if(input$Exp_format=="png") png(file, width = input$widthDiagExport, height = input$heightDiagExport)
if(input$Exp_format=="pdf") pdf(file, width = input$widthDiagExport/96, height = input$heightDiagExport/96)
......@@ -1032,7 +1032,7 @@ shinyServer(function(input, output,session) {
## PDF
## PDF
output$exportPDFVisu <- downloadHandler(
filename <- function() { paste("test",'meta16S.ps',sep="_")},
filename <- function() { paste("test",'SHAMAN.ps',sep="_")},
content <- function(file) {
resDiff = ResDiffAnal()
filesize = file.info(namesfile)[,"size"]
......@@ -1052,7 +1052,7 @@ output$exportPDFVisu <- downloadHandler(
## PNG
output$exportPNGVisu <- downloadHandler(
filename <- function() { paste("test",'meta16S.png',sep="_") },
filename <- function() { paste("test",'SHAMAN.png',sep="_") },
content <- function(file) {
png(file, width = 600, height = 400)
Plot_Visu(input,ResDiffAnal())
......@@ -1062,7 +1062,7 @@ output$exportPDFVisu <- downloadHandler(
#### Export Visu
output$exportVisu <- downloadHandler(
filename <- function() { paste(input$PlotVisuSelect,paste('meta16S',input$Exp_format_Visu,sep="."),sep="_") },
filename <- function() { paste(input$PlotVisuSelect,paste('SHAMAN',input$Exp_format_Visu,sep="."),sep="_") },
content <- function(file) {
filesize = file.info(namesfile)[,"size"]
if(is.na(filesize)){filesize=0}
......@@ -1198,7 +1198,7 @@ output$exportVisu <- downloadHandler(
#### Export diff table
output$exportDiffTable <- downloadHandler(
filename = function() {paste(input$WhichExportTable,input$ContrastList_table,'meta16S.csv',sep="_")},
filename = function() {paste(input$WhichExportTable,input$ContrastList_table,'SHAMAN.csv',sep="_")},
content = function(file){
switch(input$WhichExportTable,
"Complete" = write.csv(dataDiff()$complete, file),
......@@ -1250,7 +1250,7 @@ output$RunButton <- renderUI({
output$PlotVisuBar <- renderChart({
resDiff = ResDiffAnal()
if(!is.null(resDiff$dds)) Plot_Visu_Barplot(input,resDiff)$plotd3
if(!is.null(resDiff$dds)) withProgress(message="Loading...",Plot_Visu_Barplot(input,resDiff)$plotd3)
},env=new.env())
# output$PlotVisu <- renderPlotly({
......@@ -1265,11 +1265,11 @@ output$RunButton <- renderUI({
resplot = NULL
if(!is.null(resDiff$dds))
{
if(input$HeatMapType=="Counts") resplot = Plot_Visu_Heatmap(input,resDiff)
if(input$HeatMapType=="Counts") resplot = withProgress(message="Loading...",Plot_Visu_Heatmap(input,resDiff))
if(input$HeatMapType=="Log2FC" && filesize!=0)
{
BaseContrast = read.table(namesfile,header=TRUE)
resplot = Plot_Visu_Heatmap_FC(input,BaseContrast,resDiff)
resplot = withProgress(message="Loading...",Plot_Visu_Heatmap_FC(input,BaseContrast,resDiff))
}
}
return(resplot)
......@@ -1279,13 +1279,13 @@ output$RunButton <- renderUI({
output$Boxplot <- renderPlot({
resDiff = ResDiffAnal()
if(!is.null(resDiff$dds)) Plot_Visu_Boxplot(input,resDiff)
if(!is.null(resDiff$dds)) withProgress(message="Loading...",Plot_Visu_Boxplot(input,resDiff))
},height=reactive(input$heightVisu))
output$DiversityPlot <- renderPlot({
resDiff = ResDiffAnal()
if(!is.null(resDiff$dds)) Plot_Visu_Diversity(input,resDiff,type="point")
if(!is.null(resDiff$dds)) withProgress(message="Loading...",Plot_Visu_Diversity(input,resDiff,type="point"))
})
ranges <- reactiveValues(x = NULL, y = NULL)
......@@ -1293,7 +1293,7 @@ output$RunButton <- renderUI({
output$RarefactionPlot <- renderPlot({
resDiff = ResDiffAnal()
taxo = input$TaxoSelect
if(!is.null(resDiff)) Plot_Visu_Rarefaction(input,resDiff,ranges$x,ranges$y,ylab=taxo)
if(!is.null(resDiff)) withProgress(message="Loading...",Plot_Visu_Rarefaction(input,resDiff,ranges$x,ranges$y,ylab=taxo))
}, height = reactive(input$heightVisu))
observeEvent(input$RarefactionPlot_dblclick, {
......@@ -1402,7 +1402,7 @@ output$RunButton <- renderUI({
print(data$counts)
krona_table=tempfile(pattern = "krona", tmpdir = tempdir(), fileext = "")
url=paste(krona_table, ".html", sep="")
#system(paste("export PERL5LIB=/home/aghozlan/workspace/META16S_App/KronaTools-2.6/lib:$PERL5LIB; /home/aghozlan/workspace/META10S_App/krona_bin/bin/ktImportText", krona_table))
#system(paste("export PERL5LIB=/home/aghozlan/workspace/SHAMAN_App/KronaTools-2.6/lib:$PERL5LIB; /home/aghozlan/workspace/META10S_App/krona_bin/bin/ktImportText", krona_table))
system(paste("ktImportText", krona_table))
refs <- paste0("<a href='", url, "' target='_blank'>krona</a>")
......
......@@ -114,21 +114,21 @@ body <- dashboardBody(
tabItem(tabName = "Home",
tabBox(title="Welcome to Meta16S", id="tabset1", height = "700", width = 12,
tabBox(title="Welcome to SHAMAN", id="tabset1", height = "700", width = 12,
tabPanel("About", p("Meta16S is a web interface for the analysis of metagenomic data including the normalization,
tabPanel("About", p("SHAMAN is a web interface for the analysis of metagenomic data including the normalization,
the differential analysis and mutiple visualization.",style = "font-family: 'times'; font-si16pt"),
p("Meta16S is based on DESeq2 R package", a("[Anders and Huber 2010]", href="http://www.ncbi.nlm.nih.gov/pubmed/20979621"), "for the analysis of metagenomic data, as suggested in", a("[McMurdie and Holmes 2014]",href="http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3974642/"),
p("SHAMAN is based on DESeq2 R package", a("[Anders and Huber 2010]", href="http://www.ncbi.nlm.nih.gov/pubmed/20979621"), "for the analysis of metagenomic data, as suggested in", a("[McMurdie and Holmes 2014]",href="http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3974642/"),
". Meta16S robustly identifies the differential abundant genera with the Generalized Linear Model implemented in DESeq2", a("[Love 2014]", href="http://www.ncbi.nlm.nih.gov/pubmed/25516281"),".
". SHAMAN robustly identifies the differential abundant genera with the Generalized Linear Model implemented in DESeq2", a("[Love 2014]", href="http://www.ncbi.nlm.nih.gov/pubmed/25516281"),".
Resulting p-values are adjusted according to the Benjamini and Hochberg procedure [Benjamini and Hochberg 1995].
The PCOA is performed with the", a("ade4 R package",href="http://pbil.univ-lyon1.fr/ade4/"), "and plots are generated with", a("ggplot2",href="http://ggplot2.org/"), "or", a("D3.js packages",href="http://d3js.org/"), ".", style = "font-family: 'times'; font-si16pt")),
tabPanel("Authors", h3("The main contributors to Meta16s:"),
tabPanel("Authors", h3("The main contributors to SHAMAN:"),
p(a("Stevenn Volant", href="mailto:stevenn.volant@pasteur.fr"), "(Initiator, coding, testing, documentation, evaluation)"),
......@@ -148,9 +148,9 @@ body <- dashboardBody(
p(a("Christophe Malabat",href="mailto:christophe.malabat@pasteur.fr"))),
tabPanel("Citing Meta16S",p("No papers about Meta16s have been published yet, but a manuscript is in preparation.",style = "font-family: 'times'; font-si16pt"),
tabPanel("Citing SHAMAN",p("No papers about SHAMAN have been published yet, but a manuscript is in preparation.",style = "font-family: 'times'; font-si16pt"),
p("For now, if you have any comments, questions or suggestions, or want to use meta16s please contact", a("Dr. Marie-Agnès Dillies", href="mailto:marie-agnes.dillies@pasteur.fr"),".", style = "font-family: 'times'; font-si16pt; color:red"))
p("For now, if you have any comments, questions or suggestions, or want to use SHAMAN please contact", a("Dr. Marie-Agnès Dillies", href="mailto:marie-agnes.dillies@pasteur.fr"),".", style = "font-family: 'times'; font-si16pt; color:red"))
),
img(src = "logo.jpg", height = 90, width = 600,align="right")
),
......@@ -267,7 +267,7 @@ body <- dashboardBody(
),
fluidRow(
column(width=8,
uiOutput("contrastBox"),
# uiOutput("contrastBox"),
uiOutput("contrastBoxAdvanced")
),
column(width=4,
......@@ -562,7 +562,7 @@ body <- dashboardBody(
fluidRow(
column(width=3,tableOutput("krona") )
#includeHTML("file:///home/aghozlan/workspace/META16S_App/www/text.krona.html")
#includeHTML("file:///home/aghozlan/workspace/SHAMAN_App/www/text.krona.html")
)
)
......@@ -829,7 +829,7 @@ body <- dashboardBody(
# Put them together into a dashboardPage
dashboardPage(skin="blue",
dashboardHeader(title = "Meta16S"),
dashboardHeader(title = "SHAMAN"),
sidebar,
body
)
......
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