Commit 2c6de445 authored by Amine  GHOZLANE's avatar Amine GHOZLANE
Browse files

Debug scatter and provide a first work for mgs

parent fe993b32
......@@ -187,7 +187,17 @@ CheckCountsTable <- function(counts)
}
# computePonderationFactors=function(mgs_vect, taxo)
# {
# pond_factor = c()
# for (mgs in mgs_vect){
# print(typeof(taxo[which(taxo[, 1] == mgs), 2]))
# gene_size = as.vector(taxo[which(taxo[, 1] == mgs), 2])
# print(gene_size)
# pond_factor = c(pond_factor, gene_size / sum(gene_size))
# }
# return(pond_factor)
# }
## Get the counts for the selected taxonomy
GetCountsMerge <- function(input,dataInput,taxoSelect,target,design)
......@@ -210,6 +220,7 @@ CheckCountsTable <- function(counts)
## Get the feature size for the normalisation
Size_indcol = which(toupper(colnames(CT))%in%"SIZE")
#Size_indcol = which(toupper(colnames(CT))%in%"size")
if(length(Size_indcol)==1) FeatureSize = CT[,Size_indcol]
......@@ -222,10 +233,31 @@ CheckCountsTable <- function(counts)
CT_noNorm = CT
RowProd = sum(apply(CT_noNorm,1,prod))
# if(input$TypeTable == "MGS"){
# merged_table = merge(CT, taxo[order(rownames(CT)),], by="row.names")
# CT = merged_table[,2: (dim(CT)[2]+1)]
# taxo = merged_table[,(dim(CT)[2]+2):dim(merged_table)[2]]
# rownames(CT) = merged_table[,1]
# rownames(taxo) = merged_table[,1]
# FeatureSize = FeatureSize[which(names(FeatureSize) %in%rownames(CT))]
#
# print("Do something")
# mgs = unique(taxo[,"MGS"])
# #HERE
# pond_factors = computePonderationFactors(mgs, cbind(taxo[,"MGS"],FeatureSize))
# print(pond_factors)
# CT = CT * pond_factors
# CT_int=t(apply(CT,1,as.integer))
# rownames(CT_int)=rownames(CT)
# colnames(CT_int)=colnames(CT)
# CT=CT_int
# CT_noNorm = CT
# RowProd = sum(apply(CT_noNorm,1,prod))
# }
#
## Counts normalisation
dds <- DESeqDataSetFromMatrix(countData=CT, colData=target, design=design)
## Normalisation with or without 0
### Strange with Rowprod, not executed properly each time
if(input$AccountForNA || RowProd==0) dds = estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT))
if(!input$AccountForNA && RowProd!=0) dds = estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)))
......@@ -238,14 +270,14 @@ CheckCountsTable <- function(counts)
rownames(taxo) = merged_table[,1]
ordOTU = order(rownames(taxo))
counts_annot = CT
# ordOTU = order(rownames(taxo))
# indOTU_annot = which(rownames(CT)%in%rownames(taxo))
# counts_annot = CT[indOTU_annot[ordOTU],]
## ICI modif
if(taxoSelect=="OTU") counts = counts_annot
else{
taxoS = taxo[ordOTU,taxoSelect]
#taxoS = taxo[,taxoSelect]
counts = aggregate(counts_annot,by=list(Taxonomy = taxoS),sum)
rownames(counts)=counts[,1];counts=counts[,-1]
}
......@@ -294,9 +326,9 @@ CheckCountsTable <- function(counts)
sizeFactors(dds) = normFactorsOTU
dds <- estimateDispersions(dds, fitType=input$fitType)
if(as.numeric(R.Version()$major)+as.numeric(R.Version()$minor) >= 4.3){
dds <- nbinomWaldTest(dds)
dds <- nbinomWaldTest(dds, maxit=10)
}else{
dds <- nbinomWaldTest(dds,modelMatrixType = "expanded")
dds <- nbinomWaldTest(dds,modelMatrixType = "expanded",maxit=10)
}
countsNorm = counts(dds, normalized = TRUE)
return(list(dds = dds,raw_counts=counts,countsNorm=countsNorm,target=target,design=design,normFactors = normFactorsOTU,CT_noNorm=CT_noNorm))
......@@ -1509,7 +1541,7 @@ CheckCountsTable <- function(counts)
if(input$SensPlotVisu=="Horizontal") log2FC = t(as.matrix(log2FC))
if(!export) res = d3heatmap(log2FC, dendrogram = "row", Rowv = TRUE, Colv = NA, na.rm = TRUE, width = input$widthVisu, height = input$heightVisu, show_grid = FALSE, colors = col, scale = input$scaleHeatmap,cexRow = input$LabelSizeHeatmap,cexCol =input$LabelSizeHeatmap, offsetCol=input$LabelColOffsetHeatmap,offsetRow=input$LabelRowOffsetHeatmap)
if(export) res = heatmap.2(log2FC, dendrogram = "row", Rowv = TRUE, Colv = NA, na.rm = TRUE, width = input$widthVisu, height = input$heightVisu, density.info="none", show_grid = FALSE, trace="none", col = col, scale = input$scaleHeatmap,cexRow = input$LabelSizeHeatmap,cexCol =input$LabelSizeHeatmap, offsetCol=input$LabelColOffsetHeatmap,offsetRow=input$LabelRowOffsetHeatmap)
if(export) res = heatmap.2(log2FC, dendrogram = "none", Rowv = TRUE, Colv = NA, na.rm = TRUE, width = input$widthVisu, height = input$heightVisu, margins=c(12,8), density.info="none", show_grid = FALSE, trace="none", col = col, scale = input$scaleHeatmap,cexRow = input$LabelSizeHeatmap,cexCol =input$LabelSizeHeatmap, offsetCol=input$LabelColOffsetHeatmap,offsetRow=input$LabelRowOffsetHeatmap)
}
return(res)
}
......
......@@ -1528,7 +1528,7 @@ output$RunButton <- renderUI({
output$VarIntVisuScatter <- renderUI({
target=dataInputTarget()
target=dataInputTarget()$target
data = dataInput()$data
taxo = input$TaxoSelect
resDiff = ResDiffAnal()
......
......@@ -95,10 +95,10 @@ body <- dashboardBody(
p("SHAMAN is a SHiny application for Metagenomic ANalysis including the normalization,
the differential analysis and mutiple visualization.",style = "font-family: 'times'; font-si16pt"),
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/"),
". 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"),".
". 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"),a("Jonsson2016]",href="http://www.ncbi.nlm.nih.gov/pmc/articles/PMC4727335/"),".
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/"), ".
A presentation about SHAMAN is available", a("here",target="_blank",href="shaman_presentation.pdf"),style = "font-family: 'times'; font-si16pt"),
A presentation about SHAMAN is available", a("here.",target="_blank",href="shaman_presentation.pdf"),style = "font-family: 'times'; font-si16pt"),
p("Hereafter is the global workflow of the SHAMAN application:"),
div(img(src = "Workflow.png",width = "100%",style="max-width: 600px"),Align="center")
),
......@@ -106,12 +106,11 @@ body <- dashboardBody(
p(a("Stevenn Volant", href="mailto:stevenn.volant@pasteur.fr"), "(Initiator, coding, testing, documentation, evaluation)"),
p(a("Amine Ghozlane",href="mailto:amine.ghozlane@pasteur.fr"), "(Coding, testing, documentation, evaluation)"),
p(a("Hugo Varet",href="mailto:hugo.varet@pasteur.fr"), "(Coding, testing, feature suggestions)"),
p(a("Pierre Lechat",href="mailto:pierre.lechat@pasteur.fr"), "(Coding, testing, feature suggestions)"),
p(a("Marie-Agnès Dillies",href="mailto:marie-agnes.dillies@pasteur.fr"), "(Evaluation)"),
p(a("Sean Kennedy",href="mailto:sean.kennedy@pasteur.fr"), "(Evaluation)"),
h3("Acknowledgements"),
p("Thanks to the following people for patches and other suggestions for improvements:"),
p(a("Christophe Malabat",href="mailto:christophe.malabat@pasteur.fr"),a(", Julien Tap",href="mailto:julien.tap@danone.com"),a(", Anna Zhukova",href="mailto:anna.zhukova@pasteur.fr"), a(", Rachel Torchet",href="mailto:rachel.torchet@pasteur.fr"))
p(a("Christophe Malabat, ",href="mailto:christophe.malabat@pasteur.fr"), a("Pierre Lechat, ",href="mailto:pierre.lechat@pasteur.fr"),a("Julien Tap, ",href="mailto:julien.tap@danone.com"),a("Anna Zhukova, ",href="mailto:anna.zhukova@pasteur.fr"), a("Rachel Torchet",href="mailto:rachel.torchet@pasteur.fr"))
),
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 SHAMAN please contact authors", a("here", href="mailto:shaman@pasteur.fr"),".", style = "font-family: 'times'; font-si16pt; color:red")
......@@ -134,7 +133,7 @@ body <- dashboardBody(
p("The 16S rRNA (V3 - V4 regions) from fece samples was sequenced at time stamp : 2, 3, 4 and 5.", br(),
"The analysis will consider the different impact of the different fiber intake and the comparison to patient metabolic data.")),
tabPanel("1-Load 16S data",
p("The first step consists to load the count matrix and the annotation table as follow :"),
p("The first step consists to load the count table and the annotation table as follow :"),
p("- Select 'Upload your data'", br(),
"- Load the count table :",br(), img(src = "tutorial/tutorial_upload1.png",width = "100%",style="max-width: 900px"),hr(),
"- Load the annotation table :", br(), img(src = "tutorial/tutorial_upload2.png",width = "100%",style="max-width: 900px"),hr(),
......@@ -185,6 +184,9 @@ body <- dashboardBody(
),
conditionalPanel(condition="input.FileFormat=='fileCounts'",
box(title="Load the count table",width = 3,height = "250px", status = "primary", solidHeader = TRUE,collapsible = FALSE,
fluidRow(
column(width=6,radioButtons("TypeTable",h6(strong("Type:")),c("OTU/Gene table"="OTU","MGS table"="MGS")))
),
fileInput('fileCounts', h6(strong('Select your file')),width="100%")
),
......
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