Commit 1341b3fc authored by Amine  GHOZLANE's avatar Amine GHOZLANE
Browse files

Include Stevenn modification for project number from upload your data section

parent 12721cab
...@@ -574,6 +574,7 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design) ...@@ -574,6 +574,7 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design)
normFactors = NULL normFactors = NULL
FeatureSize = NULL FeatureSize = NULL
CT_Norm = NULL CT_Norm = NULL
Error = NULL
## Counts and taxo tables ## Counts and taxo tables
CT = dataInput$counts CT = dataInput$counts
...@@ -607,13 +608,15 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design) ...@@ -607,13 +608,15 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design)
CT=CT_int CT=CT_int
} else CT = CT[,ind] } else CT = CT[,ind]
print("start order")
## Order CT according to the target ## Order CT according to the target
CT = OrderCounts(counts=CT,labels=labels)$CountsOrder CT = OrderCounts(counts=CT,labels=labels)$CountsOrder
CT_noNorm = CT CT_noNorm = CT
RowProd = sum(apply(CT_noNorm,1,prod)) RowProd = sum(apply(CT_noNorm,1,prod))
print("end order")
merged_table = merge(CT, taxo, by="row.names") merged_table = merge(CT, taxo, by="row.names")
save(merged_table, file = "/tmp/wtf.rdata")
print("end merged")
CT = as.data.frame(merged_table[,2: (dim(CT)[2]+1)]) CT = as.data.frame(merged_table[,2: (dim(CT)[2]+1)])
taxo = as.data.frame(merged_table[,(dim(CT)[2]+2):dim(merged_table)[2]]) taxo = as.data.frame(merged_table[,(dim(CT)[2]+2):dim(merged_table)[2]])
...@@ -622,96 +625,99 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design) ...@@ -622,96 +625,99 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design)
colnames(taxo) = namesTaxo colnames(taxo) = namesTaxo
#ordOTU = order(rownames(taxo)) #ordOTU = order(rownames(taxo))
counts_annot = CT counts_annot = CT
if(0%in%colSums(counts_annot)){Error = "At least one of the column of the counts table is 0" }
## Create the dds object else{
dds <- DESeqDataSetFromMatrix(countData=CT, colData=target, design=design,ignoreRank=TRUE) print("DDS start")
## Create the dds object
#save(dds,file="testdds.RData") dds <- DESeqDataSetFromMatrix(countData=CT, colData=target, design=design,ignoreRank=TRUE)
if(is.null(VarNorm)){ print("DDS end")
## Counts normalisation #save(dds,file="testdds.RData")
## Normalisation with or without 0 if(is.null(VarNorm)){
if(input$AccountForNA=="NonNull" || RowProd==0) dds = estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT)) ## Counts normalisation
if(input$AccountForNA=="All" && RowProd!=0) dds = estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc))) ## Normalisation with or without 0
if(input$AccountForNA=="Weighted" && input$AccountForNA!="NonNull" ) {dds = estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT)); sizeFactors(dds) = w.sizefactor(CT)}
if(input$AccountForNA=="Total counts") { sizeFactors(dds) = colSums(CT)/mean(colSums(CT))}
normFactors = sizeFactors(dds)
} else{
group = as.data.frame(target[,VarNorm])
group = apply(group,1,paste, collapse = "-")
normFactors = c()
mod = unique(group)
## At least 2 samples are needed for the normalization
if(min(table(group))>1){
for(i in unique(group))
{
indgrp = which(group==i)
CT_tmp = CT[,indgrp]
CT_tmp = removeNulCounts(CT_tmp)
target_tmp = data.frame(labels = rownames(target)[indgrp])
dds_tmp <- DESeqDataSetFromMatrix(countData=CT_tmp, colData=target_tmp, design=~labels,ignoreRank=TRUE)
if(input$AccountForNA=="NonNull") {dds_tmp = estimateSizeFactors(dds_tmp,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT_tmp)); normFactors[indgrp] = sizeFactors(dds_tmp)}
if(input$AccountForNA=="All") {dds_tmp = estimateSizeFactors(dds_tmp,locfunc=eval(as.name(input$locfunc))); normFactors[indgrp] = sizeFactors(dds_tmp)}
if(input$AccountForNA=="Weighted" && input$AccountForNA!="NonNull" ) {dds_tmp = estimateSizeFactors(dds_tmp,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT_tmp)); normFactors[indgrp] = w.sizefactor(CT_tmp)}
if(input$AccountForNA=="Total counts") { normFactors[indgrp] = colSums(CT_tmp)/mean(colSums(CT_tmp))}
}
} else{
if(input$AccountForNA=="NonNull" || RowProd==0) dds = estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT)) if(input$AccountForNA=="NonNull" || RowProd==0) dds = estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT))
if(input$AccountForNA=="All" && RowProd!=0) dds = estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc))) if(input$AccountForNA=="All" && RowProd!=0) dds = estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)))
if(input$AccountForNA=="Weighted" && input$AccountForNA!="NonNull" ) {dds = estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT)); sizeFactors(dds) = w.sizefactor(CT)} if(input$AccountForNA=="Weighted" && input$AccountForNA!="NonNull" ) {dds = estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT)); sizeFactors(dds) = w.sizefactor(CT)}
if(input$AccountForNA=="Total counts") { sizeFactors(dds) = colSums(CT)/mean(colSums(CT))} if(input$AccountForNA=="Total counts") { sizeFactors(dds) = colSums(CT)/mean(colSums(CT))}
normFactors = sizeFactors(dds) normFactors = sizeFactors(dds)
} else{
group = as.data.frame(target[,VarNorm])
group = apply(group,1,paste, collapse = "-")
normFactors = c()
mod = unique(group)
## At least 2 samples are needed for the normalization
if(min(table(group))>1){
for(i in unique(group))
{
indgrp = which(group==i)
CT_tmp = CT[,indgrp]
CT_tmp = removeNulCounts(CT_tmp)
target_tmp = data.frame(labels = rownames(target)[indgrp])
dds_tmp <- DESeqDataSetFromMatrix(countData=CT_tmp, colData=target_tmp, design=~labels,ignoreRank=TRUE)
if(input$AccountForNA=="NonNull") {dds_tmp = estimateSizeFactors(dds_tmp,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT_tmp)); normFactors[indgrp] = sizeFactors(dds_tmp)}
if(input$AccountForNA=="All") {dds_tmp = estimateSizeFactors(dds_tmp,locfunc=eval(as.name(input$locfunc))); normFactors[indgrp] = sizeFactors(dds_tmp)}
if(input$AccountForNA=="Weighted" && input$AccountForNA!="NonNull" ) {dds_tmp = estimateSizeFactors(dds_tmp,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT_tmp)); normFactors[indgrp] = w.sizefactor(CT_tmp)}
if(input$AccountForNA=="Total counts") { normFactors[indgrp] = colSums(CT_tmp)/mean(colSums(CT_tmp))}
}
} else{
if(input$AccountForNA=="NonNull" || RowProd==0) dds = estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT))
if(input$AccountForNA=="All" && RowProd!=0) dds = estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)))
if(input$AccountForNA=="Weighted" && input$AccountForNA!="NonNull" ) {dds = estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT)); sizeFactors(dds) = w.sizefactor(CT)}
if(input$AccountForNA=="Total counts") { sizeFactors(dds) = colSums(CT)/mean(colSums(CT))}
normFactors = sizeFactors(dds)
}
sizeFactors(dds) = normFactors
} }
sizeFactors(dds) = normFactors ## Keep normalized OTU table
} CT_Norm = counts(dds, normalized=TRUE)
## Keep normalized OTU table # Only interesting OTU
CT_Norm = counts(dds, normalized=TRUE) # merged_table = merge(CT, taxo[order(rownames(CT)),], by="row.names")
# Only interesting OTU # merged_table = merge(CT, taxo, by="row.names")
# merged_table = merge(CT, taxo[order(rownames(CT)),], by="row.names") # CT = as.data.frame(merged_table[,2: (dim(CT)[2]+1)])
# taxo = as.data.frame(merged_table[,(dim(CT)[2]+2):dim(merged_table)[2]])
# merged_table = merge(CT, taxo, by="row.names") #
# CT = as.data.frame(merged_table[,2: (dim(CT)[2]+1)]) # rownames(CT) = merged_table[,1]
# taxo = as.data.frame(merged_table[,(dim(CT)[2]+2):dim(merged_table)[2]]) # rownames(taxo) = merged_table[,1]
# # #ordOTU = order(rownames(taxo))
# rownames(CT) = merged_table[,1] # counts_annot = CT
# rownames(taxo) = merged_table[,1] # ordOTU = order(rownames(taxo))
# #ordOTU = order(rownames(taxo)) # indOTU_annot = which(rownames(CT)%in%rownames(taxo))
# counts_annot = CT # counts_annot = CT[indOTU_annot[ordOTU],]
# ordOTU = order(rownames(taxo)) ## Aggregate matrix
# indOTU_annot = which(rownames(CT)%in%rownames(taxo)) if(taxoSelect=="OTU/Gene") counts = counts_annot
# counts_annot = CT[indOTU_annot[ordOTU],] else{
## Aggregate matrix if(input$TypeTable == "MGS" && input$FileFormat!="fileBiom"){
if(taxoSelect=="OTU/Gene") counts = counts_annot MGS_taxocol = which(toupper(colnames(taxo))%in%"MGS")
else{ taxoS = taxo[,MGS_taxocol]
if(input$TypeTable == "MGS" && input$FileFormat!="fileBiom"){ counts = aggregate(counts_annot,by=list(Taxonomy = taxoS),mean)
MGS_taxocol = which(toupper(colnames(taxo))%in%"MGS") rownames(counts)=counts[,1]
taxoS = taxo[,MGS_taxocol] counts=counts[,-1]
counts = aggregate(counts_annot,by=list(Taxonomy = taxoS),mean) counts_int=t(apply(counts,1,as.integer))
rownames(counts)=counts[,1] rownames(counts_int)=rownames(counts)
counts=counts[,-1] colnames(counts_int)=colnames(counts)
counts_int=t(apply(counts,1,as.integer)) counts=counts_int
rownames(counts_int)=rownames(counts) }
colnames(counts_int)=colnames(counts) if(taxoSelect != "MGS" || input$FileFormat=="fileBiom"){
counts=counts_int #taxoS = taxo[ordOTU,taxoSelect]
} taxoS = taxo[,taxoSelect]
if(taxoSelect != "MGS" || input$FileFormat=="fileBiom"){ counts = aggregate(counts_annot,by=list(Taxonomy = taxoS),sum)
#taxoS = taxo[ordOTU,taxoSelect] rownames(counts)=counts[,1];counts=counts[,-1]
taxoS = taxo[,taxoSelect] }
counts = aggregate(counts_annot,by=list(Taxonomy = taxoS),sum)
rownames(counts)=counts[,1];counts=counts[,-1]
} }
## Ordering the counts table according to the target labels
tmpOrder = OrderCounts(counts,normFactors,labels)
counts = tmpOrder$CountsOrder
normFactors = tmpOrder$normFactorsOrder
CheckTarget = TRUE
} }
## Ordering the counts table according to the target labels
tmpOrder = OrderCounts(counts,normFactors,labels)
counts = tmpOrder$CountsOrder
normFactors = tmpOrder$normFactorsOrder
CheckTarget = TRUE
} }
return(list(counts=counts,CheckTarget=CheckTarget,normFactors=normFactors, CT_noNorm=CT_noNorm, CT_Norm =CT_Norm)) return(list(counts=counts,CheckTarget=CheckTarget,normFactors=normFactors, CT_noNorm=CT_noNorm, CT_Norm =CT_Norm, Error = Error))
#return(list(counts=counts,target=target[ind,],labeled=labeled,normFactors=normFactors, CT_noNorm=CT_noNorm)) #return(list(counts=counts,target=target[ind,],labeled=labeled,normFactors=normFactors, CT_noNorm=CT_noNorm))
} }
......
This diff is collapsed.
...@@ -109,8 +109,8 @@ body <- dashboardBody( ...@@ -109,8 +109,8 @@ body <- dashboardBody(
tabPanel("Introduction", tabPanel("Introduction",
p("First check out our user guide:"), p("First check out our user guide:"),
tags$ul( tags$ul(
tags$li(a("User's guide", href="Userguide.pdf")), tags$li(a("User's guide",target="_blank", href="Userguide.pdf")),
tags$li(a("Writing a target file for the experimental design", href="experimental_design_guide.pdf")) tags$li(a("Writing a target file for the experimental design",target="_blank", href="experimental_design_guide.pdf"))
), ),
p(" You can test SHAMAN with the dataset from", a("[Tap et al. 2015]",href="http://www.ncbi.nlm.nih.gov/pubmed/26235304"), p(" You can test SHAMAN with the dataset from", a("[Tap et al. 2015]",href="http://www.ncbi.nlm.nih.gov/pubmed/26235304"),
", which is available", a("here",target="_blank",href="Alimintest.zip"),"."), ", which is available", a("here",target="_blank",href="Alimintest.zip"),"."),
...@@ -487,10 +487,20 @@ body <- dashboardBody( ...@@ -487,10 +487,20 @@ body <- dashboardBody(
fluidRow( fluidRow(
box(title="Select your file format",width = 3,status = "success", solidHeader = TRUE,collapsible = FALSE, box(title="Select your file format",width = 3,status = "success", solidHeader = TRUE,collapsible = FALSE,
# selectInput("FileFormat","",c("Count table & taxonomy (*.csv or *.tsv)"="fileCounts","BIOM file"="fileBiom","Saved project"="fileRData"),selected="fileCounts"), # selectInput("FileFormat","",c("Count table & taxonomy (*.csv or *.tsv)"="fileCounts","BIOM file"="fileBiom","Saved project"="fileRData"),selected="fileCounts"),
selectInput("FileFormat","",c("Count table & taxonomy (*.csv or *.tsv)"="fileCounts","BIOM file"="fileBiom"),selected="fileCounts"), selectInput("FileFormat","",c("Count table & taxonomy (*.csv or *.tsv)"="fileCounts","BIOM file"="fileBiom","Project number"="projnum"),selected="fileCounts"),
conditionalPanel(condition="input.FileFormat=='fileCounts'", conditionalPanel(condition="input.FileFormat=='fileCounts'",
checkboxInput("NoTaxoFile","No taxonomy table",value=FALSE) checkboxInput("NoTaxoFile","No taxonomy table",value=FALSE)
),
conditionalPanel(condition="input.FileFormat=='projnum'",
inlineCSS(list(.pwdGREEN = "background-color: #DDF0B3",.pwdRED = "background-color: #F0B2AD")),
textInput("password_home","Enter the key",value = NULL),
div(style = "text-align:right;",
actionButton("Check_project_home", "Check project number",icon=icon("check-circle")),
tags$style(type='text/css', "#Check_project_home {margin-top: 15px;}")
)
) )
), ),
conditionalPanel(condition="input.FileFormat=='fileCounts'", conditionalPanel(condition="input.FileFormat=='fileCounts'",
...@@ -527,18 +537,24 @@ body <- dashboardBody( ...@@ -527,18 +537,24 @@ body <- dashboardBody(
) )
), ),
box(title="Load phylogenetic tree (optional)",width = 3, status = "primary", solidHeader = TRUE,collapsible = TRUE,collapsed = TRUE, conditionalPanel(condition="input.FileFormat=='projnum'",
fileInput('fileTree', h6(strong('Select your file (tree)')),width="100%"), uiOutput("Project_box_home")
tags$script('$( "#fileTree" ).on( "click", function() { this.value = null; });') ),
conditionalPanel(condition="input.FileFormat!='projnum'",
box(title="Load phylogenetic tree (optional)",width = 3, status = "primary", solidHeader = TRUE,collapsible = TRUE,collapsed = TRUE,
fileInput('fileTree', h6(strong('Select your file (tree)')),width="100%"),
tags$script('$( "#fileTree" ).on( "click", function() { this.value = null; });')
)
), ),
fluidRow(column(width=3, fluidRow(column(width=3,
uiOutput("InfoCountsFile"), uiOutput("InfoCountsFile"),
uiOutput("InfoTaxoFile"), uiOutput("InfoTaxoFile"),
uiOutput("InfoBIOM") uiOutput("InfoBIOM")
)
) )
)
), ),
column(id="tabboxdata_col",width=12,uiOutput("TabBoxData")), column(id="tabboxdata_col",width=12,uiOutput("TabBoxData")),
......
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