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

Add support of masque

parent 4f3f6d79
...@@ -4,3 +4,8 @@ ...@@ -4,3 +4,8 @@
.Rproj.user .Rproj.user
*.Rproj *.Rproj
*.json *.json
www/masque/doing/*
www/masque/todo/*
www/masque/done/*
www/masque/error/*
www/masque.png
\ No newline at end of file
options(download.file.method = 'wget') options(download.file.method = 'wget')
if (!require("Rcpp")){ if (!require("Rcpp")){
install.packages("Rcpp") install.packages("Rcpp", repos="http://cran.univ-paris1.fr/")
} }
if(!require(shiny)){ if(!require(shiny)){
install.packages("shiny") install.packages("shiny", repos="http://cran.univ-paris1.fr/")
library(shiny) library(shiny)
} }
if(!require(shinydashboard)){ if(!require(shinydashboard)){
...@@ -13,52 +13,52 @@ if(!require(shinydashboard)){ ...@@ -13,52 +13,52 @@ if(!require(shinydashboard)){
} }
if(!require(rjson)){ if(!require(rjson)){
install.packages('rjson') install.packages('rjson', repos="http://cran.univ-paris1.fr/")
library(rjson) library(rjson)
} }
if(!require(ape)){ if(!require(ape)){
install.packages('ape') install.packages('ape', repos="http://cran.univ-paris1.fr/")
library(ape) library(ape)
} }
if(!require(GUniFrac)){ if(!require(GUniFrac)){
install.packages('GUniFrac') install.packages('GUniFrac', repos="http://cran.univ-paris1.fr/")
library(GUniFrac) library(GUniFrac)
} }
if(!require(devtools)){ if(!require(devtools)){
install.packages('devtools') install.packages('devtools', repos="http://cran.univ-paris1.fr/")
library(devtools) library(devtools)
} }
if (!require(psych)) { if (!require(psych)) {
install.packages('psych') install.packages('psych', repos="http://cran.univ-paris1.fr/")
library(psych) library(psych)
} }
if (!require(ggplot2)) { if (!require(ggplot2)) {
install.packages('ggplot2') install.packages('ggplot2', repos="http://cran.univ-paris1.fr/")
library(ggplot2) library(ggplot2)
} }
if (!require(vegan)) { if (!require(vegan)) {
install.packages('vegan') install.packages('vegan', repos="http://cran.univ-paris1.fr/")
library(vegan) library(vegan)
} }
if (!require(dendextend)) { if (!require(dendextend)) {
install.packages('dendextend') install.packages('dendextend', repos="http://cran.univ-paris1.fr/")
library(dendextend) library(dendextend)
} }
if (!require(circlize)) { if (!require(circlize)) {
install.packages('circlize') install.packages('circlize', repos="http://cran.univ-paris1.fr/")
library(circlize) library(circlize)
} }
if (!require(devtools)) { if (!require(devtools)) {
install.packages('devtools') install.packages('devtools', repos="http://cran.univ-paris1.fr/")
library(devtools) library(devtools)
} }
if(!require(treeWeightD3)){ if(!require(treeWeightD3)){
...@@ -99,12 +99,12 @@ if (!require(genefilter)) { ...@@ -99,12 +99,12 @@ if (!require(genefilter)) {
} }
if (!require(googleVis)) { if (!require(googleVis)) {
install.packages('googleVis') install.packages('googleVis', repos="http://cran.univ-paris1.fr/")
suppressPackageStartupMessages(library(googleVis)) suppressPackageStartupMessages(library(googleVis))
} }
if (!require(shinyjs)) { if (!require(shinyjs)) {
install.packages('shinyjs') install.packages('shinyjs', repos="http://cran.univ-paris1.fr/")
library(shinyjs) library(shinyjs)
} }
...@@ -114,17 +114,17 @@ if(!require(d3vennR)){ ...@@ -114,17 +114,17 @@ if(!require(d3vennR)){
} }
if (!require(DT)) { if (!require(DT)) {
install.packages('DT') install.packages('DT', repos="http://cran.univ-paris1.fr/")
library(DT) library(DT)
} }
if (!require(RColorBrewer)) { if (!require(RColorBrewer)) {
install.packages('RColorBrewer') install.packages('RColorBrewer', repos="http://cran.univ-paris1.fr/")
library(RColorBrewer) library(RColorBrewer)
} }
if (!require(gplots)) { if (!require(gplots)) {
install.packages('gplots') install.packages('gplots', repos="http://cran.univ-paris1.fr/")
library(gplots) library(gplots)
} }
...@@ -135,22 +135,22 @@ if (!require(DESeq2)) { ...@@ -135,22 +135,22 @@ if (!require(DESeq2)) {
} }
if (!require(ade4)) { if (!require(ade4)) {
install.packages('ade4') install.packages('ade4', repos="http://cran.univ-paris1.fr/")
library(ade4) library(ade4)
} }
if (!require(scales)) { if (!require(scales)) {
install.packages('scales') install.packages('scales', repos="http://cran.univ-paris1.fr/")
library(scales) library(scales)
} }
if (!require(phytools)) { if (!require(phytools)) {
install.packages('phytools') install.packages('phytools', repos="http://cran.univ-paris1.fr/")
library(phytools) library(phytools)
} }
if(!require(philentropy)){ if(!require(philentropy)){
install.packages("philentropy") install.packages("philentropy", repos="http://cran.univ-paris1.fr/")
library(philentropy) library(philentropy)
} }
...@@ -170,44 +170,53 @@ if (!require("shinyWidgets")){ ...@@ -170,44 +170,53 @@ if (!require("shinyWidgets")){
} }
if (!require("sendmailR")){ if (!require("sendmailR")){
install.packages("sendmailR") install.packages("sendmailR", repos="http://cran.univ-paris1.fr/")
library(sendmailR) library(sendmailR)
} }
if (!require("shinyBS")){ if (!require("shinyBS")){
install.packages("shinyBS") install.packages("shinyBS", repos="http://cran.univ-paris1.fr/")
library(shinyBS) library(shinyBS)
} }
library(tools) library(tools)
if (!require("flexdashboard")){ if (!require("flexdashboard")){
install.packages("flexdashboard") install.packages("flexdashboard", repos="http://cran.univ-paris1.fr/")
library(flexdashboard) library(flexdashboard)
} }
if (!require("backports")){ if (!require("backports")){
install.packages("backports") install.packages("backports", repos="http://cran.univ-paris1.fr/")
library(backports) library(backports)
} }
if (!require("readr")){ if (!require("readr")){
install.packages("readr") install.packages("readr", repos="http://cran.univ-paris1.fr/")
library(readr) library(readr)
} }
if (!require("jsonlite")){ if (!require("jsonlite")){
install.packages("jsonlite") install.packages("jsonlite", repos="http://cran.univ-paris1.fr/")
library(jsonlite) library(jsonlite)
} }
if (!require("shinyFiles")){ if (!require("shinyFiles")){
install.packages("shinyFiles") install.packages("shinyFiles", repos="http://cran.univ-paris1.fr/")
library(shinyFiles) library(shinyFiles)
} }
if (!require("htmltools")){
install.packages("htmltools", repos="http://cran.univ-paris1.fr/")
library(htmltools)
}
# if (!require("V8")){
# install.packages("V8", repos="http://cran.univ-paris1.fr/")
# library(htmltools)
# }
# if(!require(plotly)){ # if(!require(plotly)){
# install.packages("plotly") # install.packages("plotly")
......
...@@ -294,7 +294,7 @@ CheckTreeFile <- function(tree) ...@@ -294,7 +294,7 @@ CheckTreeFile <- function(tree)
## Check Masque Input ## Check Masque Input
CheckMasque <- function(input,values) CheckMasque <- function(input, values, check_mail=FALSE)
{ {
Error = NULL Error = NULL
HowTo = NULL HowTo = NULL
...@@ -306,8 +306,9 @@ CheckMasque <- function(input,values) ...@@ -306,8 +306,9 @@ CheckMasque <- function(input,values)
# HowTo = "<h6><strong>Make sure that you have click the &laquo Get key &raquo button and that you have pasted the key sent by mail </strong></h6>" # HowTo = "<h6><strong>Make sure that you have click the &laquo Get key &raquo button and that you have pasted the key sent by mail </strong></h6>"
# } # }
# #
if(is.null(Error) && is.null(values$login_email)){ print(check_mail)
if(is.null(Error) && is.null(values$login_email) && check_mail){
print("fuck")
Error = "<h6><strong>Invalid key </strong></h6>"; Error = "<h6><strong>Invalid key </strong></h6>";
HowTo = "<h6><strong>Make sure that you have click the &laquo Get key &raquo button </strong></h6>" HowTo = "<h6><strong>Make sure that you have click the &laquo Get key &raquo button </strong></h6>"
} }
...@@ -352,12 +353,19 @@ CheckMasque <- function(input,values) ...@@ -352,12 +353,19 @@ CheckMasque <- function(input,values)
res = SamplesMasque(input,values) res = SamplesMasque(input,values)
if(length(res$samples)==0) { if(length(res$samples)==0) {
Error = "<h6><strong>0 sample detected</strong></h6>" Error = "<h6><strong>0 sample detected</strong></h6>"
if(input$PairedOrNot=='y') HowTo = '<h6><strong>Make sur that you click the &laquo Load &raquo button. <br /> Change the working directory and/or verify the pairs matching.</strong></h6>' if(input$PairedOrNot=='y') HowTo = '<h6><strong>Make sure that you click the &laquo Match &raquo button. <br /> Change the working directory and/or verify the pairs matching.</strong></h6>'
if(input$PairedOrNot=='n') HowTo = '<h6><strong>Make sur that you click the &laquo Load &raquo button. <br /> Change the working directory.</strong></h6>' if(input$PairedOrNot=='n') HowTo = '<h6><strong>Make sure that your samples have the correct extension (.fastq, .fq, .fastq.gz or .fq.gz). <br /> Change the working directory.</strong></h6>'
} }
} }
if(is.null(Error)) {
error_file = paste(values$curdir,"www","masque","error",paste('file',values$masque_key,"_error.txt",sep=""),sep= .Platform$file.sep)
if(file.exists(error_file)){
Error = "<h6><strong>An error happened during the workflow progress. Please check your email.</strong></h6>"
}
}
return(list(Error=Error,HowTo=HowTo)) return(list(Error=Error,HowTo=HowTo))
} }
...@@ -425,7 +433,8 @@ CreateJSON <- function(input,values){ ...@@ -425,7 +433,8 @@ CreateJSON <- function(input,values){
"host"=input$HostName, "host"=input$HostName,
"type"=input$DataTypeMasque, "type"=input$DataTypeMasque,
"mail"=values$login_email, "mail"=values$login_email,
"contaminant"= path_fasta "contaminant"= path_fasta,
"pattern_R1"= input$R1files
) )
df %>% jsonlite::toJSON() %>% write_lines(values$json_name) df %>% jsonlite::toJSON() %>% write_lines(values$json_name)
} }
......
Project_status <- function(masque_key,curdir){ Project_status <- function(masque_key,curdir){
passOK = FALSE;status = NULL;file = NULL passOK = FALSE;status = NULL;file = NULL
json_files = list.files(paste(curdir,"www","masque",sep= .Platform$file.sep),pattern = paste("file", masque_key, ".json", sep=""),recursive = TRUE)
json_files = list.files(paste(curdir,"www","masque",sep= .Platform$file.sep),pattern = "json",recursive = TRUE)
allpass = gsub(gsub(json_files,pattern = ".*file",replacement = ""),pattern = ".json",replacement = "") allpass = gsub(gsub(json_files,pattern = ".*file",replacement = ""),pattern = ".json",replacement = "")
if(length(allpass)>0){ if(length(allpass)>0){
passOK = any(masque_key==allpass) passOK = any(masque_key==allpass)
if(passOK){ if(passOK){
...@@ -15,6 +13,7 @@ Project_status <- function(masque_key,curdir){ ...@@ -15,6 +13,7 @@ Project_status <- function(masque_key,curdir){
} }
} }
# return(list(status=status,file=json_file,passOK=passOK))
return(list(status=status,file=file,passOK=passOK)) return(list(status=status,file=file,passOK=passOK))
} }
...@@ -22,6 +21,7 @@ Project_status <- function(masque_key,curdir){ ...@@ -22,6 +21,7 @@ Project_status <- function(masque_key,curdir){
Project_box_result <- function(masque_key,curdir){ Project_box_result <- function(masque_key,curdir){
res = NULL res = NULL
PS = Project_status(masque_key,curdir) PS = Project_status(masque_key,curdir)
...@@ -31,61 +31,96 @@ Project_box_result <- function(masque_key,curdir){ ...@@ -31,61 +31,96 @@ Project_box_result <- function(masque_key,curdir){
res = list() res = list()
json_file = PS$file json_file = PS$file
folder_name = paste('file',masque_key,sep="") folder_name = paste('file',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 ### Paste file name as folder
annot_process = paste(curdir,"www","masque","done",folder_name,"shaman_annotation_process.tsv",sep= .Platform$file.sep) annot_process = paste(curdir,"www","masque","done",folder_name,"shaman_process_annotation.tsv",sep= .Platform$file.sep)
## Waiting for file creation (max 3min) ## Waiting for file creation (max 3min)
start = Sys.time(); diff = 0 start = Sys.time(); diff = 0
while(!file.exists(annot_process) && diff<180){ while(!file.exists(annot_process) && diff<180){
annot_process = paste(curdir,"www","masque","done",folder_name,"shaman_annotation_process.tsv",sep= .Platform$file.sep) annot_process = paste(curdir,"www","masque","done",folder_name,"shaman_process_annotation.tsv",sep= .Platform$file.sep)
tmp = Sys.time() tmp = Sys.time()
diff = tmp-start diff = tmp-start
} }
if(file.exists(annot_process)) if(file.exists(annot_process))
{ {
ap = read.csv(annot_process,sep="\t") ap = read.csv(annot_process,sep="\t")
build_process = paste(curdir,"www","masque","done",folder_name,"shaman_annotation_process.tsv",sep= .Platform$file.sep) if(json_data[[1]]$type == "16S_18S") db_choices = c("Silva" = "silva","Greengenes" = "greengenes", "RDP"= "rdp")
else if(json_data[[1]]$type == "23S_28S") db_choices = c("Silva" = "silva","RDP"= "rdp")
else db_choices = c("Findley" = "findley", "Underhill"= "underhill", "Unite"= "unite", "RDP"= "rdp")
#build_process = paste(curdir,"www","masque","done",folder_name,"shaman_process_annotation.tsv",sep= .Platform$file.sep)
res[[1]] = fluidRow( res[[1]] = fluidRow(
HTML('<center><h1><strong>Your project is done !</strong></h1> <br/> <em><h4> Hereafter is a summary of the building and annotation processes</h4> </em><br/> </center>'), #HTML('<center><h1><strong>Your project is done !</strong></h1> <br/> <em><h4> Hereafter is a summary of the building and annotation processes</h4> </em><br/> </center>'),
HTML('<center><h1><strong>Your project is done !</strong></h1></center>'),
br(), br(),
column(width=5, column(width=4,
valueBox(ap$Count[1],tags$strong(tags$h5("Number of amplicons", style = "width: 70%;")), color = "light-blue",width=NULL,icon = uiOutput("amplicon_icon")), h3("OTU building process"),
valueBox(ap$Count[2],tags$strong(tags$h5("Remaining amplicons after dereplication", style = "width: 70%;")), color = "light-blue",width=NULL,icon = uiOutput("dereplication_icon")), shinydashboard::valueBox(ap$Count[1],tags$strong(tags$h5("Number of amplicons", style = "width: 70%;")), color = "light-blue", width = NULL, icon = uiOutput("amplicon_icon")),
valueBox(ap$Count[3],tags$strong(tags$h5("Remaining amplicons after removing singletons", style = "width: 70%;")), color = "light-blue",width=NULL,icon = uiOutput("singleton_icon")), shinydashboard::valueBox(ap$Count[2],tags$strong(tags$h5("Remaining amplicons after dereplication", style = "width: 70%;")), color = "light-blue", width = NULL,icon = uiOutput("dereplication_icon")),
valueBox(ap$Count[4],tags$strong(tags$h5("Remaining amplicons after removing chimera", style = "width: 70%;")), color = "light-blue",width=NULL,icon = uiOutput("chimera_icon")) shinydashboard::valueBox(ap$Count[3],tags$strong(tags$h5("Remaining amplicons after removing singletons", style = "width: 70%;")), color = "light-blue", width = NULL,icon = uiOutput("singleton_icon")),
), shinydashboard::valueBox(ap$Count[4],tags$strong(tags$h5("Remaining amplicons after removing chimera", style = "width: 70%;")), color = "light-blue", width = NULL,icon = uiOutput("chimera_icon")),
column(width=5,offset = 2, shinydashboard::valueBox(ap$Count[5],tags$strong(tags$h5("Number of OTU", style = "width: 70%;")), color = "light-blue", width = NULL,icon = uiOutput("otu_icon"))
box(title="Upload the results",width = NULL, background = "light-blue",
selectInput("masque_database","Select the database",choices=c("Silva" = "silva","Greengenes" = "greengenes")),
tags$style(type='text/css', "#masque-database { width:100%; margin-top: 5px;}"),
actionButton("RunResMasque",label = "Upload the results",icon=icon('upload')),
tags$style(type='text/css', "#RunResMasque { width:100%; margin-top: 15px;}")
), ),
#column(width=5, div(img(src = "masque.png",width = "50%",height = "20%"))),
box(id="box-zip",title="Download .zip file",width = NULL, status = "success", if(json_data[[1]]$type == "16S_18S"){
downloadButton('Download_masque_zip', 'Download the results'), column(width=5,
tags$style(type='text/css', "#Download_masque_zip { width:100%; margin-top: 15px;}") strong(h3("16S/18S annotation process")),
) shinydashboard::valueBox(ap$Count[6],tags$strong(tags$h5("Number of OTU annotated by SILVA", style = "width: 70%;")), color = "light-blue", width = NULL,icon = uiOutput("silva_icon")),
shinydashboard::valueBox(ap$Count[7],tags$strong(tags$h5("Number of OTU annotated by Greengenes", style = "width: 70%;")), color = "light-blue", width = NULL,icon = uiOutput("greengenes_icon")),
shinydashboard::valueBox(ap$Count[8],tags$strong(tags$h5("Number of OTU annotated by RDP", style = "width: 70%;")), color = "light-blue", width = NULL,icon = uiOutput("rdp_icon"))
) )
}
) else if(json_data[[1]]$type == "23S_28S"){
column(width=5,
strong(h3("23S/28S annotation process")),
} else{res =HTML('<center><h1><strong>Your project is done !</strong></h1> <br/> <em><h4> Hereafter is a summary of the building and annotation processes</h4> </em> </center>')} shinydashboard::valueBox(ap$Count[6],tags$strong(tags$h5("Number of OTU annotated by SILVA", style = "width: 70%;")), color = "light-blue", width = NULL,icon = uiOutput("silva_icon")),
shinydashboard::valueBox(ap$Count[7],tags$strong(tags$h5("Number of OTU annotated by RDP", style = "width: 70%;")), color = "light-blue", width = NULL,icon = uiOutput("rdp_icon"))
)
}
else{
column(width=5,
strong(h3("ITS annotation process")),
shinydashboard::valueBox(ap$Count[6],tags$strong(tags$h5("Number of OTU annotated by Unite", style = "width: 70%;")), color = "light-blue", width = NULL,icon = uiOutput("unite_icon")),
shinydashboard::valueBox(ap$Count[7],tags$strong(tags$h5("Number of OTU annotated by Findley", style = "width: 70%;")), color = "light-blue", width = NULL,icon = uiOutput("findley_icon")),
shinydashboard::valueBox(ap$Count[8],tags$strong(tags$h5("Number of OTU annotated by Underhill", style = "width: 70%;")), color = "light-blue", width = NULL,icon = uiOutput("underhill_icon")),
shinydashboard::valueBox(ap$Count[9],tags$strong(tags$h5("Number of OTU annotated by RDP", style = "width: 70%;")), color = "light-blue", width = NULL,icon = uiOutput("rdp_icon"))
)
},
#offset = 4,
column(width=3,
strong(h3("Start statistical analysis")),
box(title="Load the results",width = NULL, background = "light-blue",
selectInput("masque_db","Select the database",choices=db_choices),
conditionalPanel(condition="input.masque_db=='rdp'",numericInput("rdp_thres",h6(strong("Threshold:")),0.5,step=0.01,min=0.01,max=1)),
actionButton("LoadResMasque", "Upload the results",icon=icon('upload')),
tags$style(type='text/css', "#LoadResMasque { width:100%; }"),
receiveSweetAlert(messageId = "LoadResMasque")
),
#shinydashboard::box(title="Upload the results",width = NULL, background = "light-blue",
#selectInput("masque_database","Select the database",choices=c("Silva" = "silva","Greengenes" = "greengenes", "MARDE"="merde")),
#tags$style(type='text/css', "#masque_database { width:100%; margin-top: 5px;}"),
#actionButton("RunResMasque",label = "Upload the results",icon=icon('upload')),
#tags$style(type='text/css', "#RunResMasque { width:100%; margin-top: 15px;}")
#),
#receiveSweetAlert(messageId = "WTF2"),
box(id="box-zip",title="Download .zip file",width = NULL, status = "success",
downloadButton('Download_masque_zip', 'Download the results'),
tags$style(type='text/css', "#Download_masque_zip { width:100%;}")
)
)
)
} else{res =HTML('<center><h1><strong>Your project is done !</strong></h1> <br/> <em><h4>Result can not be shown...</h4> </em> </center>')}
build_process = paste(curdir,"www","masque","done",folder_name,"shaman_build_process.tsv",sep= .Platform$file.sep) build_process = paste(curdir,"www","masque","done",folder_name,"shaman_process_build.tsv",sep= .Platform$file.sep)
if(file.exists(build_process)) if(file.exists(build_process))
{ {
ap = read.csv(build_process,sep="\t") ap = read.csv(build_process,sep="\t")
res[[2]] = fluidRow(column(width=12,strong(h3("Building process table")),DT::dataTableOutput("build_process_table"))) res[[2]] = fluidRow(column(width=12,strong(h3("Detailed process table")),DT::dataTableOutput("build_process_table")))
} }
...@@ -96,23 +131,26 @@ Project_box_result <- function(masque_key,curdir){ ...@@ -96,23 +131,26 @@ Project_box_result <- function(masque_key,curdir){
HTML('<center><h1><strong>Your project is currently running !</strong></h1> <br/> <br/> </center>'), HTML('<center><h1><strong>Your project is currently running !</strong></h1> <br/> <br/> </center>'),
inlineCSS(gaugeCSS), inlineCSS(gaugeCSS),
gaugeOutput("gaugeMasque_progress", width = "100%", height = "100%") gaugeOutput("gaugeMasque_progress", width = "100%", height = "100%")
#jscode <- "shinyjs.refresh = function() { history.go(0); }",
#useShinyjs(),
#extendShinyjs(text = jscode),
) )
} }
if(PS$status=="error"){ if(PS$status=="error"){
error_message = "Failed" error_message = "Failed"
json_file = PS$file json_file = PS$file