Skip to content

Commit 2881aa4

Browse files
authored
fix(loadpage): switched file reads to data.table::fread (#208)
1 parent 3aae854 commit 2881aa4

12 files changed

Lines changed: 115 additions & 227 deletions

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ biocViews: ImmunoOncology, MassSpectrometry, Proteomics, Software, ShinyApps,
4242
BugReports: https://github.com/Vitek-Lab/MSstatsShiny/issues
4343
Encoding: UTF-8
4444
Roxygen: list(markdown = TRUE)
45-
RoxygenNote: 7.3.3
4645
Config/testthat/edition: 3
46+
Config/roxygen2/version: 8.0.0

NAMESPACE

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,6 @@ importFrom(tools,file_ext)
218218
importFrom(utils,capture.output)
219219
importFrom(utils,head)
220220
importFrom(utils,packageVersion)
221-
importFrom(utils,read.csv)
222-
importFrom(utils,read.delim)
223-
importFrom(utils,read.table)
224221
importFrom(utils,txtProgressBar)
225222
importFrom(utils,write.csv)
226223
importFrom(utils,write.table)

R/MSstatsShiny.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#' @importFrom MSstatsPTM dataProcessPlotsPTM groupComparisonPlotsPTM MaxQtoMSstatsPTMFormat PDtoMSstatsPTMFormat FragPipetoMSstatsPTMFormat SkylinetoMSstatsPTMFormat MetamorpheusToMSstatsPTMFormat SpectronauttoMSstatsPTMFormat
4040
#' @importFrom MSstatsBioNet exportNetworkToHTML deleteEdgeFromNetwork
4141
#' @importFrom MSstatsResponse futureExperimentSimulation run_tpr_simulation plot_tpr_power_curve calculateTurnoverRatios
42-
#' @importFrom utils capture.output head packageVersion read.csv read.delim write.csv
42+
#' @importFrom utils capture.output head packageVersion write.csv
4343
#' @importFrom stats aggregate
4444
#' @importFrom methods is
4545
#' @importFrom readxl read_excel

R/module-loadpage-server.R

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ loadpageServer <- function(id, parent_session, is_web_server = FALSE, app_templa
187187
ui_elements <- tagList(ui_elements, create_spectronaut_standard_ui(session$ns))
188188
}
189189

190-
tagList(ui_elements, create_separator_buttons(session$ns, "sep_specdata"))
190+
ui_elements
191191
})
192192

193193
output$spectronaut_turnover_ui <- renderUI({
@@ -305,7 +305,6 @@ loadpageServer <- function(id, parent_session, is_web_server = FALSE, app_templa
305305
# enable("proceed1")
306306
# })
307307

308-
# can remove separator is.null check because shiny by default assigns the first value as the default value for radiobutton
309308
observe({
310309
disable("proceed1")
311310
if(((input$BIO == "Protein") || (input$BIO == "Peptide"))) {
@@ -316,38 +315,37 @@ loadpageServer <- function(id, parent_session, is_web_server = FALSE, app_templa
316315
enable("proceed1")
317316
}
318317
} else if (input$filetype == "msstats") {
319-
if(!is.null(input$msstatsdata) && !is.null(input$sep_msstatsdata)) {
318+
if(!is.null(input$msstatsdata)) {
320319
enable("proceed1")
321320
}
322321
} else if (input$filetype == "sky") {
323-
print(input$sep_skylinedata)
324-
if(!is.null(input$skylinedata) && !is.null(input$sep_skylinedata)) { # && !is.null(input$annot)
322+
if(!is.null(input$skylinedata)) {
325323
enable("proceed1")
326324
}
327325
} else if (input$filetype == "maxq") {
328326
if(!is.null(input$evidence) && !is.null(input$pGroup)) { # && !is.null(input$annot1)
329327
enable("proceed1")
330328
}
331329
} else if (input$filetype == "prog" || input$filetype == "PD" || input$filetype == "open" || input$filetype == "phil" || input$filetype == "meta") {
332-
if(!is.null(input$data) && !is.null(input$sep_data)) { # && !is.null(input$annot)
330+
if(!is.null(input$data)) {
333331
enable("proceed1")
334332
}
335333
} else if (input$filetype == "openms") {
336-
if(!is.null(input$data) && !is.null(input$sep_data)) {
334+
if(!is.null(input$data)) {
337335
enable("proceed1")
338336
}
339337
} else if (input$filetype == "spec") {
340338
spec_regular_file_ok <- !isTRUE(input$big_file_spec) && !is.null(input$specdata)
341339
spec_big_file_ok <- isTRUE(input$big_file_spec) && length(local_big_file_path()) > 0
342-
if((spec_regular_file_ok || spec_big_file_ok) && !is.null(input$sep_specdata)) {
340+
if(spec_regular_file_ok || spec_big_file_ok) {
343341
enable("proceed1")
344342
}
345343
} else if (input$filetype == "ump") {
346344
if(!is.null(input$fragSummary) && !is.null(input$peptideSummary) && !is.null(input$protSummary)) { #&& !is.null(input$annot2)
347345
enable("proceed1")
348346
}
349347
} else if (input$filetype == "diann") {
350-
if(!is.null(input$dianndata) && !is.null(input$sep_dianndata)) { # && !is.null(input$annot)
348+
if(!is.null(input$dianndata)) {
351349
enable("proceed1")
352350
}
353351
}
@@ -362,29 +360,29 @@ loadpageServer <- function(id, parent_session, is_web_server = FALSE, app_templa
362360
enable("proceed1")
363361
}
364362
} else if (input$filetype == "PD") {
365-
if(!is.null(input$data) && !is.null(input$sep_data)) { # && !is.null(input$annot)
363+
if(!is.null(input$data)) {
366364
enable("proceed1")
367365
}
368366
} else if (input$filetype == "openms") {
369-
if(!is.null(input$data) && !is.null(input$sep_data)) {
367+
if(!is.null(input$data)) {
370368
enable("proceed1")
371369
}
372370
} else if (input$filetype == "spmin" || input$filetype == "phil") {
373-
if(!is.null(input$data) && !is.null(input$sep_data)) { # && !is.null(input$annot)
371+
if(!is.null(input$data)) {
374372
enable("proceed1")
375373
}
376374
}
377375
}
378376
}
379-
377+
380378
}
381379
else if ((input$BIO == "PTM")) {
382380
if (input$DDA_DIA == "LType" || input$DDA_DIA == "TMT") {
383381
if ((!is.null(input$filetype) && length(input$filetype) > 0)) {
384382
if (input$filetype == "sample") {
385383
enable("proceed1")
386384
} else if (input$filetype == "msstats") {
387-
if(!is.null(input$msstatsptmdata) && !is.null(input$sep_msstatsptmdata)) {
385+
if(!is.null(input$msstatsptmdata)) {
388386
enable("proceed1")
389387
}
390388
} else if (input$filetype == "sky" || input$filetype == "maxq" || input$filetype == "spec" || input$filetype == "PD" || input$filetype == "meta") {

R/module-loadpage-ui.R

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ create_standard_uploads <- function(ns) {
215215
condition = "(input['loadpage-filetype'] =='10col' || input['loadpage-filetype'] =='prog' || input['loadpage-filetype'] =='PD' || input['loadpage-filetype'] =='open'||
216216
input['loadpage-filetype'] =='openms' || input['loadpage-filetype'] =='spmin' || input['loadpage-filetype'] == 'phil' || input['loadpage-filetype'] == 'meta') && input['loadpage-BIO'] != 'PTM'",
217217
h4("4. Upload quantification dataset"),
218-
fileInput(ns('data'), "", multiple = FALSE, accept = NULL),
219-
create_separator_buttons(ns, "sep_data")
218+
fileInput(ns('data'), "", multiple = FALSE, accept = NULL)
220219
)
221220
}
222221

@@ -240,17 +239,15 @@ create_msstats_uploads <- function(ns) {
240239
conditionalPanel(
241240
condition = "input['loadpage-filetype'] == 'msstats' && (input['loadpage-BIO'] != 'PTM' && (input['loadpage-BIO'] != 'PTM' && input['loadpage-DDA_DIA'] != 'TMT'))",
242241
h4("4. Upload data in MSstats Format"),
243-
fileInput(ns('msstatsdata'), "", multiple = FALSE, accept = NULL),
244-
create_separator_buttons(ns, "sep_msstatsdata")
242+
fileInput(ns('msstatsdata'), "", multiple = FALSE, accept = NULL)
245243
),
246244

247245
# PTM MSstats format
248246
conditionalPanel(
249247
condition = "input['loadpage-filetype'] == 'msstats' && (input['loadpage-BIO'] == 'PTM' || (input['loadpage-BIO'] == 'PTM' && input['loadpage-DDA_DIA'] == 'TMT'))",
250248
h4("4. Upload PTM data in MSstats Format"),
251249
fileInput(ns('msstatsptmdata'), "", multiple = FALSE, accept = NULL),
252-
create_separator_buttons(ns, "sep_msstatsptmdata"),
253-
250+
254251
h4("5. (Optional) Upload unmodified data in MSstats Format"),
255252
fileInput(ns('unmod'), "", multiple = FALSE, accept = NULL),
256253
tags$br()
@@ -264,8 +261,7 @@ create_skyline_uploads <- function(ns) {
264261
conditionalPanel(
265262
condition = "input['loadpage-filetype'] == 'sky' && input['loadpage-BIO'] != 'PTM'",
266263
h4("4. Upload MSstats report from Skyline"),
267-
fileInput(ns('skylinedata'), "", multiple = FALSE, accept = NULL),
268-
create_separator_buttons(ns, "sep_skylinedata")
264+
fileInput(ns('skylinedata'), "", multiple = FALSE, accept = NULL)
269265
)
270266
}
271267

@@ -275,8 +271,7 @@ create_diann_uploads <- function(ns) {
275271
conditionalPanel(
276272
condition = "input['loadpage-filetype'] == 'diann' && input['loadpage-BIO'] != 'PTM'",
277273
h4("4. Upload MSstats report from DIANN"),
278-
fileInput(ns('dianndata'), "", multiple = FALSE, accept = NULL),
279-
create_separator_buttons(ns, "sep_dianndata")
274+
fileInput(ns('dianndata'), "", multiple = FALSE, accept = NULL)
280275
)
281276
}
282277

@@ -664,19 +659,3 @@ create_quality_filtering_options <- function(ns) {
664659
)
665660
)
666661
}
667-
668-
669-
#' Create column separator radio buttons
670-
#'
671-
#' @param ns Namespace function
672-
#' @param input_id ID for the radio button input
673-
#' @noRd
674-
create_separator_buttons <- function(ns, input_id) {
675-
radioButtons(ns(input_id),
676-
label = h5("Column separator in uploaded file", class = "icon-wrapper",
677-
icon("question-circle", lib = "font-awesome"),
678-
div("Choose how columns are separated in the uploaded file", class = "icon-tooltip")),
679-
c(Comma=",", Semicolon=";", Tab="\t", Pipe="|"),
680-
inline = TRUE
681-
)
682-
}

R/module-visualize-network-server.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ loadCsvData <- function(input, dataComparison) {
111111
}
112112
req(input$dataUpload)
113113
tryCatch({
114-
read.csv(input$dataUpload$datapath)
114+
data.table::fread(input$dataUpload$datapath)
115115
}, error = function(e) {
116116
showNotification(paste("Error reading file:", e$message), type = "error")
117117
return(NULL)
@@ -535,7 +535,7 @@ visualizeNetworkServer <- function(id, parent_session, dataComparison) {
535535
codes <- paste(codes, "library(MSstatsBioNet)\nlibrary(dplyr)\n\n", sep = "")
536536

537537
codes <- paste(codes, "# Read data\n", sep = "")
538-
codes <- paste(codes, "df <- read.csv(\"path/to/your/data.csv\")\n\n", sep = "")
538+
codes <- paste(codes, "df <- data.table::fread(\"path/to/your/data.csv\")\n\n", sep = "")
539539

540540
# Add label filtering if not default
541541
if (params$selectedLabel != "" && !is.null(params$selectedLabel)) {

R/plotting_funtions.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
#' @importFrom grDevices dev.off pdf
8383
#' @importFrom graphics image mtext par plot.new
8484
#' @importFrom stats dist hclust qt
85-
#' @importFrom utils read.table write.table
85+
#' @importFrom utils write.table
8686
#'
8787
#' @examples
8888
#' data("dia_skyline_model")
@@ -136,7 +136,7 @@ groupComparisonPlots2 = function(data=data,
136136
}
137137

138138
finalfile = lastfilename
139-
processout = as.matrix(read.table(finalfile, header=TRUE, sep="\t"))
139+
processout = as.matrix(data.table::fread(finalfile))
140140
}
141141

142142
processout = rbind(processout, as.matrix(c(" ", " ", "MSstats - groupComparisonPlots function", " "), ncol=1))

0 commit comments

Comments
 (0)