Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ Authors@R: c(
License: Artistic-2.0
Depends: R (>= 4.2)
Imports: shiny, shinyBS, shinyjs, shinybusy, dplyr, ggplot2, plotly, data.table, Hmisc, shinyFiles,
MSstats,MSstatsBig, MSstatsTMT, MSstatsPTM, MSstatsConvert, gplots, marray, DT, readxl,
MSstats, MSstatsTMT, MSstatsPTM, MSstatsConvert, gplots, marray, DT, readxl,
ggrepel, uuid, utils, stats, htmltools, methods, tidyr, grDevices, graphics, mockery, MSstatsBioNet,
shinydashboard, arrow, tools, MSstatsResponse
Suggests:
Suggests:
MSstatsBig,
rmarkdown,
tinytest,
sessioninfo,
Expand Down
111 changes: 84 additions & 27 deletions R/module-loadpage-server.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,37 @@ loadpageServer <- function(id, parent_session, is_web_server = FALSE) {
# Define volumes for the file selection.
if (!is_web_server) {
volumes <- shinyFiles::getVolumes()()

# Server-side logic for the shinyFiles button
shinyFiles::shinyFileChoose(input, "big_file_browse", roots = volumes, session = session)

# Reactive to parse and store the full file information (path, name, etc.)
# This is efficient because parseFilePaths is only called once.
local_file_info <- reactive({
req(is.list(input$big_file_browse))
shinyFiles::parseFilePaths(volumes, input$big_file_browse)
})

# Reactive to get just the full datapath, for use in backend processing.
local_big_file_path <- reactive({
path_info <- local_file_info()
if (nrow(path_info) > 0) path_info$datapath else NULL
})

# Render just the filename for user feedback in the UI.
output$specdata_big_path <- renderPrint({
req(nrow(local_file_info()) > 0)
cat(local_file_info()$name)
})
}

# Register one shinyFiles pipeline per filetype so DIANN and Spectronaut
# selections can't leak across when the user switches filetypes mid-session.
make_big_file_path <- function(id_suffix) {
browse_id <- paste0("big_file_browse_", id_suffix)
path_id <- paste0("big_file_path_", id_suffix)

shinyFiles::shinyFileChoose(input, browse_id, roots = volumes, session = session)

file_info <- reactive({
req(is.list(input[[browse_id]]))
shinyFiles::parseFilePaths(volumes, input[[browse_id]])
})

output[[path_id]] <- renderPrint({
req(nrow(file_info()) > 0)
cat(file_info()$name)
})

reactive({
info <- file_info()
if (nrow(info) > 0) info$datapath else NULL
})
}

local_big_file_path_spec <- make_big_file_path("spec")
local_big_file_path_diann <- make_big_file_path("diann")
}
else {
local_big_file_path <- reactive({ NULL })
local_big_file_path_spec <- reactive({ NULL })
local_big_file_path_diann <- reactive({ NULL })
}

output$spectronaut_header_ui <- renderUI({
Expand Down Expand Up @@ -72,6 +78,51 @@ loadpageServer <- function(id, parent_session, is_web_server = FALSE) {
tagList(ui_elements, create_separator_buttons(session$ns, "sep_specdata"))
})

output$diann_header_ui <- renderUI({
req(input$filetype == 'diann', input$BIO != 'PTM')
create_diann_header()
})

output$diann_file_selection_ui <- renderUI({
req(input$filetype == 'diann', input$BIO != 'PTM')

ui_elements <- tagList()

if (!is_web_server) {
ui_elements <- tagList(ui_elements, create_diann_mode_selector(session$ns, isTRUE(input$big_file_diann)))

if (isTRUE(input$big_file_diann)) {
ui_elements <- tagList(ui_elements, create_diann_large_file_ui(session$ns))
} else {
ui_elements <- tagList(ui_elements, create_diann_standard_ui(session$ns))
}
} else {
ui_elements <- tagList(ui_elements, create_diann_standard_ui(session$ns))
}

tagList(ui_elements, create_separator_buttons(session$ns, "sep_dianndata"))
})

output$diann_options_ui <- renderUI({
req(input$filetype == 'diann', input$BIO != 'PTM')

if (!is_web_server && isTRUE(input$big_file_diann)) {
mbr_def <- if (is.null(input$diann_MBR)) TRUE else input$diann_MBR

max_feature_def <- if (is.null(input$max_feature_count)) 100 else input$max_feature_count
unique_peps_def <- if (is.null(input$filter_unique_peptides)) FALSE else input$filter_unique_peptides
agg_psms_def <- if (is.null(input$aggregate_psms)) FALSE else input$aggregate_psms
few_obs_def <- if (is.null(input$filter_few_obs)) FALSE else input$filter_few_obs

tagList(
create_diann_large_filter_options(session$ns, mbr_def),
create_diann_large_bottom_ui(session$ns, max_feature_def, unique_peps_def, agg_psms_def, few_obs_def)
)
} else {
NULL
}
})

output$spectronaut_options_ui <- renderUI({
req(input$filetype == 'spec', input$BIO != 'PTM')

Expand Down Expand Up @@ -186,7 +237,7 @@ loadpageServer <- function(id, parent_session, is_web_server = FALSE) {
}
} else if (input$filetype == "spec") {
spec_regular_file_ok <- !isTRUE(input$big_file_spec) && !is.null(input$specdata)
spec_big_file_ok <- isTRUE(input$big_file_spec) && length(local_big_file_path()) > 0
spec_big_file_ok <- isTRUE(input$big_file_spec) && length(local_big_file_path_spec()) > 0
if((spec_regular_file_ok || spec_big_file_ok) && !is.null(input$sep_specdata)) {
enable("proceed1")
}
Expand All @@ -195,7 +246,9 @@ loadpageServer <- function(id, parent_session, is_web_server = FALSE) {
enable("proceed1")
}
} else if (input$filetype == "diann") {
if(!is.null(input$dianndata) && !is.null(input$sep_dianndata)) { # && !is.null(input$annot)
diann_regular_file_ok <- !isTRUE(input$big_file_diann) && !is.null(input$dianndata)
diann_big_file_ok <- isTRUE(input$big_file_diann) && length(local_big_file_path_diann()) > 0
if((diann_regular_file_ok || diann_big_file_ok) && !is.null(input$sep_dianndata)) {
enable("proceed1")
}
}
Expand Down Expand Up @@ -305,7 +358,11 @@ loadpageServer <- function(id, parent_session, is_web_server = FALSE) {


get_data = eventReactive(input$proceed1, {
getData(input)
getData(
input,
big_file_path_spec = local_big_file_path_spec(),
big_file_path_diann = local_big_file_path_diann()
)
})


Expand Down
61 changes: 54 additions & 7 deletions R/module-loadpage-ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,10 @@ create_skyline_uploads <- function(ns) {
#' Create DIANN file uploads
#' @noRd
create_diann_uploads <- function(ns) {
conditionalPanel(
condition = "input['loadpage-filetype'] == 'diann' && input['loadpage-BIO'] != 'PTM'",
h4("4. Upload MSstats report from DIANN"),
fileInput(ns('dianndata'), "", multiple = FALSE, accept = NULL),
create_separator_buttons(ns, "sep_dianndata")
tagList(
uiOutput(ns("diann_header_ui")),
uiOutput(ns("diann_file_selection_ui")),
uiOutput(ns("diann_options_ui"))
Comment thread
tonywu1999 marked this conversation as resolved.
)
}

Expand All @@ -295,24 +294,51 @@ create_spectronaut_header <- function() {
h4("4. Upload MSstats scheme output from Spectronaut")
}

#' Create DIANN header
#' @noRd
create_diann_header <- function() {
h4("4. Upload MSstats report from DIANN")
}

#' Create Spectronaut mode selector (Local only)
#' @noRd
create_spectronaut_mode_selector <- function(ns, selected = FALSE) {
checkboxInput(ns("big_file_spec"), "Large file mode", value = selected)
}

#' Create DIANN mode selector (Local only)
#' @noRd
create_diann_mode_selector <- function(ns, selected = FALSE) {
checkboxInput(ns("big_file_diann"), "Large file mode", value = selected)
}

#' Create Spectronaut standard file input
#' @noRd
create_spectronaut_standard_ui <- function(ns) {
fileInput(ns('specdata'), "", multiple = FALSE, accept = NULL)
}

#' Create DIANN standard file input
#' @noRd
create_diann_standard_ui <- function(ns) {
fileInput(ns('dianndata'), "", multiple = FALSE, accept = NULL)
}

#' Create Spectronaut large file selection UI
#' @noRd
create_spectronaut_large_file_ui <- function(ns) {
tagList(
shinyFiles::shinyFilesButton(ns("big_file_browse"), "Browse for local file...", "Please select a file", multiple = FALSE),
verbatimTextOutput(ns("specdata_big_path"))
shinyFiles::shinyFilesButton(ns("big_file_browse_spec"), "Browse for local file...", "Please select a file", multiple = FALSE),
verbatimTextOutput(ns("big_file_path_spec"))
)
}

#' Create DIANN large file selection UI
#' @noRd
create_diann_large_file_ui <- function(ns) {
tagList(
shinyFiles::shinyFilesButton(ns("big_file_browse_diann"), "Browse for local file...", "Please select a file", multiple = FALSE),
verbatimTextOutput(ns("big_file_path_diann"))
)
}

Expand All @@ -328,6 +354,16 @@ create_spectronaut_large_filter_options <- function(ns, excluded_def = FALSE, id
)
}

#' Create DIANN large file filter options
#' @noRd
create_diann_large_filter_options <- function(ns, mbr_def = TRUE) {
tagList(
tags$hr(),
h4("Options for large file processing"),
checkboxInput(ns("diann_MBR"), "MBR Enabled", value = mbr_def)
)
}

#' Create Spectronaut Q-value cutoff input
#' @noRd
create_spectronaut_qvalue_cutoff_ui <- function(ns, cutoff_def = 0.01) {
Expand All @@ -345,6 +381,17 @@ create_spectronaut_large_bottom_ui <- function(ns, max_feature_def = 20, unique_
)
}

#' Create DIANN large file options (Bottom part)
#' @noRd
create_diann_large_bottom_ui <- function(ns, max_feature_def = 100, unique_peps_def = FALSE, agg_psms_def = FALSE, few_obs_def = FALSE) {
tagList(
numericInput(ns("max_feature_count"), "Max feature count", value = max_feature_def, min = 1),
checkboxInput(ns("filter_unique_peptides"), "Use unique peptides", value = unique_peps_def),
checkboxInput(ns("aggregate_psms"), "Aggregate PSMs to peptides", value = agg_psms_def),
checkboxInput(ns("filter_few_obs"), "Filter features with few observations", value = few_obs_def)
)
}

#' Create PTM FragPipe uploads
#' @noRd
create_ptm_fragpipe_uploads <- function(ns) {
Expand Down
Loading