Commit b2b05954 authored by Amine  GHOZLANE's avatar Amine GHOZLANE
Browse files

Add epi2me support

parent 3fcf4e7f
Pipeline #48359 failed with stages
in 43 minutes and 52 seconds
......@@ -2,6 +2,7 @@
options(bitmapType='cairo')
if (!require("Rcpp")){
#RcppArmadillo_0.9.800.3.0
install.packages("Rcpp", repos="https://cran.univ-paris1.fr/")
}
# Limited shiny 1.3.2
......
......@@ -660,14 +660,14 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design)
if(0%in%colSums(counts_annot)){Error = "At least one of the column of the counts table is 0" }
else{
## Create the dds object
dds <- DESeqDataSetFromMatrix(countData=CT, colData=target, design=design,ignoreRank=TRUE)
dds <- DESeq2shaman::DESeqDataSetFromMatrix(countData=CT, colData=target, design=design,ignoreRank=TRUE)
#save(dds,file="testdds.RData")
if(is.null(VarNorm)){
## Counts normalisation
## Normalisation with or without 0
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=="NonNull" || RowProd==0) dds = DESeq2shaman::estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT))
if(input$AccountForNA=="All" && RowProd!=0) dds = DESeq2shaman::estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)))
if(input$AccountForNA=="Weighted" && input$AccountForNA!="NonNull" ) {dds = DESeq2shaman::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)
......@@ -684,16 +684,16 @@ GetCountsMerge <- function(input,dataInput,taxoSelect,target,design)
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)}
dds_tmp <- DESeq2shaman::DESeqDataSetFromMatrix(countData=CT_tmp, colData=target_tmp, design=~labels,ignoreRank=TRUE)
if(input$AccountForNA=="NonNull") {dds_tmp = DESeq2shaman::estimateSizeFactors(dds_tmp,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT_tmp)); normFactors[indgrp] = sizeFactors(dds_tmp)}
if(input$AccountForNA=="All") {dds_tmp = DESeq2shaman::estimateSizeFactors(dds_tmp,locfunc=eval(as.name(input$locfunc))); normFactors[indgrp] = sizeFactors(dds_tmp)}
if(input$AccountForNA=="Weighted" && input$AccountForNA!="NonNull" ) {dds_tmp = DESeq2shaman::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=="NonNull" || RowProd==0) dds = DESeq2shaman::estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)),geoMeans=GeoMeansCT(CT))
if(input$AccountForNA=="All" && RowProd!=0) dds = DESeq2shaman::estimateSizeFactors(dds,locfunc=eval(as.name(input$locfunc)))
if(input$AccountForNA=="Weighted" && input$AccountForNA!="NonNull" ) {dds = DESeq2shaman::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)
}
......
......@@ -31,7 +31,7 @@ shinyServer(function(input, output,session) {
json_name=json_name,num=0,pass=pass,login_email = NULL,is.valid =NULL,
biom_masque = NULL,tree_masque=NULL, masque_key = NULL, count_table_masque = NULL,
rdp_annot_masque = NULL, rdp_thres_masque = NULL,
paths_fastq_tmp=NULL,curdir=curdir, error_progress=FALSE, visTarget=FALSE)
paths_fastq_tmp=NULL,curdir=curdir, error_progress=FALSE, visTarget=FALSE, colors_diag=NULL)
## Counts file
dataInputCounts <-reactive({
......@@ -62,7 +62,7 @@ shinyServer(function(input, output,session) {
if(!TRUE%in%duplicated(data[,1])) rownames(data)=data[,1];data=data[,-1]
try(round(data, 0)->data, silent=T)
}
print(data)
return(as.data.frame(data))
})
......@@ -119,11 +119,32 @@ shinyServer(function(input, output,session) {
data=as.matrix(data)
indNa = which(data=="")
data[indNa]=NA
print(data)
return(as.data.frame(data))
})
## BIOM File
dataInputEpi2me <-reactive({
data = NULL
inFile <- input$fileEpi2me
if (!is.null(inFile) && is.null(values$biom_masque)){
tryCatch(read.csv(inFile$datapath,sep=input$sepepi2me,header=TRUE)->data,
#messageId="ErrorBiom1",
error=function(e) sendSweetAlert(session,
title = "Oops",
text=paste("Your file can not be read in SHAMAN.\n \n",e),type ="error"))
if(FALSE %in% c(c("accuracy", "barcode", "genus", "species") %in% colnames(data))){
data = NULL
sendSweetAlert(session, title = "Missing data",
text="Shaman looks for accuracy, barcode, genus and species colnames in Epi2me files\n \n",type ="error")
}
}
return(data)
})
## BIOM File
dataInputBiom <-reactive({
......@@ -284,6 +305,38 @@ shinyServer(function(input, output,session) {
}
}
if(input$FileFormat=="fileEpi2me")
{
tmpEpi2me = dataInputEpi2me()
if(!is.null(tmpEpi2me) && is.null(data))
{
tmpEpi2me = tmpEpi2me[which(tmpEpi2me$accuracy >= as.numeric(input$Epi2me_th) & !is.na(tmpEpi2me$barcode) ),]
tmp = plyr::count(tmpEpi2me,c("barcode", "genus", "species"))
tmp$ids = paste(tmp$genus, tmp$species, sep="|")
tmp$index = paste0("Seq_",match(tmp$ids, unique(tmp$ids)))
Counts = as.data.frame.matrix(t(xtabs(freq~.,tmp[,c("freq", "barcode","index")])))
Taxo = unique(tmp[,c("index", "genus", "species")])
rownames(Taxo) = Taxo$index
Taxo= Taxo[,c("genus","species")]
names(Taxo)=c("Genus","Specie")
if(!is.null(Counts) && !is.null(Taxo))
{
tmp = GetDataFromCT(Counts,Taxo, FALSE)
# print(tmp)
data = list(counts=tmp$counts,taxo=tmp$taxo, taxo_biom=tmp$taxo_biom)
## Remove row with only O
# data[["counts"]] = data[["counts"]][rowSums(data[["counts"]])>1,]
check = list(CheckCounts=tmp$CheckCounts,CheckTaxo=tmp$CheckTaxo,CheckPercent=tmp$CheckPercent)
# print(check)
percent = tmp$Percent
}
## Remove row with only O
# data[["counts"]] = data[["counts"]][rowSums(data[["counts"]])>1,]
}
}
if(input$FileFormat=="fileBiom")
{
......@@ -2365,7 +2418,25 @@ shinyServer(function(input, output,session) {
})
## Box for color selection
# output$BoxColors <- renderUI({
# input$addcoldiag
# print("Here doing nothing")
# #print( input$coldiag)
# #print(CPCOLS)
# # colors = input$coldiag
# # if(!is.null(colors)){
# # res=
# # }
# # return(res)
# values$colors_diag = c(values$colors_diag, input$coldiag)
# tagList(
# for ( i in 1:length(values$colors_diag)+1){
# #colourWidget(height = "35px",width = "35px",value = "white", allowTransparent = TRUE, showColour = "background", closeOnClick=TRUE)
# colourpicker::colourInput("coldiag", "Select colour", "purple", allowTransparent = TRUE, closeOnClick=TRUE, showColour = "background")
# }
# )
# })
### ###
##
......@@ -2979,6 +3050,21 @@ shinyServer(function(input, output,session) {
}
})
output$InfoEpi2me<- renderUI({
if(input$FileFormat=="fileEpi2me")
{
inFile <- input$fileEpi2me
tmpEpi2me = dataInputEpi2me()
if(!is.null(inFile) && is.null(tmpEpi2me)) {
toastr_error(title="Error",message=paste("<h5>","This file can not be loaded.","</h5>","<br/> <br/>","<em>The loaded file is not in the Epi2me format or its format is not currently supported by SHAMAN software.</em>"),
closeButton = TRUE,position ="bottom-right",preventDuplicates = TRUE,newestOnTop = TRUE,
progressBar = TRUE,showDuration = 300,showMethod="show",timeOut = 20000,extendedTimeOut = 2000)
}
}
})
output$InfoCountsFile<- renderUI({
......
......@@ -86,6 +86,7 @@ function(request) {
box(
title = "What's new in SHAMAN", width = NULL, status = "primary",
div(style = 'overflow-y: scroll; height: 550px',
addNews("Feburary 19th 2020","New feature","Shaman now support Epi2me data output. Let us know if you meet any issue."),
addNews("August 19th 2020","SHAMAN paper is out","We are really happy to announce that the paper describing in depth shaman and comparing this application to other available is out in BMC Bioinformatics. Moreover we keep improving the stability and functions of the application and we hope that we will be able to maintain this application for a long time."),
addNews("August 14th 2019","Major update","We performed a global improvement of SHAMAN. The application is now migrated to R 3.6.1. We implemented several visualization for differential analysis and network of abundance. We hope you will enjoy this new version."),
addNews("April 11th 2019","Debugging","We fixed few bugs in export system and scatterplot visualisation system."),
......@@ -520,7 +521,7 @@ function(request) {
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","Project number"="projnum"),selected="fileCounts"),
selectInput("FileFormat","",c("Count table & taxonomy (*.csv or *.tsv)"="fileCounts","BIOM file"="fileBiom","Epi2me file"="fileEpi2me","Project number"="projnum"),selected="fileCounts"),
conditionalPanel(condition="input.FileFormat=='fileCounts'",
checkboxInput("NoTaxoFile","No taxonomy table",value=FALSE),
selectInput("DemoDataset",h6(strong('Or select a dataset')),
......@@ -579,6 +580,18 @@ function(request) {
)
),
conditionalPanel(condition="input.FileFormat=='fileEpi2me'&&input.DemoDataset=='...'",
box(title="Load the Epi2me file",width = 3, status = "primary", solidHeader = TRUE,collapsible = FALSE,
column(width=6,
selectInput("sepepi2me", h6(strong("Separator:")), c("Semicolon" = ";", "Tab" = "\t", "Comma" = ","))),
column(width=6,
numericInput("Epi2me_th",h6(strong("Minimum accuracy level:")),70,step=0.5,min=1,max=100)),
column(width=12,
fileInput('fileEpi2me', h6(strong('Select your file')),width="100%",accept = c(".csv", ".tsv"))),
tags$script('$( "#fileEpi2me" ).on( "click", function() { this.value = null; });')
)
),
conditionalPanel(condition="input.FileFormat=='projnum'||input.DemoDataset!='...'",
uiOutput("Project_box_home")
),
......@@ -593,6 +606,7 @@ function(request) {
fluidRow(column(width=3,
uiOutput("InfoCountsFile"),
uiOutput("InfoTaxoFile"),
uiOutput("InfoEpi2me"),
uiOutput("InfoBIOM")
)
)
......@@ -688,7 +702,7 @@ function(request) {
fileInput('fileSizeFactors', h6(strong('Define your own size factors')),width="100%"),
tags$script('$( "#fileSizeFactors" ).on( "click", function() { this.value = null; });')
),
column(width=3, selectInput("sepsize", h6(strong("Separator:")), c("Tab" = "\t", "," = "Comma", "Semicolon" = ";"))),
column(width=3, selectInput("sepsize", h6(strong("Separator:")), c("Tab" = "\t", "Comma" = ",", "Semicolon" = ";"))),
column(width=3,br(),htmlOutput("InfoSizeFactor"))
)
),
......@@ -838,6 +852,10 @@ function(request) {
conditionalPanel(condition="input.modifwidthDiag",
sliderInput("widthDiag", "Width",min=100,max=2500,value = 800,step =10)),
selectInput("colorsdiag", label=h6(strong("Gradient of colors")),choices = c("shaman-palette1", "shaman-palette2"),selected = "shaman-palette1"),
#plotHelper(colours = c("red", "#123ABC")),
#fluidRow(
actionButton("addcoldiag",label=NULL, icon=icon('plus')), actionButton("delcoldiag",label=NULL,icon=icon('trash')), uiOutput("BoxColors"),
# ),
conditionalPanel(condition="input.DiagPlot=='clustPlot'",
h6(strong("Layout")),
selectInput("typeHculst", h6("Type"),c("Horizontal"="hori","Fan"="fan")),
......@@ -913,9 +931,9 @@ function(request) {
box(title = "Plot options", width = NULL, status = "primary", solidHeader = TRUE, collapsible = TRUE, collapsed = FALSE,
### _______both ####
h5(strong("Choose colours")),
fluidRow(column(width = 7, colourInput("colour1", NULL, value = "#008B00", showColour = "both")), column(width = 5, h6(strong("Down")), style='padding:0px;')),
fluidRow(column(width = 7, colourInput("colour2", NULL, value = "#999999", showColour = "both")), column(width = 5, h6(strong("Not significant")), style='padding:0px;')),
fluidRow(column(width = 7, colourInput("colour3", NULL, value = "#FF7F00", showColour = "both")), column(width = 5, h6(strong("Up")), style='padding:0px;')),
fluidRow(column(width = 7, colourpicker::colourInput("colour1", NULL, value = "#008B00", showColour = "both")), column(width = 5, h6(strong("Down")), style='padding:0px;')),
fluidRow(column(width = 7, colourpicker::colourInput("colour2", NULL, value = "#999999", showColour = "both")), column(width = 5, h6(strong("Not significant")), style='padding:0px;')),
fluidRow(column(width = 7, colourpicker::colourInput("colour3", NULL, value = "#FF7F00", showColour = "both")), column(width = 5, h6(strong("Up")), style='padding:0px;')),
### _______bar chart ####
conditionalPanel(condition = "input.tabBoxPlotTables == 'Bar chart'",
uiOutput("RadioButtonSelectedBarChart"),
......@@ -1204,19 +1222,19 @@ function(request) {
column(width=6,sliderInput("linkWidth", h6("Link width"),min=0,max=10,value = 1,step = 0.5))
),
fluidRow(
column(width=6,colourInput("edgeColorPositive", "Positive correlation", value = "red", showColour = "both")),
column(width=6,colourInput("edgeColorNegative", "Negative correlation", value = "blue", showColour = "both"))
column(width=6,colourpicker::colourInput("edgeColorPositive", "Positive correlation", value = "red", showColour = "both")),
column(width=6,colourpicker::colourInput("edgeColorNegative", "Negative correlation", value = "blue", showColour = "both"))
),
conditionalPanel(condition="!input.colorCorr",
fluidRow(column(width=7,colourInput("colorBackground", "Node color", value = "#BBBBBB", showColour = "both")),
column(width=5,colourInput("colorHighlightBackground", "if selected", value = "#BBBBBB", showColour = "both")))),
fluidRow(column(width=7,colourpicker::colourInput("colorBackground", "Node color", value = "#BBBBBB", showColour = "both")),
column(width=5,colourpicker::colourInput("colorHighlightBackground", "if selected", value = "#BBBBBB", showColour = "both")))),
conditionalPanel(condition="input.colorCorr",
selectInput("colorPalette", label=h6(strong("Gradient of colors")),choices = c("green-blue"="GnBu", "blue-white-red"="RdBu", "purple-white-orange"="PuOr", "red-yellow-green"="RdYlGn"),selected = "RdBu"),
checkboxInput("scaleFree", "Free scale")
),
fluidRow(
column(width=7,colourInput("colorBorder", "Node border", value = "#AAAAAA", showColour = "both")),
column(width=5,colourInput("colorHighlightBorder", "if selected", value = "#000000", showColour = "both"))
column(width=7,colourpicker::colourInput("colorBorder", "Node border", value = "#AAAAAA", showColour = "both")),
column(width=5,colourpicker::colourInput("colorHighlightBorder", "if selected", value = "#000000", showColour = "both"))
)
),
......@@ -1322,10 +1340,10 @@ function(request) {
## _______logit plot ####
conditionalPanel(condition="input.PlotVisuSelectComp=='LogitPlot'",
h5(strong("Choose colours")),
fluidRow(column(width = 7, colourInput("colour01", NULL, value = "#999999", showColour = "both")), column(width = 5, h6(strong("Not significant")), style='padding:0px;')),
fluidRow(column(width = 7, colourInput("colour02", NULL, value = "#1E90FF", showColour = "both")), column(width = 5, h6(strong("Significant for contrast 1")), style='padding:0px;')),
fluidRow(column(width = 7, colourInput("colour03", NULL, value = "#FF7F00", showColour = "both")), column(width = 5, h6(strong("Significant for contrast 2")), style='padding:0px;')),
fluidRow(column(width = 7, colourInput("colour04", NULL, value = "#008B00", showColour = "both")), column(width = 5, h6(strong("Significant for both contrasts")), style='padding:0px;')),
fluidRow(column(width = 7, colourpicker::colourInput("colour01", NULL, value = "#999999", showColour = "both")), column(width = 5, h6(strong("Not significant")), style='padding:0px;')),
fluidRow(column(width = 7, colourpicker::colourInput("colour02", NULL, value = "#1E90FF", showColour = "both")), column(width = 5, h6(strong("Significant for contrast 1")), style='padding:0px;')),
fluidRow(column(width = 7, colourpicker::colourInput("colour03", NULL, value = "#FF7F00", showColour = "both")), column(width = 5, h6(strong("Significant for contrast 2")), style='padding:0px;')),
fluidRow(column(width = 7, colourpicker::colourInput("colour04", NULL, value = "#008B00", showColour = "both")), column(width = 5, h6(strong("Significant for both contrasts")), style='padding:0px;')),
checkboxInput("showSignifThresholdsLogitPlot", "Show significance thresholds", TRUE),
checkboxInput("showDiagonal", "Show diagonal", TRUE),
conditionalPanel(condition="input.showSignifThresholdsLogitPlot || input.showDiagonal",
......
Markdown is supported
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