From 303fbc9e7e55efb1b34f734c62acb1ee6cfafeda Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Thu, 17 Aug 2023 09:25:23 +0200 Subject: [PATCH 01/17] add time before and after launching process and export --- server/process.R | 4 ++-- server/process_results.R | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/process.R b/server/process.R index a14b8ae4c..08bdbe9a4 100644 --- a/server/process.R +++ b/server/process.R @@ -324,7 +324,7 @@ shiny::observeEvent(input$process_launch, { print('############################################################') print('######################### PROCESS ##########################') print('############################################################') - + print(Sys.time()) param <- list(standard_study = input$process_standard_study) params <- list( project = input$project, @@ -615,7 +615,7 @@ shiny::observeEvent(input$process_launch, { shinyWidgets::closeSweetAlert(session) sweet_alert_error(e$message) }) - + print(Sys.time()) print('############################################################') print('######################### END PROCESS ######################') print('############################################################') diff --git a/server/process_results.R b/server/process_results.R index 3679bc7d5..6dc28ae69 100644 --- a/server/process_results.R +++ b/server/process_results.R @@ -425,6 +425,7 @@ shiny::observeEvent(input$process_results_download, { print('############################################################') print('###################### EXPORTATION #########################') print('############################################################') + print(Sys.time()) files <- project_samples()[which( project_samples()$project == input$project), "sample_id"] allDeconv <- deconvolution_params()[which( @@ -483,6 +484,7 @@ shiny::observeEvent(input$process_results_download, { } toastr_success("Exportation success !") + print(Sys.time()) print('############################################################') print('################### END OF EXPORTATION #####################') print('############################################################') From 3edde57a7db895b0bdcf4d7a2cf609823fb79f18 Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Fri, 18 Aug 2023 14:54:05 +0200 Subject: [PATCH 02/17] correction for family name in export (PCO, phase1 and 2) --- server/export_function.R | 225 +++++++++++++++++++++++++++------------ 1 file changed, 156 insertions(+), 69 deletions(-) diff --git a/server/export_function.R b/server/export_function.R index 39ece4a81..45dfb59c7 100644 --- a/server/export_function.R +++ b/server/export_function.R @@ -64,7 +64,7 @@ export_PCA <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, 1, paste("Comments"),startRow = 6, startCol = 2) openxlsx::writeData(wb, 1, paste("Creation date"),startRow = 7, startCol = 2) openxlsx::writeData(wb, 1, paste("Last modified"),startRow = 8, startCol = 2) - setColWidths(wb, sheet = 1, cols = 2, widths = 50) + setColWidths(wb, sheet = 1, cols = 2, widths = 55) openxlsx::writeData(wb, 1, user, startRow = 4, startCol = 3) openxlsx::writeData(wb, 1, project_informations$name, startRow = 5, startCol = 3) @@ -72,7 +72,7 @@ export_PCA <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, 1, project_informations$creation, startRow = 7, startCol = 3) openxlsx::writeData(wb, 1, project_informations$modified, startRow = 8, startCol = 3) addStyle(wb, sheet = 1, tableStyle, rows = 4:8, cols = 3) - setColWidths(wb, sheet = 1, cols = 3, widths = 50) + setColWidths(wb, sheet = 1, cols = 3, widths = 55) openxlsx::writeData(wb, 1, c("File"), startRow = 10, startCol = 2) openxlsx::writeData(wb, 1, c("Label"), startRow = 10, startCol = 3) @@ -222,7 +222,7 @@ export_PCA <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, 2, "time of duration", startCol = 3, startRow = 24) # surement à créer openxlsx::writeData(wb, 2, paste0(as.numeric(80),"%"), startCol = 3, startRow = 29) # pas compris openxlsx::writeData(wb, 2, as.numeric(2), startCol = 3, startRow = 30) # pas compris - setColWidths(wb, 2, cols = 3, widths = 50) + setColWidths(wb, 2, cols = 3, widths = 55) addStyle(wb, 2, sh2TableStyle, rows = c(5:9,12:13,16:19,22:24), cols = 3) addStyle(wb, 2, sh2EndTableStyle, rows = 29:30, cols = 3) @@ -272,9 +272,9 @@ export_PCA <- function(user, maxBar, chem_type, adducts, project_informations, p setColWidths(wb, sheet, cols = 1, widths = 4) openxlsx::writeData(wb, sheet, "File", startCol = 2, startRow = 5) - setColWidths(wb, sheet, cols = 2, widths = 50) + setColWidths(wb, sheet, cols = 2, widths = 55) openxlsx::writeData(wb, sheet, "Label", startCol = 3, startRow = 5) - setColWidths(wb, sheet, cols = 3, widths = 50) + setColWidths(wb, sheet, cols = 3, widths = 55) openxlsx::writeData(wb, sheet, "Adduct", startCol = 4, startRow = 5) setColWidths(wb, sheet, cols = 4, widths = 15) openxlsx::writeData(wb, sheet, "Total area", startCol = 5, startRow = 5) @@ -301,7 +301,7 @@ export_PCA <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, sheet, paste0("[",stdAdduct,"]"), startCol = 4, startRow = line) # Total area table <- get_standard_table(db, input$project, stdAdduct, s) - table <- table[which(table$sample_id == allFiles[which(allFiles$sample == smpl),"sample_id"]),] + table <- unique(table[which(table$sample_id == allFiles[which(allFiles$sample == smpl),"sample_id"]),]) addStyle(wb, sheet = sheet, bodyTableStyle, rows = line, cols = 2:8) # Is there noise ? Calculate with total area ABOVE baseline (script from home) if(is.na(table$'total area') || table$'total area' == 0){ @@ -350,11 +350,11 @@ export_PCA <- function(user, maxBar, chem_type, adducts, project_informations, p print("label sheet") ################################################################################ # Write the label's sheet(s) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) decParams <- deconvolution_params()[which(deconvolution_params()$chemical_type == chem),] decParams <- decParams[which(decParams$project == as.numeric(input$project)),] decParams <- decParams[which(decParams$adduct == adduct),] - for(file in allFiles$sample_id){ + for(file in unique(allFiles$sample_id)){ myActualFile <- allFiles[which(allFiles$sample_id == file),] # Create the sheet of the file label addWorksheet(wb = wb, sheetName = file, gridLines = FALSE) @@ -572,7 +572,7 @@ export_PCO <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, 1, paste("Comments"),startRow = 6, startCol = 2) openxlsx::writeData(wb, 1, paste("Creation date"),startRow = 7, startCol = 2) openxlsx::writeData(wb, 1, paste("Last modified"),startRow = 8, startCol = 2) - setColWidths(wb, sheet = 1, cols = 2, widths = 50) + setColWidths(wb, sheet = 1, cols = 2, widths = 55) openxlsx::writeData(wb, 1, user, startRow = 4, startCol = 3) openxlsx::writeData(wb, 1, project_informations$name, startRow = 5, startCol = 3) @@ -580,7 +580,7 @@ export_PCO <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, 1, project_informations$creation, startRow = 7, startCol = 3) openxlsx::writeData(wb, 1, project_informations$modified, startRow = 8, startCol = 3) addStyle(wb, sheet = 1, tableStyle, rows = 4:8, cols = 3) - setColWidths(wb, sheet = 1, cols = 3, widths = 50) + setColWidths(wb, sheet = 1, cols = 3, widths = 55) openxlsx::writeData(wb, 1, c("File"), startRow = 10, startCol = 2) openxlsx::writeData(wb, 1, c("Label"), startRow = 10, startCol = 3) @@ -594,7 +594,7 @@ export_PCO <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, 1, c("Original path"), startRow = 10, startCol = 9) addStyle(wb, sheet = 1, hTableStyle, rows = 10, cols = 2:9) setColWidths(wb, sheet = 1, cols = 9, widths = 100) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) line <- 11 for(smpl in allFiles$sample){ sample_info <- samples()[which(samples()$sample == smpl),] @@ -651,13 +651,46 @@ export_PCO <- function(user, maxBar, chem_type, adducts, project_informations, p # Peakwidth openxlsx::writeData(wb, 2, paste0(decParams$peakwidth_min," to ",decParams$peakwidth_max," s"), startCol = 3, startRow = 7) # Retention time - openxlsx::writeData(wb, 2, paste0(decParams$retention_time_min," to ",decParams$retention_time_max," min"), startCol = 3, startRow = 8) + if(length(unique(decParams$retention_time_min)) == 1 && length(unique(decParams$retention_time_max)) == 1){ + openxlsx::writeData(wb, 2, paste0(unique(decParams$retention_time_min)," to ",unique(decParams$retention_time_max)," min"), startCol = 3, startRow = 8) + }else{ + if(length(unique(decParams$retention_time_min)) == 1){ + for(max in 1:length(unique(decParams$retention_time_max))){ + my_rt <- paste0(unique(decParams$retention_time_min), " to (", unique(decParams$retention_time_max), ") min") + } + } + if(length(unique(decParams$retention_time_max)) == 1){ + for(min in 1:length(unique(decParams$retention_time_min))){ + my_rt <- paste0("(", unique(decParams$retention_time_min), ") to ", unique(decParams$retention_time_max), " min") + } + } + openxlsx::writeData(wb, 2, my_rt, startCol = 3, startRow = 8) + } # Missing scans - openxlsx::writeData(wb, 2, decParams$missing_scans, startCol = 3, startRow = 9) + if(length(unique(decParams$missing_scans)) == 1){ + openxlsx::writeData(wb, 2, unique(decParams$missing_scans), startCol = 3, startRow = 9) + }else{ + miss_scan <- paste(decParams$missing_scans) + openxlsx::writeData(wb, 2, miss_scan, startCol = 3, startRow = 9) + } # Chemical type - openxlsx::writeData(wb, 2, chem_type, startCol = 3, startRow = 12) + my_chemtype <- NULL + whichone <- rep(0, 3) + if(length(chem_type == 3)){ + my_chemtype <- "PCOs (mono, di, tri)" + }else if(length(chem_type) == 1){ + my_chemtype <- chem_type + }else{ + if(grep("PCOs", chem_type)) whichone[1] <- 1 + if(grep("di", chem_type)) whichone[2] <- 1 + if(grep("tri", chem_type)) whichone[3] <- 1 + if(whichone == c(1,1,0)) my_chemtype <- "PCOs (mono, di)" + if(whichone == c(1,0,1)) my_chemtype <- "PCOs (mono, tri)" + if(whichone == c(0,1,1)) my_chemtype <- "PCOs (di, tri)" + } + openxlsx::writeData(wb, 2, my_chemtype, startCol = 3, startRow = 12) # Adduct(s) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] if(unique(allSamples$polarity == "negative")){ openxlsx::writeData(wb, 2, paste0("[",adduct,"]-"), startCol = 3, startRow = 13) @@ -686,7 +719,7 @@ export_PCO <- function(user, maxBar, chem_type, adducts, project_informations, p } openxlsx::writeData(wb, 2, myStd, startCol = 3, startRow = 16) # Standard adduct(s) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] if(unique(allSamples$polarity == "negative")){ myStdAdduct <- NULL @@ -728,7 +761,7 @@ export_PCO <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, 2, "time of duration", startCol = 3, startRow = 24) # surement à créer openxlsx::writeData(wb, 2, paste0(as.numeric(80),"%"), startCol = 3, startRow = 29) # pas compris openxlsx::writeData(wb, 2, as.numeric(2), startCol = 3, startRow = 30) # pas compris - setColWidths(wb, 2, cols = 3, widths = 50) + setColWidths(wb, 2, cols = 3, widths = 55) addStyle(wb, 2, sh2TableStyle, rows = c(5:9,12:13,16:19,22:24), cols = 3) addStyle(wb, 2, sh2EndTableStyle, rows = 29:30, cols = 3) @@ -749,7 +782,7 @@ export_PCO <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, sheet, config$appname, startRow = 1) usedStd <- deconvolution_params()[which(deconvolution_params()$chemical_type == s),] openxlsx::writeData(wb, sheet, unique(usedStd$chemical_type), startRow = 2) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] if(unique(allSamples$polarity == "negative")){ myStdAdduct <- NULL @@ -778,9 +811,9 @@ export_PCO <- function(user, maxBar, chem_type, adducts, project_informations, p setColWidths(wb, sheet, cols = 1, widths = 4) openxlsx::writeData(wb, sheet, "File", startCol = 2, startRow = 5) - setColWidths(wb, sheet, cols = 2, widths = 50) + setColWidths(wb, sheet, cols = 2, widths = 55) openxlsx::writeData(wb, sheet, "Label", startCol = 3, startRow = 5) - setColWidths(wb, sheet, cols = 3, widths = 50) + setColWidths(wb, sheet, cols = 3, widths = 55) openxlsx::writeData(wb, sheet, "Adduct", startCol = 4, startRow = 5) setColWidths(wb, sheet, cols = 4, widths = 15) openxlsx::writeData(wb, sheet, "Total area", startCol = 5, startRow = 5) @@ -794,7 +827,7 @@ export_PCO <- function(user, maxBar, chem_type, adducts, project_informations, p addStyle(wb, sheet, hTableStyle, rows = 5, cols = 2:8) addStyle(wb, sheet, headerRightAlignStd, rows = 5, cols = c(5,7,8)) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) line <- 6 for(stdAdduct in unique(usedStd$adduct)){ for(smpl in allFiles$sample){ @@ -807,7 +840,7 @@ export_PCO <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, sheet, paste0("[",stdAdduct,"]"), startCol = 4, startRow = line) # Total area table <- get_standard_table(db, input$project, stdAdduct, s) - table <- table[which(table$sample_id == allFiles[which(allFiles$sample == smpl),"sample_id"]),] + table <- unique(table[which(table$sample_id == allFiles[which(allFiles$sample == smpl),"sample_id"]),]) addStyle(wb, sheet = sheet, bodyTableStyle, rows = line, cols = 2:8) if(is.na(table$'total area') || table$'total area' == 0){ openxlsx::writeData(wb, sheet, "Not detected", startCol = 5, startRow = line) @@ -853,11 +886,11 @@ export_PCO <- function(user, maxBar, chem_type, adducts, project_informations, p } ################################################################################ # Write the label's sheet(s) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) decParams <- myProjDeconv[which(myProjDeconv$adduct == adduct),] allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] - for(file in allFiles$sample_id){ + for(file in unique(allFiles$sample_id)){ myActualFile <- allFiles[which(allFiles$sample_id == file),] # Create the sheet of the file label addWorksheet(wb = wb, sheetName = file, gridLines = FALSE) @@ -1311,7 +1344,7 @@ export_PXA <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, 1, paste("Comments"),startRow = 6, startCol = 2) openxlsx::writeData(wb, 1, paste("Creation date"),startRow = 7, startCol = 2) openxlsx::writeData(wb, 1, paste("Last modified"),startRow = 8, startCol = 2) - setColWidths(wb, sheet = 1, cols = 2, widths = 50) + setColWidths(wb, sheet = 1, cols = 2, widths = 55) openxlsx::writeData(wb, 1, user, startRow = 4, startCol = 3) openxlsx::writeData(wb, 1, project_informations$name, startRow = 5, startCol = 3) @@ -1319,7 +1352,7 @@ export_PXA <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, 1, project_informations$creation, startRow = 7, startCol = 3) openxlsx::writeData(wb, 1, project_informations$modified, startRow = 8, startCol = 3) addStyle(wb, sheet = 1, tableStyle, rows = 4:8, cols = 3) - setColWidths(wb, sheet = 1, cols = 3, widths = 50) + setColWidths(wb, sheet = 1, cols = 3, widths = 55) openxlsx::writeData(wb, 1, c("File"), startRow = 10, startCol = 2) openxlsx::writeData(wb, 1, c("Label"), startRow = 10, startCol = 3) @@ -1333,7 +1366,7 @@ export_PXA <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, 1, c("Original path"), startRow = 10, startCol = 9) addStyle(wb, sheet = 1, hTableStyle, rows = 10, cols = 2:9) setColWidths(wb, sheet = 1, cols = 9, widths = 100) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) line <- 11 for(smpl in allFiles$sample){ sample_info <- samples()[which(samples()$sample == smpl),] @@ -1420,7 +1453,7 @@ export_PXA <- function(user, maxBar, chem_type, adducts, project_informations, p } openxlsx::writeData(wb, 2, paste0("PXAs (", saveChem, ")"), startCol = 3, startRow = 12) # Adduct(s) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] if(unique(allSamples$polarity == "negative")){ openxlsx::writeData(wb, 2, paste0("[",adduct,"]-"), startCol = 3, startRow = 13) @@ -1449,7 +1482,7 @@ export_PXA <- function(user, maxBar, chem_type, adducts, project_informations, p } openxlsx::writeData(wb, 2, myStd, startCol = 3, startRow = 16) # Standard adduct(s) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] if(unique(allSamples$polarity == "negative")){ myStdAdduct <- NULL @@ -1491,7 +1524,7 @@ export_PXA <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, 2, "time of duration", startCol = 3, startRow = 24) # surement à créer openxlsx::writeData(wb, 2, paste0(as.numeric(80),"%"), startCol = 3, startRow = 29) # pas compris openxlsx::writeData(wb, 2, as.numeric(2), startCol = 3, startRow = 30) # pas compris - setColWidths(wb, 2, cols = 3, widths = 50) + setColWidths(wb, 2, cols = 3, widths = 55) addStyle(wb, 2, sh2TableStyle, rows = c(5:9,12:13,16:19,22:24), cols = 3) addStyle(wb, 2, sh2EndTableStyle, rows = 29:30, cols = 3) @@ -1512,7 +1545,7 @@ export_PXA <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, sheet, config$appname, startRow = 1) usedStd <- deconvolution_params()[which(deconvolution_params()$chemical_type == s),] openxlsx::writeData(wb, sheet, unique(usedStd$chemical_type), startRow = 2) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] if(unique(allSamples$polarity == "negative")){ myStdAdduct <- NULL @@ -1541,9 +1574,9 @@ export_PXA <- function(user, maxBar, chem_type, adducts, project_informations, p setColWidths(wb, sheet, cols = 1, widths = 4) openxlsx::writeData(wb, sheet, "File", startCol = 2, startRow = 5) - setColWidths(wb, sheet, cols = 2, widths = 50) + setColWidths(wb, sheet, cols = 2, widths = 55) openxlsx::writeData(wb, sheet, "Label", startCol = 3, startRow = 5) - setColWidths(wb, sheet, cols = 3, widths = 50) + setColWidths(wb, sheet, cols = 3, widths = 55) openxlsx::writeData(wb, sheet, "Adduct", startCol = 4, startRow = 5) setColWidths(wb, sheet, cols = 4, widths = 15) openxlsx::writeData(wb, sheet, "Total area", startCol = 5, startRow = 5) @@ -1557,7 +1590,7 @@ export_PXA <- function(user, maxBar, chem_type, adducts, project_informations, p addStyle(wb, sheet, hTableStyle, rows = 5, cols = 2:8) addStyle(wb, sheet, headerRightAlignStd, rows = 5, cols = c(5,7,8)) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) line <- 6 for(stdAdduct in unique(usedStd$adduct)){ for(smpl in allFiles$sample){ @@ -1570,7 +1603,7 @@ export_PXA <- function(user, maxBar, chem_type, adducts, project_informations, p openxlsx::writeData(wb, sheet, paste0("[",stdAdduct,"]"), startCol = 4, startRow = line) # Total area table <- get_standard_table(db, input$project, stdAdduct, s) - table <- table[which(table$sample_id == allFiles[which(allFiles$sample == smpl),"sample_id"]),] + table <- unique(table[which(table$sample_id == allFiles[which(allFiles$sample == smpl),"sample_id"]),]) addStyle(wb, sheet = sheet, bodyTableStyle, rows = line, cols = 2:8) if(is.na(table$'total area') || table$'total area' == 0){ openxlsx::writeData(wb, sheet, "Not detected", startCol = 5, startRow = line) @@ -1617,12 +1650,12 @@ export_PXA <- function(user, maxBar, chem_type, adducts, project_informations, p ################################################################################ # Write the label's sheet(s) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) decParams <- deconvolution_params()[which(deconvolution_params()$chemical_type %in% chem_type),] decParams <- decParams[which(decParams$adduct == adduct),] allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] - for(file in allFiles$sample_id){ + for(file in unique(allFiles$sample_id)){ myActualFile <- allFiles[which(allFiles$sample_id == file),] # Create the sheet of the file label addWorksheet(wb = wb, sheetName = file, gridLines = FALSE) @@ -1855,7 +1888,7 @@ export_phase1 <- function(user, maxBar, chem_type, adducts, project_informations openxlsx::writeData(wb, 1, paste("Comments"),startRow = 6, startCol = 2) openxlsx::writeData(wb, 1, paste("Creation date"),startRow = 7, startCol = 2) openxlsx::writeData(wb, 1, paste("Last modified"),startRow = 8, startCol = 2) - setColWidths(wb, sheet = 1, cols = 2, widths = 50) + setColWidths(wb, sheet = 1, cols = 2, widths = 55) openxlsx::writeData(wb, 1, user, startRow = 4, startCol = 3) openxlsx::writeData(wb, 1, project_informations$name, startRow = 5, startCol = 3) @@ -1863,7 +1896,7 @@ export_phase1 <- function(user, maxBar, chem_type, adducts, project_informations openxlsx::writeData(wb, 1, project_informations$creation, startRow = 7, startCol = 3) openxlsx::writeData(wb, 1, project_informations$modified, startRow = 8, startCol = 3) addStyle(wb, sheet = 1, tableStyle, rows = 4:8, cols = 3) - setColWidths(wb, sheet = 1, cols = 3, widths = 50) + setColWidths(wb, sheet = 1, cols = 3, widths = 55) openxlsx::writeData(wb, 1, c("File"), startRow = 10, startCol = 2) openxlsx::writeData(wb, 1, c("Label"), startRow = 10, startCol = 3) @@ -1877,7 +1910,7 @@ export_phase1 <- function(user, maxBar, chem_type, adducts, project_informations openxlsx::writeData(wb, 1, c("Original path"), startRow = 10, startCol = 9) addStyle(wb, sheet = 1, hTableStyle, rows = 10, cols = 2:9) setColWidths(wb, sheet = 1, cols = 9, widths = 100) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) line <- 11 for(smpl in allFiles$sample){ sample_info <- samples()[which(samples()$sample == smpl),] @@ -1934,13 +1967,40 @@ export_phase1 <- function(user, maxBar, chem_type, adducts, project_informations # Peakwidth openxlsx::writeData(wb, 2, paste0(decParams$peakwidth_min," to ",decParams$peakwidth_max," s"), startCol = 3, startRow = 7) # Retention time - openxlsx::writeData(wb, 2, paste0(decParams$retention_time_min," to ",decParams$retention_time_max," min"), startCol = 3, startRow = 8) + if(length(unique(decParams$retention_time_min)) == 1 && length(unique(decParams$retention_time_max)) == 1){ + openxlsx::writeData(wb, 2, paste0(unique(decParams$retention_time_min)," to ",unique(decParams$retention_time_max)," min"), startCol = 3, startRow = 8) + }else{ + if(length(unique(decParams$retention_time_min)) == 1){ + for(max in 1:length(unique(decParams$retention_time_max))){ + my_rt <- paste0(unique(decParams$retention_time_min), " to (", unique(decParams$retention_time_max), ") min") + } + } + if(length(unique(decParams$retention_time_max)) == 1){ + for(min in 1:length(unique(decParams$retention_time_min))){ + my_rt <- paste0("(", unique(decParams$retention_time_min), ") to ", unique(decParams$retention_time_max), " min") + } + } + openxlsx::writeData(wb, 2, my_rt, startCol = 3, startRow = 8) + } # Missing scans - openxlsx::writeData(wb, 2, decParams$missing_scans, startCol = 3, startRow = 9) + if(length(unique(decParams$missing_scans)) == 1){ + openxlsx::writeData(wb, 2, unique(decParams$missing_scans), startCol = 3, startRow = 9) + }else{ + miss_scan <- paste(decParams$missing_scans) + openxlsx::writeData(wb, 2, miss_scan, startCol = 3, startRow = 9) + } # Chemical type - openxlsx::writeData(wb, 2, chem_type, startCol = 3, startRow = 12) + my_chemtype <- "Phase I metabolites (" + for(met in 1:length(chem_type)){ + if(met < length(chem_type)){ + my_chemtype <- paste0(my_chemtype, chem_type[met], ", ") + }else{ + my_chemtype <- paste0(my_chemtype, chem_type[met], ")") + } + } + openxlsx::writeData(wb, 2, my_chemtype, startCol = 3, startRow = 12) # Adduct(s) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] if(unique(allSamples$polarity == "negative")){ openxlsx::writeData(wb, 2, paste0("[",adduct,"]-"), startCol = 3, startRow = 13) @@ -1969,7 +2029,7 @@ export_phase1 <- function(user, maxBar, chem_type, adducts, project_informations } openxlsx::writeData(wb, 2, myStd, startCol = 3, startRow = 16) # Standard adduct(s) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] if(unique(allSamples$polarity == "negative")){ myStdAdduct <- NULL @@ -2011,7 +2071,7 @@ export_phase1 <- function(user, maxBar, chem_type, adducts, project_informations openxlsx::writeData(wb, 2, "time of duration", startCol = 3, startRow = 24) # surement à créer openxlsx::writeData(wb, 2, paste0(as.numeric(80),"%"), startCol = 3, startRow = 29) # pas compris openxlsx::writeData(wb, 2, as.numeric(2), startCol = 3, startRow = 30) # pas compris - setColWidths(wb, 2, cols = 3, widths = 50) + setColWidths(wb, 2, cols = 3, widths = 55) addStyle(wb, 2, sh2TableStyle, rows = c(5:9,12:13,16:19,22:24), cols = 3) addStyle(wb, 2, sh2EndTableStyle, rows = 29:30, cols = 3) @@ -2032,7 +2092,7 @@ export_phase1 <- function(user, maxBar, chem_type, adducts, project_informations openxlsx::writeData(wb, sheet, config$appname, startRow = 1) usedStd <- deconvolution_params()[which(deconvolution_params()$chemical_type == s),] openxlsx::writeData(wb, sheet, unique(usedStd$chemical_type), startRow = 2) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] if(unique(allSamples$polarity == "negative")){ myStdAdduct <- NULL @@ -2061,9 +2121,9 @@ export_phase1 <- function(user, maxBar, chem_type, adducts, project_informations setColWidths(wb, sheet, cols = 1, widths = 4) openxlsx::writeData(wb, sheet, "File", startCol = 2, startRow = 5) - setColWidths(wb, sheet, cols = 2, widths = 50) + setColWidths(wb, sheet, cols = 2, widths = 55) openxlsx::writeData(wb, sheet, "Label", startCol = 3, startRow = 5) - setColWidths(wb, sheet, cols = 3, widths = 50) + setColWidths(wb, sheet, cols = 3, widths = 55) openxlsx::writeData(wb, sheet, "Adduct", startCol = 4, startRow = 5) setColWidths(wb, sheet, cols = 4, widths = 15) openxlsx::writeData(wb, sheet, "Total area", startCol = 5, startRow = 5) @@ -2077,7 +2137,7 @@ export_phase1 <- function(user, maxBar, chem_type, adducts, project_informations addStyle(wb, sheet, hTableStyle, rows = 5, cols = 2:8) addStyle(wb, sheet, headerRightAlignStd, rows = 5, cols = c(5,7,8)) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) line <- 6 for(stdAdduct in unique(usedStd$adduct)){ for(smpl in allFiles$sample){ @@ -2090,7 +2150,7 @@ export_phase1 <- function(user, maxBar, chem_type, adducts, project_informations openxlsx::writeData(wb, sheet, paste0("[",stdAdduct,"]"), startCol = 4, startRow = line) # Total area table <- get_standard_table(db, input$project, stdAdduct, s) - table <- table[which(table$sample_id == allFiles[which(allFiles$sample == smpl),"sample_id"]),] + table <- unique(table[which(table$sample_id == allFiles[which(allFiles$sample == smpl),"sample_id"]),]) addStyle(wb, sheet = sheet, bodyTableStyle, rows = line, cols = 2:8) if(is.na(table$'total area') || table$'total area' == 0){ openxlsx::writeData(wb, sheet, "Not detected", startCol = 5, startRow = line) @@ -2136,11 +2196,11 @@ export_phase1 <- function(user, maxBar, chem_type, adducts, project_informations } ################################################################################ # Write the label's sheet(s) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) decParams <- myProjDeconv[which(myProjDeconv$adduct == adduct),] allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] - for(file in allFiles$sample_id){ + for(file in unique(allFiles$sample_id)){ myActualFile <- allFiles[which(allFiles$sample_id == file),] # Create the sheet of the file label addWorksheet(wb = wb, sheetName = file, gridLines = FALSE) @@ -2594,7 +2654,7 @@ export_phase2 <- function(user, maxBar, chem_type, adducts, project_informations openxlsx::writeData(wb, 1, paste("Comments"),startRow = 6, startCol = 2) openxlsx::writeData(wb, 1, paste("Creation date"),startRow = 7, startCol = 2) openxlsx::writeData(wb, 1, paste("Last modified"),startRow = 8, startCol = 2) - setColWidths(wb, sheet = 1, cols = 2, widths = 50) + setColWidths(wb, sheet = 1, cols = 2, widths = 55) openxlsx::writeData(wb, 1, user, startRow = 4, startCol = 3) openxlsx::writeData(wb, 1, project_informations$name, startRow = 5, startCol = 3) @@ -2602,7 +2662,7 @@ export_phase2 <- function(user, maxBar, chem_type, adducts, project_informations openxlsx::writeData(wb, 1, project_informations$creation, startRow = 7, startCol = 3) openxlsx::writeData(wb, 1, project_informations$modified, startRow = 8, startCol = 3) addStyle(wb, sheet = 1, tableStyle, rows = 4:8, cols = 3) - setColWidths(wb, sheet = 1, cols = 3, widths = 50) + setColWidths(wb, sheet = 1, cols = 3, widths = 55) openxlsx::writeData(wb, 1, c("File"), startRow = 10, startCol = 2) openxlsx::writeData(wb, 1, c("Label"), startRow = 10, startCol = 3) @@ -2616,7 +2676,7 @@ export_phase2 <- function(user, maxBar, chem_type, adducts, project_informations openxlsx::writeData(wb, 1, c("Original path"), startRow = 10, startCol = 9) addStyle(wb, sheet = 1, hTableStyle, rows = 10, cols = 2:9) setColWidths(wb, sheet = 1, cols = 9, widths = 100) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) line <- 11 for(smpl in allFiles$sample){ sample_info <- samples()[which(samples()$sample == smpl),] @@ -2673,13 +2733,40 @@ export_phase2 <- function(user, maxBar, chem_type, adducts, project_informations # Peakwidth openxlsx::writeData(wb, 2, paste0(decParams$peakwidth_min," to ",decParams$peakwidth_max," s"), startCol = 3, startRow = 7) # Retention time - openxlsx::writeData(wb, 2, paste0(decParams$retention_time_min," to ",decParams$retention_time_max," min"), startCol = 3, startRow = 8) + if(length(unique(decParams$retention_time_min)) == 1 && length(unique(decParams$retention_time_max)) == 1){ + openxlsx::writeData(wb, 2, paste0(unique(decParams$retention_time_min)," to ",unique(decParams$retention_time_max)," min"), startCol = 3, startRow = 8) + }else{ + if(length(unique(decParams$retention_time_min)) == 1){ + for(max in 1:length(unique(decParams$retention_time_max))){ + my_rt <- paste0(unique(decParams$retention_time_min), " to (", unique(decParams$retention_time_max), ") min") + } + } + if(length(unique(decParams$retention_time_max)) == 1){ + for(min in 1:length(unique(decParams$retention_time_min))){ + my_rt <- paste0("(", unique(decParams$retention_time_min), ") to ", unique(decParams$retention_time_max), " min") + } + } + openxlsx::writeData(wb, 2, my_rt, startCol = 3, startRow = 8) + } # Missing scans - openxlsx::writeData(wb, 2, decParams$missing_scans, startCol = 3, startRow = 9) + if(length(unique(decParams$missing_scans)) == 1){ + openxlsx::writeData(wb, 2, unique(decParams$missing_scans), startCol = 3, startRow = 9) + }else{ + miss_scan <- paste(decParams$missing_scans) + openxlsx::writeData(wb, 2, miss_scan, startCol = 3, startRow = 9) + } # Chemical type - openxlsx::writeData(wb, 2, chem_type, startCol = 3, startRow = 12) + my_chemtype <- "Phase II metabolites (" + for(met in 1:length(chem_type)){ + if(met < length(chem_type)){ + my_chemtype <- paste0(my_chemtype, chem_type[met], ", ") + }else{ + my_chemtype <- paste0(my_chemtype, chem_type[met], ")") + } + } + openxlsx::writeData(wb, 2, my_chemtype, startCol = 3, startRow = 12) # Adduct(s) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] if(unique(allSamples$polarity == "negative")){ openxlsx::writeData(wb, 2, paste0("[",adduct,"]-"), startCol = 3, startRow = 13) @@ -2708,7 +2795,7 @@ export_phase2 <- function(user, maxBar, chem_type, adducts, project_informations } openxlsx::writeData(wb, 2, myStd, startCol = 3, startRow = 16) # Standard adduct(s) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] if(unique(allSamples$polarity == "negative")){ myStdAdduct <- NULL @@ -2750,7 +2837,7 @@ export_phase2 <- function(user, maxBar, chem_type, adducts, project_informations openxlsx::writeData(wb, 2, "time of duration", startCol = 3, startRow = 24) # surement à créer openxlsx::writeData(wb, 2, paste0(as.numeric(80),"%"), startCol = 3, startRow = 29) # pas compris openxlsx::writeData(wb, 2, as.numeric(2), startCol = 3, startRow = 30) # pas compris - setColWidths(wb, 2, cols = 3, widths = 50) + setColWidths(wb, 2, cols = 3, widths = 55) addStyle(wb, 2, sh2TableStyle, rows = c(5:9,12:13,16:19,22:24), cols = 3) addStyle(wb, 2, sh2EndTableStyle, rows = 29:30, cols = 3) @@ -2771,7 +2858,7 @@ export_phase2 <- function(user, maxBar, chem_type, adducts, project_informations openxlsx::writeData(wb, sheet, config$appname, startRow = 1) usedStd <- deconvolution_params()[which(deconvolution_params()$chemical_type == s),] openxlsx::writeData(wb, sheet, unique(usedStd$chemical_type), startRow = 2) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] if(unique(allSamples$polarity == "negative")){ myStdAdduct <- NULL @@ -2800,9 +2887,9 @@ export_phase2 <- function(user, maxBar, chem_type, adducts, project_informations setColWidths(wb, sheet, cols = 1, widths = 4) openxlsx::writeData(wb, sheet, "File", startCol = 2, startRow = 5) - setColWidths(wb, sheet, cols = 2, widths = 50) + setColWidths(wb, sheet, cols = 2, widths = 55) openxlsx::writeData(wb, sheet, "Label", startCol = 3, startRow = 5) - setColWidths(wb, sheet, cols = 3, widths = 50) + setColWidths(wb, sheet, cols = 3, widths = 55) openxlsx::writeData(wb, sheet, "Adduct", startCol = 4, startRow = 5) setColWidths(wb, sheet, cols = 4, widths = 15) openxlsx::writeData(wb, sheet, "Total area", startCol = 5, startRow = 5) @@ -2816,7 +2903,7 @@ export_phase2 <- function(user, maxBar, chem_type, adducts, project_informations addStyle(wb, sheet, hTableStyle, rows = 5, cols = 2:8) addStyle(wb, sheet, headerRightAlignStd, rows = 5, cols = c(5,7,8)) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) line <- 6 for(stdAdduct in unique(usedStd$adduct)){ for(smpl in allFiles$sample){ @@ -2829,7 +2916,7 @@ export_phase2 <- function(user, maxBar, chem_type, adducts, project_informations openxlsx::writeData(wb, sheet, paste0("[",stdAdduct,"]"), startCol = 4, startRow = line) # Total area table <- get_standard_table(db, input$project, stdAdduct, s) - table <- table[which(table$sample_id == allFiles[which(allFiles$sample == smpl),"sample_id"]),] + table <- unique(table[which(table$sample_id == allFiles[which(allFiles$sample == smpl),"sample_id"]),]) addStyle(wb, sheet = sheet, bodyTableStyle, rows = line, cols = 2:8) if(is.na(table$'total area') || table$'total area' == 0){ openxlsx::writeData(wb, sheet, "Not detected", startCol = 5, startRow = line) @@ -2875,11 +2962,11 @@ export_phase2 <- function(user, maxBar, chem_type, adducts, project_informations } ################################################################################ # Write the label's sheet(s) - allFiles <- project_samples()[which(project_samples()$project == input$project),] + allFiles <- unique(project_samples()[which(project_samples()$project == input$project),]) decParams <- myProjDeconv[which(myProjDeconv$adduct == adduct),] allSamples <- samples()[which(samples()$sample %in% allFiles$sample),] - for(file in allFiles$sample_id){ + for(file in unique(allFiles$sample_id)){ myActualFile <- allFiles[which(allFiles$sample_id == file),] # Create the sheet of the file label addWorksheet(wb = wb, sheetName = file, gridLines = FALSE) From 51b7b05a1af59db5e32739c6e54405a9dc95f9e8 Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Tue, 22 Aug 2023 15:37:54 +0200 Subject: [PATCH 03/17] modify std rt in integration to named them with their std names --- server/process.R | 21 ++++++++++++++------- server/reactiveValues.R | 4 ++-- ui/process.R | 9 --------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/server/process.R b/server/process.R index 08bdbe9a4..ee021f5dc 100644 --- a/server/process.R +++ b/server/process.R @@ -178,19 +178,26 @@ output$ui_process_standard_adduct <- shiny::renderUI({ #' When more than one standard are chosen, will display a retention time input #' for each standard #' -#' @param standard_number reactive value number of standard chosen +#' @param standard_selected reactive value number of standard chosen output$process_standard_rt <- renderUI({ - standard <- standard_number() + standard <- standard_selected() print(standard) - ids <- sapply(1:standard, function(i){ + ids <- sapply(1:length(standard), function(i){ paste("process_standard_retention_time_", i, sep = "") }) print(ids) output <- tagList() - if(standard > 1){ - for(i in 2:standard){ + if(length(standard > 1)){ + for(i in 1:length(standard)){ output[[i]] <- tagList() - output[[i]][[1]] <- numericInput(ids[i], "Retention time", value = NA) + output[[i]][[1]] <- bsplus::shinyInput_label_embed( + shiny::numericInput(ids[i], paste0("Retention time (+/- 2 min) - ", standard[i]), value = NA), + bsplus::bs_embed_tooltip( + bsplus::shiny_iconlink(), + placement = 'top', + title = "Retention time to use for the standard study" + ) + ) } } output @@ -361,7 +368,7 @@ shiny::observeEvent(input$process_launch, { ppm = 0, mda = 0, peakwidth = c(input$process_peakwidth_min, input$process_peakwidth_max), retention_time = lapply(1:length(input$process_standard_type), function(i){ - rt <- eval(parse(text = paste("input$process_standard_retention_time_", i, sep = ""))) + rt <- eval(parse(text = paste0("input$process_standard_retention_time_", i))) }), missing_scans = input$process_missing_scans ) diff --git a/server/reactiveValues.R b/server/reactiveValues.R index c8b42174d..ff89e7e13 100644 --- a/server/reactiveValues.R +++ b/server/reactiveValues.R @@ -3,8 +3,8 @@ #' @description #' #' @param input$process_standard_formula string, standard formula -standard_number <- reactive({ - length(input$process_standard_type) +standard_selected <- reactive({ + input$process_standard_type }) #' @title Force reactualization of reactive values diff --git a/ui/process.R b/ui/process.R index 8e5ad92fc..90ada172e 100644 --- a/ui/process.R +++ b/ui/process.R @@ -161,15 +161,6 @@ shinydashboard::tabItem(tabName = 'process', shiny::tags$div(id = "process_standard_params", shiny::uiOutput("ui_process_standard_formula"), shiny::uiOutput("ui_process_standard_adduct"), - bsplus::shinyInput_label_embed( - shiny::numericInput("process_standard_retention_time_1", "Retention time +/- 2 (min)", - value = ""), - bsplus::bs_embed_tooltip( - bsplus::shiny_iconlink(), - placement = 'top', - title = "Retention time to use for the standard study" - ) - ), shiny::uiOutput("process_standard_rt") ) ) From 93a1ae27fc5ee30d9d8ef5bf0744542f3f44b7fb Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Wed, 23 Aug 2023 10:08:13 +0200 Subject: [PATCH 04/17] change colnames in database manage --- server/manage.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/manage.R b/server/manage.R index 6ed292e83..f2a63ae09 100644 --- a/server/manage.R +++ b/server/manage.R @@ -79,7 +79,7 @@ output$manage_table <- DT::renderDataTable({ data <- projects() data <- data[order(data$project, decreasing = TRUE), c("project", "name", "comments", "creation", "modified")] - colnames(data) <- c("Sequence", "Name", "Comments", "Creation", "Last modified") + colnames(data) <- c("Increment", "Name", "Comments", "Creation", "Last modified") data } else if (params$table_selected == "Sample") { data <- samples() @@ -95,7 +95,7 @@ output$manage_table <- DT::renderDataTable({ c("name", "instrument_model", "instrument_manufacturer", "ion_source", "analyzer", "detector_type", "resolution", "agc_target", "maximum_it", "number_of_scan_range", "scan_range")], as.factor) - colnames(data) <- c("Sample ID", "Sample", "Sequence", + colnames(data) <- c("Increment", "Label", "Sequence", "Size (Mo)", "Instrument model", "Instrument manufacturer", "Ion source", "Analyzer", "Detector type", "Resolution", "AGC target", "Maximum IT", "Number of scan range", "Scan range", "Original path") From 46bca812cb45ce60ad2eeea02d746b5dbd6d8a7a Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Wed, 23 Aug 2023 11:38:46 +0200 Subject: [PATCH 05/17] limit name of sequence to 50 characters --- server/project.R | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/server/project.R b/server/project.R index 6bb513f70..d7376f15c 100644 --- a/server/project.R +++ b/server/project.R @@ -15,15 +15,14 @@ shiny::observeEvent(input$project_create, { name = gsub('"', "'", input$project_name), comments = gsub('"', "'", input$project_comment)) print(params) - tryCatch({ - inputs <- c("project_name") - conditions <- c(params$name != "") - msgs <- c("A sequence name is required") - check_inputs(inputs, conditions, msgs) + inputs <- c("project_name", "project_name") + conditions <- c(params$name != "", nchar(params$name) < 51) + msgs <- c("A sequence name is required", "Name have to be less than 50 characters") + check_inputs(inputs, conditions, msgs) - record_project(db, params$name, params$comments) - toastr_success(paste('Sequence', params$name, 'created!')) + record_project(db, params$name, params$comments) + toastr_success(paste('Sequence', params$name, 'created!')) }, invalid = function(i) NULL , error = function(e){ print(e) From 4f7fe10f92063f5f3f492aea934e1077037c0e1f Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Wed, 23 Aug 2023 15:40:11 +0200 Subject: [PATCH 06/17] modification to export something even if we have no std --- server/process_results.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/process_results.R b/server/process_results.R index 6dc28ae69..69a9947f5 100644 --- a/server/process_results.R +++ b/server/process_results.R @@ -436,7 +436,9 @@ shiny::observeEvent(input$process_results_download, { family <- unique(db_get_query(db, "select chemical_type, chemical_familly from chemical")) # Merge our type and their family chem_type <- family[which(family$chemical_type %in% chem_type),] - chem_type <- chem_type[-which(chem_type$chemical_familly == "Standard"),] + if(length(grep("Standard", chem_type$chemical_familly)) > 0){ + chem_type <- chem_type[-which(chem_type$chemical_familly == "Standard"),] + } actual_user <- input$user actual_project_informations <- projects()[which( projects()$project == input$project),] From f51f12625376cf8aeab59dc03277783642703b2f Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Thu, 24 Aug 2023 14:00:53 +0200 Subject: [PATCH 07/17] correction of deviation calculation which is observed - theoric --- server/deconvolution.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/deconvolution.R b/server/deconvolution.R index 343063524..b95d514a3 100644 --- a/server/deconvolution.R +++ b/server/deconvolution.R @@ -592,7 +592,7 @@ deconvolution <- function(xr, theoric_patterns, chemical_ids, scalerange, scanra basepeak <- basepeaks[which.max(basepeaks$maxo),] peaks2 <- NULL scores <- c(theoric_patterns[[i]][1, "weight"]) - deviations <- c(theoric_patterns[[i]][1, "mz"] - basepeak[1, "mz"]) + deviations <- c(basepeak[1, "mz"] - theoric_patterns[[i]][1, "mz"]) weight <- c(theoric_patterns[[i]][1, "weight"]) continue_integration <- TRUE k <- 2 @@ -613,7 +613,7 @@ deconvolution <- function(xr, theoric_patterns, chemical_ids, scalerange, scanra theoric_patterns[[i]][k, "abundance"]) * theoric_patterns[[i]][k, "weight"]) deviations <- c(deviations, - theoric_patterns[[i]][k, "mz"] - peak[1, "mz"]) + peak[1, "mz"] - theoric_patterns[[i]][k, "mz"]) weight <- c(weight, theoric_patterns[[i]][k, "weight"]) peaks2 <- rbind(peaks2, peak) } else continue_integration <- FALSE @@ -711,7 +711,7 @@ deconvolution_std <- function(xr, theoric_patterns, chemical_ids = NA, scalerang theoric_patterns[[i]][k, "abundance"]) * theoric_patterns[[i]][k, "weight"]) deviations <- c(deviations, - theoric_patterns[[i]][k, "mz"] - peak[1, "mz"]) + peak[1, "mz"] - theoric_patterns[[i]][k, "mz"]) weight <- c(weight, theoric_patterns[[i]][k, "weight"]) peaks2 <- rbind(peaks2, peak) } else continue_integration <- FALSE From 5a3c849e7d174a351f09a24294a7f1cb0cb41712 Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Thu, 24 Aug 2023 16:13:18 +0200 Subject: [PATCH 08/17] add export menu in sidebar but not functional yet --- ui.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui.R b/ui.R index 569d49d04..9b4cffa90 100644 --- a/ui.R +++ b/ui.R @@ -64,7 +64,12 @@ sidebar <- shinydashboard::dashboardSidebar(collapsed = TRUE, disable = TRUE, shinydashboard::menuSubItem("Results", icon = shiny::icon("table"), tabName = "process_results"), shinydashboard::menuSubItem("TIC/EIC & MS", icon = shiny::icon("bar-chart-o"), tabName = "EIC"), shinydashboard::menuSubItem("Figures", icon = shiny::icon("bar-chart-o"), tabName = "graphics") - ) + ), + shinydashboard::menuItem("Generate Report", tabName = "sectors", icon = icon("download"), + radioButtons("export_format", "Document format", c("Excel", "CSV"),inline = FALSE, selected = 1), + shiny::actionButton("export_button", "Download Report", class = "butt"), + tags$head(tags$style(".butt{color: blue !important;}")) + ) ) ) From 409b67112b5fda0664442e7ab86bad5ecb7a4fad Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Thu, 24 Aug 2023 16:14:32 +0200 Subject: [PATCH 09/17] add exportation in Excel format and correction if no format choose --- server/process_results.R | 97 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/server/process_results.R b/server/process_results.R index 69a9947f5..c4257cdf0 100644 --- a/server/process_results.R +++ b/server/process_results.R @@ -493,6 +493,103 @@ shiny::observeEvent(input$process_results_download, { shinyWidgets::closeSweetAlert(session) }) +shiny::observeEvent(input$export_button,{ + print(input$export_format) + tryCatch({ + inputs <- c("export_format") + conditions <- c(!is.null(input$export_format)) + msgs <- c("Please select a format for exportation") + check_inputs(inputs, conditions, msgs) + + if(input$export_format == "Excel"){ + print('##################################################################') + print('###################### EXCEL EXPORTATION #########################') + print('##################################################################') + print(Sys.time()) + files <- project_samples()[which( + project_samples()$project == input$project), "sample_id"] + allDeconv <- deconvolution_params()[which( + deconvolution_params()$project == input$project),] + chem_type <- unique(deconvolution_params()[which( + deconvolution_params()$project == input$project), "chemical_type"]) + # Search for all families we have + family <- unique(db_get_query(db, "select chemical_type, chemical_familly from chemical")) + # Merge our type and their family + chem_type <- family[which(family$chemical_type %in% chem_type),] + if(length(grep("Standard", chem_type$chemical_familly)) > 0){ + chem_type <- chem_type[-which(chem_type$chemical_familly == "Standard"),] + } + actual_user <- input$user + actual_project_informations <- projects()[which( + projects()$project == input$project),] + pbValue <- 0 # When add unique is when we considered all chem type in one family + shinyWidgets::progressSweetAlert(session, 'exportBar', value = pbValue, title = "Exportation...", striped = TRUE, display_pct = TRUE) + if(length(c(grep("Chlorinated paraffins",chem_type$chemical_familly), grep("Brominated paraffins",chem_type$chemical_familly))) > 0){ + adducts <- deconvolution_params()[which( + deconvolution_params()$chemical_type %in% chem_type$chemical_type[c(grep("Chlorinated paraffins",chem_type$chemical_familly), grep("Brominated paraffins",chem_type$chemical_familly))]), ] + adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) + export_PCA(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[c(grep("Chlorinated paraffins",chem_type$chemical_familly), grep("Brominated paraffins",chem_type$chemical_familly)), "chemical_type"], + adducts = adducts, actual_project_informations, pbValue) + pbValue <- pbValue + length(allDeconv[c(grep("^PCAs",allDeconv$chemical_type), grep("^PBAs",allDeconv$chemical_type)),"adduct"]) + } + if(length(grep("Chlorinated olefins", chem_type$chemical_familly)) > 0){ + adducts <- deconvolution_params()[which( + deconvolution_params()$chemical_type %in% chem_type$chemical_type[grep("Chlorinated olefins",chem_type$chemical_familly)]), ] + adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) + export_PCO(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[grep("Chlorinated olefins",chem_type$chemical_familly), "chemical_type"], + adducts = adducts, actual_project_informations, pbValue) + pbValue <- pbValue + length(unique(allDeconv[grep("P.*Os",allDeconv$chemical_type),"adduct"])) + } + if(length(grep("Mixed paraffins",chem_type$chemical_familly)) > 0){ + adducts <- deconvolution_params()[which( + deconvolution_params()$chemical_type %in% chem_type$chemical_type[grep("Mixed paraffins",chem_type$chemical_familly)]), ] + adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) + export_PXA(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[grep("Mixed paraffins",chem_type$chemical_familly), "chemical_type"], + adducts = adducts, actual_project_informations, pbValue) + pbValue <- pbValue + length(unique(allDeconv[grep("PXAs",allDeconv$chemical_type),"adduct"])) + } + if(length(grep("Phase I metabolites", chem_type$chemical_familly)) > 0){ + adducts <- deconvolution_params()[which( + deconvolution_params()$chemical_type %in% chem_type$chemical_type[grep("Phase I metabolites",chem_type$chemical_familly)]), ] + adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) + export_phase1(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[grep("Phase I metabolites",chem_type$chemical_familly), "chemical_type"], + adducts = adducts, actual_project_informations, pbValue) + pbValue <- pbValue + length(unique(allDeconv[grep("-PCAs",allDeconv$chemical_type),"adduct"])) + } + if(length(grep("Phase II metabolites", chem_type$chemical_familly)) > 0){ + adducts <- deconvolution_params()[which( + deconvolution_params()$chemical_type %in% chem_type$chemical_type[grep("Phase I metabolites",chem_type$chemical_familly)]), ] + adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) + export_phase2(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[grep("Phase II metabolites",chem_type$chemical_familly), "chemical_type"], + adducts = adducts, actual_project_informations, pbValue) + pbValue <- pbValue + length(unique(allDeconv[grep("-OH-PCAs",allDeconv$chemical_type),"adduct"])) + } + + toastr_success("Exportation success !") + print(Sys.time()) + print('############################################################') + print('################### END OF EXPORTATION #####################') + print('############################################################') + shinyWidgets::closeSweetAlert(session) + }else if(input$export_format == "CSV"){ + print('##################################################################') + print('###################### EXCEL EXPORTATION #########################') + print('##################################################################') + print(Sys.time()) + + toastr_success("Exportation success !") + print(Sys.time()) + print('############################################################') + print('################### END OF EXPORTATION #####################') + print('############################################################') + shinyWidgets::closeSweetAlert(session) + } + }, invalid = function(i) NULL + , error = function(e){ + print(e) + sweet_alert_error("Cannot create sequence", e$message) + }) +}) #' @title Launch reintegration #' From e05541571f68648c927fd8480d1f5d7b9d3d6920 Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Thu, 24 Aug 2023 16:42:12 +0200 Subject: [PATCH 10/17] delete useless lines in export function --- server/export_function.R | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/server/export_function.R b/server/export_function.R index 45dfb59c7..dbfee0e2e 100644 --- a/server/export_function.R +++ b/server/export_function.R @@ -4,10 +4,6 @@ export_PCA <- function(user, maxBar, chem_type, adducts, project_informations, p # Template PCAs & PBAs library(openxlsx) #library(XLConnect) # for some more functions - query <- sprintf('select chemical_type, adduct from deconvolution_param where project == %s and - chemical_type in (select chemical_type from chemical where chemical_familly != "Standard");', - input$project) - chemicals <- db_get_query(db, query) for(chem in chem_type){ for(adduct in adducts){ shinyWidgets::updateProgressBar(session, id = "exportBar", @@ -507,10 +503,6 @@ export_PCA <- function(user, maxBar, chem_type, adducts, project_informations, p export_PCO <- function(user, maxBar, chem_type, adducts, project_informations, pbValue, output = ""){ library(openxlsx) #library(XLConnect) # for some more functions - query <- sprintf('select chemical_type, adduct from deconvolution_param where project == %s and - chemical_type in (select chemical_type from chemical where chemical_familly != "Standard");', - input$project) - chemicals <- db_get_query(db, query) allProj <- deconvolution_params()[which(deconvolution_params()$chemical_type %in% chem_type),] myProjDeconv <- allProj[which(allProj$project == project_informations$project),] for(adduct in adducts){ @@ -1279,10 +1271,6 @@ export_PCO <- function(user, maxBar, chem_type, adducts, project_informations, p export_PXA <- function(user, maxBar, chem_type, adducts, project_informations, pbValue, output = ""){ library(openxlsx) #library(XLConnect) # for some more functions - query <- sprintf('select chemical_type, adduct from deconvolution_param where project == %s and - chemical_type in (select chemical_type from chemical where chemical_familly != "Standard");', - input$project) - chemicals <- db_get_query(db, query) allProj <- deconvolution_params()[which(deconvolution_params()$chemical_type %in% chem_type),] myProjDeconv <- allProj[which(allProj$project == project_informations$project),] for(adduct in adducts){ @@ -1823,10 +1811,6 @@ export_PXA <- function(user, maxBar, chem_type, adducts, project_informations, p export_phase1 <- function(user, maxBar, chem_type, adducts, project_informations, pbValue, output = ""){ library(openxlsx) #library(XLConnect) # for some more functions - query <- sprintf('select chemical_type, adduct from deconvolution_param where project == %s and - chemical_type in (select chemical_type from chemical where chemical_familly != "Standard");', - input$project) - chemicals <- db_get_query(db, query) allProj <- deconvolution_params()[which(deconvolution_params()$chemical_type %in% chem_type),] myProjDeconv <- allProj[which(allProj$project == project_informations$project),] for(adduct in adducts){ @@ -2589,10 +2573,6 @@ export_phase1 <- function(user, maxBar, chem_type, adducts, project_informations export_phase2 <- function(user, maxBar, chem_type, adducts, project_informations, pbValue, output = ""){ library(openxlsx) #library(XLConnect) # for some more functions - query <- sprintf('select chemical_type, adduct from deconvolution_param where project == %s and - chemical_type in (select chemical_type from chemical where chemical_familly != "Standard");', - input$project) - chemicals <- db_get_query(db, query) allProj <- deconvolution_params()[which(deconvolution_params()$chemical_type %in% chem_type),] myProjDeconv <- allProj[which(allProj$project == project_informations$project),] for(adduct in adducts){ From 3254ffeb6521fd0914842efd0497ef588816d9ab Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Tue, 29 Aug 2023 09:02:41 +0200 Subject: [PATCH 11/17] correction calcul into with area --- server/deconvolution.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/deconvolution.R b/server/deconvolution.R index b95d514a3..6ae15c4f4 100644 --- a/server/deconvolution.R +++ b/server/deconvolution.R @@ -315,7 +315,7 @@ merge_peaks <- function(peaks, eic, baseline, noise){ rt = peaks[1, "rt"], rtmin = min(peaks[, "rtmin"]), rtmax = max(peaks[, "rtmax"]), - into = pracma::trapz(eic[lm[1]:lm[2], 'int']), + into = pracma::trapz(eic[lm[1]:lm[2], 'rt'], eic[lm[1]:lm[2], 'int']), intb = intb, maxo = max(peaks[, "maxo"]), sn = if (noise == 0) intb @@ -482,7 +482,7 @@ integrate2 <- function(eic, lm, baseline, noise, missing_scans, mzmat, scale = N rt = eic[center, 'rt'] / 60, rtmin = eic[lm[1], 'rt'] / 60, rtmax = eic[lm[2], 'rt'] / 60, - into = pracma::trapz(eic[lm[1]:lm[2], 'int']), + into = pracma::trapz(eic[lm[1]:lm[2], 'rt'], eic[lm[1]:lm[2], 'int']), intb = intb, maxo = max(mz_vals[, "int"]), sn = if (noise == 0) intb @@ -625,7 +625,7 @@ deconvolution <- function(xr, theoric_patterns, chemical_ids, scalerange, scanra score = sum(scores) * 100, deviation = mean(deviations) * 10**3, chemical_ion = chemical_ids[i], - intensities = length(traces)*sum(peaks2[,"maxo"])/k, + intensities = length(traces)*sum(peaks2[,"into"])/k, weighted_deviations = sum(deviations*weight)/sum(weight) )) } @@ -723,7 +723,7 @@ deconvolution_std <- function(xr, theoric_patterns, chemical_ids = NA, scalerang score = sum(scores) * 100, deviation = mean(deviations) * 10**3, chemical_ion = chemical_ids[i], - intensities = length(traces)*sum(peaks2[,"maxo"])/k, + intensities = length(traces)*sum(peaks2[,"into"])/k, weighted_deviations = sum(deviations*weight)/sum(weight) )) } From d459f58f635b3c9420a75cae28ef7d6e60f0b1aa Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Wed, 30 Aug 2023 11:07:49 +0200 Subject: [PATCH 12/17] changed intb calcul to add the x parameter of trapz, and some indentation --- server/deconvolution.R | 45 +++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/server/deconvolution.R b/server/deconvolution.R index 6ae15c4f4..fd31218bd 100644 --- a/server/deconvolution.R +++ b/server/deconvolution.R @@ -307,7 +307,6 @@ overlap_peaks <- function(peaks, eic, baseline, noise) { #' } merge_peaks <- function(peaks, eic, baseline, noise){ lm <- c(min(peaks$lmin), max(peaks$lmax)) - intb <- pracma::trapz(eic[lm[1]:lm[2], 'int'] - baseline[lm[1]:lm[2]]) new_peak <- data.frame( mz = peaks[1, "mz"], mzmin = min(peaks[, "mzmin"]), @@ -316,7 +315,7 @@ merge_peaks <- function(peaks, eic, baseline, noise){ rtmin = min(peaks[, "rtmin"]), rtmax = max(peaks[, "rtmax"]), into = pracma::trapz(eic[lm[1]:lm[2], 'rt'], eic[lm[1]:lm[2], 'int']), - intb = intb, + intb = pracma::trapz(eic[lm[1]:lm[2], 'rt'], eic[lm[1]:lm[2], 'int'] - baseline[lm[1]:lm[2]]), maxo = max(peaks[, "maxo"]), sn = if (noise == 0) intb else intb / pracma::trapz(rep(noise, diff(lm) + 1)), @@ -474,7 +473,6 @@ integrate2 <- function(eic, lm, baseline, noise, missing_scans, mzmat, scale = N mz <- do.call(xcms:::mzCenter.wMean, list( mz = mz_vals[, "mz"], intensity = mz_vals[, "int"])) - intb <- pracma::trapz(eic[lm[1]:lm[2], 'int'] - baseline[lm[1]:lm[2]]) data.frame( mz = mz, mzmin = mz_range[1], @@ -483,7 +481,7 @@ integrate2 <- function(eic, lm, baseline, noise, missing_scans, mzmat, scale = N rtmin = eic[lm[1], 'rt'] / 60, rtmax = eic[lm[2], 'rt'] / 60, into = pracma::trapz(eic[lm[1]:lm[2], 'rt'], eic[lm[1]:lm[2], 'int']), - intb = intb, + intb = pracma::trapz(eic[lm[1]:lm[2], 'rt'], eic[lm[1]:lm[2], 'int'] - baseline[lm[1]:lm[2]]), maxo = max(mz_vals[, "int"]), sn = if (noise == 0) intb else intb / pracma::trapz(rep(noise, diff(lm) + 1)), @@ -568,26 +566,23 @@ deconvolution <- function(xr, theoric_patterns, chemical_ids, scalerange, scanra lm <- c(roi[1] - traces[[1]]$eic[roi[1], "scan"] + 1, roi[2] - traces[[1]]$eic[roi[1], "scan"] + 1) basepeaks <- integrate2(traces[[1]]$eic[roi[1]:roi[2], ], lm, baselines[[1]][roi[1]:roi[2]], noises[1], missing_scans, - traces[[1]]$mzmat[which( - traces[[1]]$mzmat[, "scan"] %in% roi[1]:roi[2]) - , , drop = FALSE]) - } - else{ + traces[[1]]$mzmat[which(traces[[1]]$mzmat[, "scan"] %in% roi[1]:roi[2]), , drop = FALSE]) + }else{ # extend roi for better integration - roi <- range( - (if (min(roi) - extend_range < 1) 1 else min(roi) - extend_range) : - (if (max(roi) + extend_range > nrow(traces[[1]]$eic)) nrow(traces[[1]]$eic) else max(roi) + extend_range) - ) - basepeaks <- integrate(traces[[1]]$eic[roi[1]:roi[2], ], scalerange, - baselines[[1]][roi[1]:roi[2]], noises[1], missing_scans, - traces[[1]]$mzmat[which( - traces[[1]]$mzmat[, "scan"] %in% roi[1]:roi[2]) - , , drop = FALSE]) + roi <- range( + (if (min(roi) - extend_range < 1) 1 else min(roi) - extend_range) : + (if (max(roi) + extend_range > nrow(traces[[1]]$eic)) nrow(traces[[1]]$eic) else max(roi) + extend_range) + ) + basepeaks <- integrate(traces[[1]]$eic[roi[1]:roi[2], ], scalerange, + baselines[[1]][roi[1]:roi[2]], noises[1], missing_scans, + traces[[1]]$mzmat[which( + traces[[1]]$mzmat[, "scan"] %in% roi[1]:roi[2]) + , , drop = FALSE]) } if (length(basepeaks) == 0) next basepeaks <- cbind(basepeaks, abundance = 100, iso = "A") - if(is.vector(scanrange)) basepeaks <- basepeaks[(basepeaks$rt > scanrange[1] & basepeaks$rt < scanrange[2]),] + if(is.vector(scanrange)) basepeaks <- basepeaks[(basepeaks$rt > scanrange[1] & basepeaks$rt < scanrange[2]),] if(nrow(basepeaks) == 0) next basepeak <- basepeaks[which.max(basepeaks$maxo),] peaks2 <- NULL @@ -595,7 +590,7 @@ deconvolution <- function(xr, theoric_patterns, chemical_ids, scalerange, scanra deviations <- c(basepeak[1, "mz"] - theoric_patterns[[i]][1, "mz"]) weight <- c(theoric_patterns[[i]][1, "weight"]) continue_integration <- TRUE - k <- 2 + k <- 2 # To avoid iso = A while (k < length(traces) & continue_integration) { eic <- traces[[k]]$eic mzmat <- traces[[k]]$mzmat @@ -625,8 +620,8 @@ deconvolution <- function(xr, theoric_patterns, chemical_ids, scalerange, scanra score = sum(scores) * 100, deviation = mean(deviations) * 10**3, chemical_ion = chemical_ids[i], - intensities = length(traces)*sum(peaks2[,"into"])/k, - weighted_deviations = sum(deviations*weight)/sum(weight) + intensities = sum(peaks2[,"into"]), + weighted_deviations = sum(deviations*weight)/sum(weight) )) } @@ -685,7 +680,7 @@ deconvolution_std <- function(xr, theoric_patterns, chemical_ids = NA, scalerang if (length(basepeaks) == 0) next basepeaks <- cbind(basepeaks, abundance = 100, iso = "A") - if(is.vector(scanrange)) basepeaks <- basepeaks[(basepeaks$rt > scanrange[1] & basepeaks$rt < scanrange[2]),] + if(is.vector(scanrange)) basepeaks <- basepeaks[(basepeaks$rt > scanrange[1] & basepeaks$rt < scanrange[2]),] if(nrow(basepeaks) == 0) next basepeak <- basepeaks[which.max(basepeaks$maxo),] peaks2 <- NULL @@ -723,8 +718,8 @@ deconvolution_std <- function(xr, theoric_patterns, chemical_ids = NA, scalerang score = sum(scores) * 100, deviation = mean(deviations) * 10**3, chemical_ion = chemical_ids[i], - intensities = length(traces)*sum(peaks2[,"into"])/k, - weighted_deviations = sum(deviations*weight)/sum(weight) + intensities = sum(peaks2[,"into"]), + weighted_deviations = sum(deviations*weight)/sum(weight) )) } From 1e1520a57ab5441169b9c0d9bbadbf8b45d70a38 Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Wed, 30 Aug 2023 11:42:31 +0200 Subject: [PATCH 13/17] change cwt algo in msconvert because of integration problems with thermo data --- server/file.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/file.R b/server/file.R index daf08e089..387d43410 100644 --- a/server/file.R +++ b/server/file.R @@ -559,10 +559,10 @@ conversion <- function(db, project, sample_name, sample_id, filepath, filename, (grepl('raw$', filepath, ignore.case=TRUE) & !dir.exists(filepath)) | grepl('mzXML$', filepath, ignore.case=TRUE) | - grepl('mzML$', filepath, ignore.case=TRUE)) 'cwt' else 'vendor' + grepl('mzML$', filepath, ignore.case=TRUE)) 'vendor' #'cwt' else 'vendor' cwt only for waters but raw is also thermo # call msConvert - query <- sprintf("\"%s\" \"%s\" -o \"%s\" --outfile \"%s\" --mzXML --32 --zlib --filter \"peakPicking %s msLevel=1\" --filter \"polarity %s\"", + query <- sprintf("\"%s\" \"%s\" -o \"%s\" --outfile \"%s\" --mzXML --64 --zlib --filter \"peakPicking %s msLevel=1\" --filter \"polarity %s\"", converter, filepath, out_dir, out_filename, algorithm, polarity) print(query) msconvert_blabla <- system(query, intern = TRUE, wait = TRUE) From 7f882a752aed87369c2caca2e6b4e1b54b6ab700 Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Wed, 30 Aug 2023 11:43:53 +0200 Subject: [PATCH 14/17] restore intb variable because of bug but keep the good changes in calcul --- server/deconvolution.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/deconvolution.R b/server/deconvolution.R index fd31218bd..5935ce6df 100644 --- a/server/deconvolution.R +++ b/server/deconvolution.R @@ -307,6 +307,7 @@ overlap_peaks <- function(peaks, eic, baseline, noise) { #' } merge_peaks <- function(peaks, eic, baseline, noise){ lm <- c(min(peaks$lmin), max(peaks$lmax)) + intb <- pracma::trapz(eic[lm[1]:lm[2], 'rt'], eic[lm[1]:lm[2], 'int'] - baseline[lm[1]:lm[2]]) new_peak <- data.frame( mz = peaks[1, "mz"], mzmin = min(peaks[, "mzmin"]), @@ -315,7 +316,7 @@ merge_peaks <- function(peaks, eic, baseline, noise){ rtmin = min(peaks[, "rtmin"]), rtmax = max(peaks[, "rtmax"]), into = pracma::trapz(eic[lm[1]:lm[2], 'rt'], eic[lm[1]:lm[2], 'int']), - intb = pracma::trapz(eic[lm[1]:lm[2], 'rt'], eic[lm[1]:lm[2], 'int'] - baseline[lm[1]:lm[2]]), + intb = intb, maxo = max(peaks[, "maxo"]), sn = if (noise == 0) intb else intb / pracma::trapz(rep(noise, diff(lm) + 1)), @@ -473,6 +474,7 @@ integrate2 <- function(eic, lm, baseline, noise, missing_scans, mzmat, scale = N mz <- do.call(xcms:::mzCenter.wMean, list( mz = mz_vals[, "mz"], intensity = mz_vals[, "int"])) + intb <- pracma::trapz(eic[lm[1]:lm[2], 'rt'], eic[lm[1]:lm[2], 'int'] - baseline[lm[1]:lm[2]]) data.frame( mz = mz, mzmin = mz_range[1], @@ -481,7 +483,7 @@ integrate2 <- function(eic, lm, baseline, noise, missing_scans, mzmat, scale = N rtmin = eic[lm[1], 'rt'] / 60, rtmax = eic[lm[2], 'rt'] / 60, into = pracma::trapz(eic[lm[1]:lm[2], 'rt'], eic[lm[1]:lm[2], 'int']), - intb = pracma::trapz(eic[lm[1]:lm[2], 'rt'], eic[lm[1]:lm[2], 'int'] - baseline[lm[1]:lm[2]]), + intb = intb, maxo = max(mz_vals[, "int"]), sn = if (noise == 0) intb else intb / pracma::trapz(rep(noise, diff(lm) + 1)), From 46c0e2ae62870d25256ec44ab044538057149c66 Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Wed, 30 Aug 2023 11:55:24 +0200 Subject: [PATCH 15/17] delete export button from results and add it on the leftbar, disabled csv export and put excel export in the leftbar --- server/process_results.R | 214 ++++++++++++++++++++++----------------- ui/process_results.R | 6 +- 2 files changed, 123 insertions(+), 97 deletions(-) diff --git a/server/process_results.R b/server/process_results.R index c4257cdf0..5764efb8b 100644 --- a/server/process_results.R +++ b/server/process_results.R @@ -13,7 +13,7 @@ shiny::observeEvent(input$process_results_study, { shinyjs::hide("process_results_adduct") shinyjs::show("process_results_adduct2") shinyjs::hide("process_results_selected_matrix") - shinyjs::hide("process_results_download") + #shinyjs::hide("process_results_download") shinyjs::hide("process_results_deviation_max") shinyjs::hide("process_results_score_min") shinyjs::hide("process_results_apply") @@ -25,7 +25,7 @@ shiny::observeEvent(input$process_results_study, { shinyjs::show("process_results_adduct") shinyjs::hide("process_results_adduct2") shinyjs::show("process_results_selected_matrix") - shinyjs::show("process_results_download") + #shinyjs::show("process_results_download") shinyjs::show("process_results_deviation_max") shinyjs::show("process_results_score_min") shinyjs::show("process_results_apply") @@ -421,78 +421,84 @@ output$process_results_ms <- plotly::renderPlotly({ #' Will display a modal dialog for the selection of files to download #' #' @param input$project integer, project id -shiny::observeEvent(input$process_results_download, { - print('############################################################') - print('###################### EXPORTATION #########################') - print('############################################################') - print(Sys.time()) - files <- project_samples()[which( - project_samples()$project == input$project), "sample_id"] - allDeconv <- deconvolution_params()[which( - deconvolution_params()$project == input$project),] - chem_type <- unique(deconvolution_params()[which( - deconvolution_params()$project == input$project), "chemical_type"]) - # Search for all families we have - family <- unique(db_get_query(db, "select chemical_type, chemical_familly from chemical")) - # Merge our type and their family - chem_type <- family[which(family$chemical_type %in% chem_type),] - if(length(grep("Standard", chem_type$chemical_familly)) > 0){ - chem_type <- chem_type[-which(chem_type$chemical_familly == "Standard"),] - } - actual_user <- input$user - actual_project_informations <- projects()[which( - projects()$project == input$project),] - pbValue <- 0 # When add unique is when we considered all chem type in one family - shinyWidgets::progressSweetAlert(session, 'exportBar', value = pbValue, title = "Exportation...", striped = TRUE, display_pct = TRUE) - if(length(c(grep("Chlorinated paraffins",chem_type$chemical_familly), grep("Brominated paraffins",chem_type$chemical_familly))) > 0){ - adducts <- deconvolution_params()[which( - deconvolution_params()$chemical_type %in% chem_type$chemical_type[c(grep("Chlorinated paraffins",chem_type$chemical_familly), grep("Brominated paraffins",chem_type$chemical_familly))]), ] - adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) - export_PCA(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[c(grep("Chlorinated paraffins",chem_type$chemical_familly), grep("Brominated paraffins",chem_type$chemical_familly)), "chemical_type"], - adducts = adducts, actual_project_informations, pbValue) - pbValue <- pbValue + length(allDeconv[c(grep("^PCAs",allDeconv$chemical_type), grep("^PBAs",allDeconv$chemical_type)),"adduct"]) - } - if(length(grep("Chlorinated olefins", chem_type$chemical_familly)) > 0){ - adducts <- deconvolution_params()[which( - deconvolution_params()$chemical_type %in% chem_type$chemical_type[grep("Chlorinated olefins",chem_type$chemical_familly)]), ] - adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) - export_PCO(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[grep("Chlorinated olefins",chem_type$chemical_familly), "chemical_type"], - adducts = adducts, actual_project_informations, pbValue) - pbValue <- pbValue + length(unique(allDeconv[grep("P.*Os",allDeconv$chemical_type),"adduct"])) - } - if(length(grep("Mixed paraffins",chem_type$chemical_familly)) > 0){ - adducts <- deconvolution_params()[which( - deconvolution_params()$chemical_type %in% chem_type$chemical_type[grep("Mixed paraffins",chem_type$chemical_familly)]), ] - adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) - export_PXA(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[grep("Mixed paraffins",chem_type$chemical_familly), "chemical_type"], - adducts = adducts, actual_project_informations, pbValue) - pbValue <- pbValue + length(unique(allDeconv[grep("PXAs",allDeconv$chemical_type),"adduct"])) - } - if(length(grep("Phase I metabolites", chem_type$chemical_familly)) > 0){ - adducts <- deconvolution_params()[which( - deconvolution_params()$chemical_type %in% chem_type$chemical_type[grep("Phase I metabolites",chem_type$chemical_familly)]), ] - adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) - export_phase1(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[grep("Phase I metabolites",chem_type$chemical_familly), "chemical_type"], - adducts = adducts, actual_project_informations, pbValue) - pbValue <- pbValue + length(unique(allDeconv[grep("-PCAs",allDeconv$chemical_type),"adduct"])) - } - if(length(grep("Phase II metabolites", chem_type$chemical_familly)) > 0){ - adducts <- deconvolution_params()[which( - deconvolution_params()$chemical_type %in% chem_type$chemical_type[grep("Phase I metabolites",chem_type$chemical_familly)]), ] - adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) - export_phase2(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[grep("Phase II metabolites",chem_type$chemical_familly), "chemical_type"], - adducts = adducts, actual_project_informations, pbValue) - pbValue <- pbValue + length(unique(allDeconv[grep("-OH-PCAs",allDeconv$chemical_type),"adduct"])) - } +# shiny::observeEvent(input$process_results_download, { +# print('############################################################') +# print('###################### EXPORTATION #########################') +# print('############################################################') +# print(Sys.time()) +# files <- project_samples()[which( +# project_samples()$project == input$project), "sample_id"] +# allDeconv <- deconvolution_params()[which( +# deconvolution_params()$project == input$project),] +# chem_type <- unique(deconvolution_params()[which( +# deconvolution_params()$project == input$project), "chemical_type"]) +# # Search for all families we have +# family <- unique(db_get_query(db, "select chemical_type, chemical_familly from chemical")) +# # Merge our type and their family +# chem_type <- family[which(family$chemical_type %in% chem_type),] +# if(length(grep("Standard", chem_type$chemical_familly)) > 0){ +# chem_type <- chem_type[-which(chem_type$chemical_familly == "Standard"),] +# } +# actual_user <- input$user +# actual_project_informations <- projects()[which( +# projects()$project == input$project),] +# pbValue <- 0 # When add unique is when we considered all chem type in one family +# shinyWidgets::progressSweetAlert(session, 'exportBar', value = pbValue, title = "Exportation...", striped = TRUE, display_pct = TRUE) +# if(length(c(grep("Chlorinated paraffins",chem_type$chemical_familly), grep("Brominated paraffins",chem_type$chemical_familly))) > 0){ +# adducts <- deconvolution_params()[which( +# deconvolution_params()$chemical_type %in% chem_type$chemical_type[c(grep("Chlorinated paraffins",chem_type$chemical_familly), grep("Brominated paraffins",chem_type$chemical_familly))]), ] +# adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) +# export_PCA(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[c(grep("Chlorinated paraffins",chem_type$chemical_familly), grep("Brominated paraffins",chem_type$chemical_familly)), "chemical_type"], +# adducts = adducts, actual_project_informations, pbValue) +# pbValue <- pbValue + length(allDeconv[c(grep("^PCAs",allDeconv$chemical_type), grep("^PBAs",allDeconv$chemical_type)),"adduct"]) +# } +# if(length(grep("Chlorinated olefins", chem_type$chemical_familly)) > 0){ +# adducts <- deconvolution_params()[which( +# deconvolution_params()$chemical_type %in% chem_type$chemical_type[grep("Chlorinated olefins",chem_type$chemical_familly)]), ] +# adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) +# export_PCO(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[grep("Chlorinated olefins",chem_type$chemical_familly), "chemical_type"], +# adducts = adducts, actual_project_informations, pbValue) +# pbValue <- pbValue + length(unique(allDeconv[grep("P.*Os",allDeconv$chemical_type),"adduct"])) +# } +# if(length(grep("Mixed paraffins",chem_type$chemical_familly)) > 0){ +# adducts <- deconvolution_params()[which( +# deconvolution_params()$chemical_type %in% chem_type$chemical_type[grep("Mixed paraffins",chem_type$chemical_familly)]), ] +# adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) +# export_PXA(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[grep("Mixed paraffins",chem_type$chemical_familly), "chemical_type"], +# adducts = adducts, actual_project_informations, pbValue) +# pbValue <- pbValue + length(unique(allDeconv[grep("PXAs",allDeconv$chemical_type),"adduct"])) +# } +# if(length(grep("Phase I metabolites", chem_type$chemical_familly)) > 0){ +# adducts <- deconvolution_params()[which( +# deconvolution_params()$chemical_type %in% chem_type$chemical_type[grep("Phase I metabolites",chem_type$chemical_familly)]), ] +# adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) +# export_phase1(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[grep("Phase I metabolites",chem_type$chemical_familly), "chemical_type"], +# adducts = adducts, actual_project_informations, pbValue) +# pbValue <- pbValue + length(unique(allDeconv[grep("-PCAs",allDeconv$chemical_type),"adduct"])) +# } +# if(length(grep("Phase II metabolites", chem_type$chemical_familly)) > 0){ +# adducts <- deconvolution_params()[which( +# deconvolution_params()$chemical_type %in% chem_type$chemical_type[grep("Phase I metabolites",chem_type$chemical_familly)]), ] +# adducts <- unique(adducts[which(adducts$project == input$project), "adduct"]) +# export_phase2(actual_user, maxBar = length(unique(chem_type$chemical_familly))*length(adducts), chem_type = chem_type[grep("Phase II metabolites",chem_type$chemical_familly), "chemical_type"], +# adducts = adducts, actual_project_informations, pbValue) +# pbValue <- pbValue + length(unique(allDeconv[grep("-OH-PCAs",allDeconv$chemical_type),"adduct"])) +# } - toastr_success("Exportation success !") - print(Sys.time()) - print('############################################################') - print('################### END OF EXPORTATION #####################') - print('############################################################') - shinyWidgets::closeSweetAlert(session) -}) +# toastr_success("Exportation success !") +# print(Sys.time()) +# print('############################################################') +# print('################### END OF EXPORTATION #####################') +# print('############################################################') +# shinyWidgets::closeSweetAlert(session) +# }) +#' @title File selection for matrix downloading +#' +#' @description +#' Will display a modal dialog for the selection of files to download +#' +#' @param input$project integer, project id shiny::observeEvent(input$export_button,{ print(input$export_format) tryCatch({ @@ -501,27 +507,30 @@ shiny::observeEvent(input$export_button,{ msgs <- c("Please select a format for exportation") check_inputs(inputs, conditions, msgs) + # Variables for exportation + files <- project_samples()[which( + project_samples()$project == input$project), ] + allDeconv <- deconvolution_params()[which( + deconvolution_params()$project == input$project),] + chem_type <- unique(deconvolution_params()[which( + deconvolution_params()$project == input$project), "chemical_type"]) + # Search for all families we have + family <- unique(db_get_query(db, "select chemical_type, chemical_familly from chemical")) + # Merge our type and their family + chem_type <- family[which(family$chemical_type %in% chem_type),] + if(length(grep("Standard", chem_type$chemical_familly)) > 0){ + chem_type <- chem_type[-which(chem_type$chemical_familly == "Standard"),] + } + actual_user <- input$user + actual_project_informations <- projects()[which(projects()$project == input$project),] + + # Excel exportation if(input$export_format == "Excel"){ print('##################################################################') print('###################### EXCEL EXPORTATION #########################') print('##################################################################') print(Sys.time()) - files <- project_samples()[which( - project_samples()$project == input$project), "sample_id"] - allDeconv <- deconvolution_params()[which( - deconvolution_params()$project == input$project),] - chem_type <- unique(deconvolution_params()[which( - deconvolution_params()$project == input$project), "chemical_type"]) - # Search for all families we have - family <- unique(db_get_query(db, "select chemical_type, chemical_familly from chemical")) - # Merge our type and their family - chem_type <- family[which(family$chemical_type %in% chem_type),] - if(length(grep("Standard", chem_type$chemical_familly)) > 0){ - chem_type <- chem_type[-which(chem_type$chemical_familly == "Standard"),] - } - actual_user <- input$user - actual_project_informations <- projects()[which( - projects()$project == input$project),] + pbValue <- 0 # When add unique is when we considered all chem type in one family shinyWidgets::progressSweetAlert(session, 'exportBar', value = pbValue, title = "Exportation...", striped = TRUE, display_pct = TRUE) if(length(c(grep("Chlorinated paraffins",chem_type$chemical_familly), grep("Brominated paraffins",chem_type$chemical_familly))) > 0){ @@ -571,13 +580,30 @@ shiny::observeEvent(input$export_button,{ print('################### END OF EXPORTATION #####################') print('############################################################') shinyWidgets::closeSweetAlert(session) - }else if(input$export_format == "CSV"){ - print('##################################################################') - print('###################### EXCEL EXPORTATION #########################') - print('##################################################################') + } + + # CSV exportation + if(input$export_format == "CSV"){ + print('################################################################') + print('###################### CSV EXPORTATION #########################') + print('################################################################') print(Sys.time()) - toastr_success("Exportation success !") + toastr_error("WORK IN PROGRESS, NOT AVAILABLE YET") + + # pbValue <- 0 # When add unique is when we considered all chem type in one family + # shinyWidgets::progressSweetAlert(session, 'exportBar', value = pbValue, title = "Exportation...", striped = TRUE, display_pct = TRUE) + # browser() + # final_csv <- NULL + # for(r in 1:nrow(allDeconv)){ + # this_chem <- allDeconv[r, "chemical_type"] + # this_adduct <- allDeconv[r, "adduct"] + # for(file in files){ + + # } + # } + + #toastr_success("Exportation success !") print(Sys.time()) print('############################################################') print('################### END OF EXPORTATION #####################') @@ -587,7 +613,7 @@ shiny::observeEvent(input$export_button,{ }, invalid = function(i) NULL , error = function(e){ print(e) - sweet_alert_error("Cannot create sequence", e$message) + sweet_alert_error("Cannot export your results", e$message) }) }) diff --git a/ui/process_results.R b/ui/process_results.R index 314ae14b6..3c31ed83f 100644 --- a/ui/process_results.R +++ b/ui/process_results.R @@ -26,9 +26,9 @@ shinydashboard::tabItem(tabName = 'process_results', ) ), shinydashboard::box(width = 9, - shiny::column(width = 3, style = 'margin-top: 20px; margin-bottom: 20px;', - shiny::actionButton('process_results_download', 'Export matrix', - icon = shiny::icon("download")) + shiny::column(width = 3, style = 'margin-top: 20px; margin-bottom: 20px;'#, + # shiny::actionButton('process_results_download', 'Export matrix', + # icon = shiny::icon("download")) ), shiny::column(width = 2), shiny::column(width = 3, From 3645b32554d04fc93acc1acf9fb238b4e0134d5c Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Wed, 30 Aug 2023 12:11:56 +0200 Subject: [PATCH 16/17] language corrections --- server/file.R | 2 +- server/process_results.R | 24 ++++++++++++------------ ui.R | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/server/file.R b/server/file.R index 387d43410..8d29a218e 100644 --- a/server/file.R +++ b/server/file.R @@ -441,7 +441,7 @@ shiny::observeEvent(input$file_import_valid2, { shinyWidgets::updateProgressBar(session, id = 'pb', title = msg, value = round((i - 1) * 100 / length(params$filepaths))) - # Have to add the checking of the label given by user to not have multiple file labels with the same name => error in Excel exportation + # Have to add the checking of the label given by user to not have multiple file labels with the same name => error in Excel export # check if file already exists in database success[i] <- tryCatch({ diff --git a/server/process_results.R b/server/process_results.R index 5764efb8b..4b19123ec 100644 --- a/server/process_results.R +++ b/server/process_results.R @@ -504,10 +504,10 @@ shiny::observeEvent(input$export_button,{ tryCatch({ inputs <- c("export_format") conditions <- c(!is.null(input$export_format)) - msgs <- c("Please select a format for exportation") + msgs <- c("Please select a format for export") check_inputs(inputs, conditions, msgs) - # Variables for exportation + # Variables for export files <- project_samples()[which( project_samples()$project == input$project), ] allDeconv <- deconvolution_params()[which( @@ -524,15 +524,15 @@ shiny::observeEvent(input$export_button,{ actual_user <- input$user actual_project_informations <- projects()[which(projects()$project == input$project),] - # Excel exportation + # Excel export if(input$export_format == "Excel"){ print('##################################################################') - print('###################### EXCEL EXPORTATION #########################') + print('######################### EXCEL EXPORT ###########################') print('##################################################################') print(Sys.time()) pbValue <- 0 # When add unique is when we considered all chem type in one family - shinyWidgets::progressSweetAlert(session, 'exportBar', value = pbValue, title = "Exportation...", striped = TRUE, display_pct = TRUE) + shinyWidgets::progressSweetAlert(session, 'exportBar', value = pbValue, title = "Export...", striped = TRUE, display_pct = TRUE) if(length(c(grep("Chlorinated paraffins",chem_type$chemical_familly), grep("Brominated paraffins",chem_type$chemical_familly))) > 0){ adducts <- deconvolution_params()[which( deconvolution_params()$chemical_type %in% chem_type$chemical_type[c(grep("Chlorinated paraffins",chem_type$chemical_familly), grep("Brominated paraffins",chem_type$chemical_familly))]), ] @@ -574,25 +574,25 @@ shiny::observeEvent(input$export_button,{ pbValue <- pbValue + length(unique(allDeconv[grep("-OH-PCAs",allDeconv$chemical_type),"adduct"])) } - toastr_success("Exportation success !") + toastr_success("Export success !") print(Sys.time()) print('############################################################') - print('################### END OF EXPORTATION #####################') + print('###################### END OF EXPORT #######################') print('############################################################') shinyWidgets::closeSweetAlert(session) } - # CSV exportation + # CSV export if(input$export_format == "CSV"){ print('################################################################') - print('###################### CSV EXPORTATION #########################') + print('######################### CSV EXPORT ###########################') print('################################################################') print(Sys.time()) toastr_error("WORK IN PROGRESS, NOT AVAILABLE YET") # pbValue <- 0 # When add unique is when we considered all chem type in one family - # shinyWidgets::progressSweetAlert(session, 'exportBar', value = pbValue, title = "Exportation...", striped = TRUE, display_pct = TRUE) + # shinyWidgets::progressSweetAlert(session, 'exportBar', value = pbValue, title = "Export...", striped = TRUE, display_pct = TRUE) # browser() # final_csv <- NULL # for(r in 1:nrow(allDeconv)){ @@ -603,10 +603,10 @@ shiny::observeEvent(input$export_button,{ # } # } - #toastr_success("Exportation success !") + #toastr_success("Export success !") print(Sys.time()) print('############################################################') - print('################### END OF EXPORTATION #####################') + print('###################### END OF EXPORT #######################') print('############################################################') shinyWidgets::closeSweetAlert(session) } diff --git a/ui.R b/ui.R index 9b4cffa90..3cf30817c 100644 --- a/ui.R +++ b/ui.R @@ -65,9 +65,9 @@ sidebar <- shinydashboard::dashboardSidebar(collapsed = TRUE, disable = TRUE, shinydashboard::menuSubItem("TIC/EIC & MS", icon = shiny::icon("bar-chart-o"), tabName = "EIC"), shinydashboard::menuSubItem("Figures", icon = shiny::icon("bar-chart-o"), tabName = "graphics") ), - shinydashboard::menuItem("Generate Report", tabName = "sectors", icon = icon("download"), + shinydashboard::menuItem("Export Results", tabName = "sectors", icon = icon("download"), radioButtons("export_format", "Document format", c("Excel", "CSV"),inline = FALSE, selected = 1), - shiny::actionButton("export_button", "Download Report", class = "butt"), + shiny::actionButton("export_button", "Launch Report", class = "butt"), tags$head(tags$style(".butt{color: blue !important;}")) ) ) From b8957ad73de2522320fd3e16ad36e9e46e2cfbe4 Mon Sep 17 00:00:00 2001 From: jsaintvanne Date: Wed, 30 Aug 2023 14:13:17 +0200 Subject: [PATCH 17/17] change version number --- CPSeeker.iss | 2 +- utils/config.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CPSeeker.iss b/CPSeeker.iss index ac94240e9..d95419c2a 100644 --- a/CPSeeker.iss +++ b/CPSeeker.iss @@ -1,5 +1,5 @@ #define MyAppName "CPSeeker" -#define MyAppVersion "2.0.0" +#define MyAppVersion "2.1.0" #define MyAppExeName "CPSeeker.bat" [Setup] diff --git a/utils/config.cfg b/utils/config.cfg index 4f0febc60..90bc3936b 100644 --- a/utils/config.cfg +++ b/utils/config.cfg @@ -1,5 +1,5 @@ { - "appname": "CP-Seeker 2.0.0", + "appname": "CP-Seeker 2.1.0", "pkgs": { "jsonlite": ">=1.7.1", "RSQLite": ">=2.2.1",