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)
normFactors = NULL
FeatureSize = NULL
CT_Norm = NULL
Error = NULL
## Counts and taxo tables
CT = dataInput$counts
......@@ -607,13 +608,15 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design)
CT=CT_int
} else CT = CT[,ind]
print("start order")
## Order CT according to the target
CT = OrderCounts(counts=CT,labels=labels)$CountsOrder
CT_noNorm = CT
RowProd = sum(apply(CT_noNorm,1,prod))
print("end order")
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)])
taxo = as.data.frame(merged_table[,(dim(CT)[2]+2):dim(merged_table)[2]])
......@@ -622,10 +625,12 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design)
colnames(taxo) = namesTaxo
#ordOTU = order(rownames(taxo))
counts_annot = CT
if(0%in%colSums(counts_annot)){Error = "At least one of the column of the counts table is 0" }
else{
print("DDS start")
## Create the dds object
dds <- DESeqDataSetFromMatrix(countData=CT, colData=target, design=design,ignoreRank=TRUE)
print("DDS end")
#save(dds,file="testdds.RData")
if(is.null(VarNorm)){
## Counts normalisation
......@@ -711,7 +716,8 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design)
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))
}
......
......@@ -293,16 +293,16 @@ shinyServer(function(input, output,session) {
# if(input$FileFormat=="fileRData")
# {
# inFile <- input$fileRData
# load(inFile)
# if(!is.null(inputData)){
# data = inputData$data
# check = inputData$check
# percent = inputData$percent
# }
# }
# if(input$FileFormat=="fileRData")
# {
# inFile <- input$fileRData
# load(inFile)
# if(!is.null(inputData)){
# data = inputData$data
# check = inputData$check
# percent = inputData$percent
# }
# }
return(list(data=data,check=check,percent=percent))
})
......@@ -362,25 +362,35 @@ shinyServer(function(input, output,session) {
CT_noNorm = NULL
CT_Norm = NULL
ChTM = NULL
ChMC = NULL
data = isolate(dataInput()$data)
target = isolate(values$TargetWorking)
labeled= isolate(values$labeled)
taxo = isolate(input$TaxoSelect)
print("here-1")
withProgress(
if(!is.null(data$counts) && !is.null(data$taxo) && nrow(data$counts)>0 && nrow(data$taxo)>0 && !is.null(taxo) && taxo!="..." && !is.null(target))
{
print("here0")
design = GetDesign(isolate(input),target)
ChTM = CheckTargetModel(input,target,labeled,data$counts)$Error
if(!is.null(design) && is.null(ChTM))
{
print("here")
tmp = isolate(GetCountsMerge(input,data,taxo,target,design))
ChMC = tmp$Error
if (!is.null(ChMC))
{
print("here_getcount")
counts = tmp$counts
## Filtering the counts
if(isolate(input$AddFilter) && !is.null(isolate(input$SliderThSamp)) && !is.null(isolate(input$SliderThAb)))
{
print("here1")
ind.filter =Filtered_feature(counts,isolate(input$SliderThSamp),isolate(input$SliderThAb))$ind
counts = counts[-ind.filter,]
}
print("here2")
CheckTarget = tmp$CheckTarget
#target = tmp$target
#labeled = tmp$labeled
......@@ -390,8 +400,9 @@ shinyServer(function(input, output,session) {
CT_Norm = tmp$CT_Norm
}
}
}
,message="Merging the counts ...")
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 = ChMC))
#return(list(counts=counts,target=target,labeled=labeled,normFactors=normFactors,CT_noNorm=CT_noNorm))
})
......@@ -734,8 +745,8 @@ shinyServer(function(input, output,session) {
}
values$TargetWorking = as.data.frame(data)
# ind_sel = Target_selection()
# if(length(ind))
# ind_sel = Target_selection()
# if(length(ind))
# target = as.data.frame(apply(target,2,gsub,pattern = "-",replacement = "."))
#ord = order(rownames(data))
......@@ -1253,7 +1264,7 @@ shinyServer(function(input, output,session) {
}
#CHANGEMENT DE COULEUR BORDEL
else if(!is.null(Error) && isolate(values$num)>=1) values$error_progress = TRUE
})
})
observe({
......@@ -1343,6 +1354,35 @@ shinyServer(function(input, output,session) {
}
})
## the same from home
observeEvent(input$Check_project_home,{
values$masque_key = input$password_home
PS = Project_status(values$masque_key,values$curdir)
if(!is.null(input$password_home) && input$password_home!="" && !PS$passOK){
removeCssClass(class = 'pwdGREEN', selector = '#password_home')
addCssClass(class = 'pwdRED', selector = '#password_home')
}
if(!is.null(input$password_home) && input$password_home!="" && PS$passOK){
removeCssClass(class = 'pwdRED', selector = '#password_home')
addCssClass(class = 'pwdGREEN', selector = '#password_home')
hideElement("masque-form",anim=TRUE)
hideElement("masque-infobox",anim=TRUE)
hideElement("boxsum",anim=TRUE)
showElement("reload-project",anim=TRUE)
hideElement("project_over",anim=TRUE)
hideElement("pass",anim=TRUE)
#showElement("MasqueToShaman",anim=TRUE)
}
if(is.null(input$password_home) || input$password_home==""){
removeCssClass(class = 'pwdRED', selector = '#password_home')
removeCssClass(class = 'pwdGREEN', selector = '#password_home')
}
})
#eventReactive(input$refresh, {
# shinyjs::js$refresh()
#hideElement("gaugeMasque_progress")
......@@ -1733,6 +1773,29 @@ shinyServer(function(input, output,session) {
})
#from home
observeEvent(input$LoadResMasque_home, {
if (input$masque_db_home == "rdp"){
updateSelectInput(session, "FileFormat","",selected = "fileCounts")
updateSelectInput(session, "TypeTaxo","",selected = "RDP")
reset("fileTaxo")
reset("fileCounts")
values$rdp_thres_masque = as.numeric(input$rdp_thres_home)
values$rdp_annot_masque = paste(values$curdir,"www","masque","done",paste("file",values$masque_key,sep=""),"shaman_rdp_annotation.tsv",sep= .Platform$file.sep)
values$count_table_masque = paste(values$curdir,"www","masque","done",paste("file",values$masque_key,sep=""),"shaman_otu_table.tsv",sep= .Platform$file.sep)
}
else{
updateSelectInput(session, "FileFormat","",selected = "fileBiom")
reset("fileBiom")
reset("fileTree")
values$biom_masque = paste(values$curdir,"www","masque","done",paste("file",values$masque_key,sep=""),paste("shaman_",input$masque_db_home,".biom",sep=""),sep= .Platform$file.sep)
values$tree_masque = paste(values$curdir,"www","masque","done",paste("file",values$masque_key,sep=""),paste("shaman_",input$masque_db_home,"_tree.nhx",sep=""),sep= .Platform$file.sep)
}
sendSweetAlert(messageId="LoadResMasque_home", title = "Success", text = "Processed data were successfully loaded. You can go to statistical analysis part to analyze your data with SHAMAN.", type = "success", html=TRUE)
})
## Export results in .zip
output$Download_masque_zip <- downloadHandler(
filename = function() { paste("SHAMAN_",values$masque_key,'.zip',sep="")},
......@@ -1742,7 +1805,70 @@ shinyServer(function(input, output,session) {
}
)
## Export results in .zip from home
output$Download_masque_zip_home <- downloadHandler(
filename = function() { paste("SHAMAN_",values$masque_key,'.zip',sep="")},
content = function(file){
zip_file = paste(values$curdir,"www","masque","done",paste("shaman_",values$masque_key,".zip",sep=""),sep= .Platform$file.sep)
if(file.exists(zip_file)){file.copy(zip_file, file)}
}
)
output$Project_box_home <- renderUI({
res = NULL
PS = Project_status(values$masque_key,values$curdir)
if(PS$passOK){
if(PS$status=="done")
{
res = list()
json_file = PS$file
folder_name = paste('file',values$masque_key,sep="")
json_file = paste(curdir,"www","masque","done",paste(folder_name, ".json", sep=""),sep= .Platform$file.sep)
json_data = rjson::fromJSON(file=json_file)
### Paste file name as folder
annot_process = paste(curdir,"www","masque","done",folder_name,"shaman_process_annotation.tsv",sep= .Platform$file.sep)
## Waiting for file creation (max 3min)
start = Sys.time(); diff = 0
while(!file.exists(annot_process) && diff<180){
annot_process = paste(curdir,"www","masque","done",folder_name,"shaman_process_annotation.tsv",sep= .Platform$file.sep)
tmp = Sys.time()
diff = tmp-start
}
if(file.exists(annot_process))
{
ap = read.csv(annot_process,sep="\t")
if(json_data$type == "16S") db_choices = c("Silva" = "silva","Greengenes" = "greengenes", "RDP"= "rdp")
else if(json_data$type == "23S_28S" || json_data$type == "18S") db_choices = c("Silva" = "silva","RDP"= "rdp")
else db_choices = c("Findley" = "findley", "Underhill"= "underhill", "Unite"= "unite", "RDP"= "rdp")
res[[1]] = fluidRow(
box(title="Load the results",width = 3, background = "light-blue",
selectInput("masque_db_home","Select the database",choices=db_choices),
conditionalPanel(condition="input.masque_db_home=='rdp'",numericInput("rdp_thres_home",h6(strong("Threshold:")),0.5,step=0.01,min=0.01,max=1)),
actionButton("LoadResMasque_home", "Upload the results",icon=icon('upload')),
tags$style(type='text/css', "#LoadResMasque_home { width:100%; }"),
receiveSweetAlert(messageId = "LoadResMasque_home")
),
box(title="Download .zip file",width = 3, status = "success",
downloadButton('Download_masque_zip_home', 'Download the results'),
tags$style(type='text/css', "#Download_masque_zip_home { width:100%;}")
)
)
}
}
}
return(res)
})
######################## END MASQUE #################################
......@@ -2146,12 +2272,12 @@ shinyServer(function(input, output,session) {
}
## if user load a bad contrast file after having define one or more good contrasts
# if(!is.null(input$fileContrast)){
# tmpRead = ReadContrastFile()
# CheckCont_new = CheckContrast(tmpRead,dds)
# if(!is.null(CheckCont_new$Warning)) info("test1")
# if(!is.null(CheckCont_new$Error)) info("test2")
# }
# if(!is.null(input$fileContrast)){
# tmpRead = ReadContrastFile()
# CheckCont_new = CheckContrast(tmpRead,dds)
# if(!is.null(CheckCont_new$Warning)) info("test1")
# if(!is.null(CheckCont_new$Error)) info("test2")
# }
}
return(res)
})
......@@ -2459,23 +2585,23 @@ shinyServer(function(input, output,session) {
# Infobox model/target
# output$InfoModel<- renderInfoBox({
# res = infoBox(h6(strong("Target file and variables")),
# subtitle = h6(strong("Your target file must contain at least 2 columns and 2 rows. NA's values are not allowed and the variables must not be collinear.")),
# icon = icon("book"),color = "green",width=NULL,fill=TRUE)
#
# target = values$TargetWorking
# taxo = input$TaxoSelect
# ChTM = NULL
#
# ## Return NULL if there is no error
# if(!is.null(target)) ChTM = CheckTargetModel(input,target)
#
# if(!is.null(ChTM)) res = infoBox(h6(strong("Error")), subtitle = h6(ChTM), icon = icon("thumbs-o-down"),color = "red",width=NULL,fill=TRUE)
#
# return(res)
#
# })
# output$InfoModel<- renderInfoBox({
# res = infoBox(h6(strong("Target file and variables")),
# subtitle = h6(strong("Your target file must contain at least 2 columns and 2 rows. NA's values are not allowed and the variables must not be collinear.")),
# icon = icon("book"),color = "green",width=NULL,fill=TRUE)
#
# target = values$TargetWorking
# taxo = input$TaxoSelect
# ChTM = NULL
#
# ## Return NULL if there is no error
# if(!is.null(target)) ChTM = CheckTargetModel(input,target)
#
# if(!is.null(ChTM)) res = infoBox(h6(strong("Error")), subtitle = h6(ChTM), icon = icon("thumbs-o-down"),color = "red",width=NULL,fill=TRUE)
#
# return(res)
#
# })
output$InfoModel<- renderUI({
......@@ -3047,8 +3173,6 @@ shinyServer(function(input, output,session) {
if(!is.null(resDiff$dds) && length(input$VisuVarInt)>=1 )
if(input$NormOrRaw=="norm") withProgress(message="Loading...", Plot_Visu_Phylotree(input, resDiff, dataMergeCounts()$CT_Norm, taxo_table, treeseq))
else withProgress(message="Loading...", Plot_Visu_Phylotree(input, resDiff, dataMergeCounts()$CT_noNorm, taxo_table, treeseq))
})
......
......@@ -109,8 +109,8 @@ body <- dashboardBody(
tabPanel("Introduction",
p("First check out our user guide:"),
tags$ul(
tags$li(a("User's guide", href="Userguide.pdf")),
tags$li(a("Writing a target file for the experimental design", href="experimental_design_guide.pdf"))
tags$li(a("User's guide",target="_blank", href="Userguide.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"),
", which is available", a("here",target="_blank",href="Alimintest.zip"),"."),
......@@ -487,10 +487,20 @@ body <- dashboardBody(
fluidRow(
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"),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'",
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'",
......@@ -527,9 +537,15 @@ body <- dashboardBody(
)
),
conditionalPanel(condition="input.FileFormat=='projnum'",
uiOutput("Project_box_home")
),
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,
......
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