Skip to content
Merged
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
7 changes: 6 additions & 1 deletion R/module-help-ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ helpUI <- function(id) {
experiments should likely use a subset of features due to the very \
large number of available features."),
tags$li("Missing value imputation (can be MAR/MNAR depending on \
spectral processing tool used.):"),
spectral processing tool used). Imputation runs only when \
(a) the protein has at least one observed feature in the \
current run, AND (b) the missing feature is observed in at \
least one other run. Proteins entirely missing from a run \
and features never observed in the dataset are not \
imputed. Censoring assumptions:"),
tags$ul(
tags$li("Assume all NAs as censored (ie missing not at random)"),
tags$li("Assume all intensities between 0 and 1 as censored and NAs as \
Expand Down
47 changes: 47 additions & 0 deletions R/module-loadpage-server.R
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,53 @@ loadpageServer <- function(id, parent_session, is_web_server = FALSE, app_templa
)
})

observeEvent(input$proceed1, {
shinyjs::disable("download_msstats_format")
})

observeEvent(get_data(), {
req(get_data())
shinyjs::enable("download_msstats_format")
Comment thread
coderabbitai[bot] marked this conversation as resolved.
})

output$download_msstats_format = downloadHandler(
filename = function() {
data <- get_data()
if (inherits(data, "data.frame")) {
paste0("MSstats_format-", Sys.Date(), ".csv")
} else {
paste0("MSstats_format-", Sys.Date(), ".zip")
}
Comment on lines +578 to +582

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'll always inherit data frame right?

},
content = function(file) {
tryCatch({
data <- get_data()
if (inherits(data, "data.frame")) {
data.table::fwrite(data, file)
} else {
tmp_dir <- tempfile("msstats_format_")
dir.create(tmp_dir)
on.exit(unlink(tmp_dir, recursive = TRUE), add = TRUE)
tmp_files <- character()
for (nm in names(data)) {
tbl <- data[[nm]]
if (is.null(tbl)) next
if (NROW(tbl) == 0L) next
tmp_path <- file.path(tmp_dir, paste0(nm, ".csv"))
data.table::fwrite(tbl, tmp_path)
tmp_files <- c(tmp_files, tmp_path)
}
if (length(tmp_files) == 0L) {
stop("No non-empty tables available to export.")
}
utils::zip(zipfile = file, files = tmp_files, flags = "-j")
}
}, error = function(e) {
writeLines(paste("Failed to export MSstats format:", conditionMessage(e)), file)
})
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.


get_data_code = eventReactive(input$calculate, {
getDataCode(input)
Expand Down
11 changes: 9 additions & 2 deletions R/module-loadpage-ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ loadpageUI <- function(id) {
# Processing options
create_processing_options(ns),

# Action button
disabled(actionButton(inputId = ns("proceed1"), label = "Upload Data"))
# Action buttons
tags$div(
style = "display:flex; gap:8px; align-items:center;",
disabled(actionButton(inputId = ns("proceed1"), label = "Upload Data")),
shinyjs::disabled(downloadButton(
ns("download_msstats_format"),
"Download MSstats-format CSV"
))
)
),

column(width = 8,
Expand Down
4 changes: 2 additions & 2 deletions R/module-qc-ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ qcUI <- function(id) {
tags$link(rel = "stylesheet", type = "text/css", href = "assets/style.css"),
),
headerPanel("Process and quantify data"),
p("Feature summarization and missing value imputation. Includes options for vizualizing summarization through data tables and multiple plots. All outputs are available to download in 'csv' format."),
p("Feature summarization and missing value imputation. Includes options for visualizing summarization through data tables and multiple plots. Summarized tables and processed datasets are available to download in CSV format. Imputation runs only when a feature is observed in some other run AND the protein has at least one observed feature in the current run."),
tags$br(),
sidebarPanel(
# transformation
Expand Down Expand Up @@ -141,7 +141,7 @@ qcUI <- function(id) {
h4("Imputation"),
conditionalPanel(condition = "input['qc-censInt'] == 'NA' || input['qc-censInt'] == '0'",
checkboxInput(ns("MBi"), label=tags$div("Model based imputation",class = "icon-wrapper",icon("question-circle", lib = "font-awesome"),
div("If unchecked the values set as cutoff for censored will be used", class = "icon-tooltip")),value = TRUE
div("Fills in missing intensities only when (a) the protein has at least one observed feature in that run, AND (b) the missing feature is observed in at least one other run. Proteins entirely missing from a run, and features never observed in the dataset, are not imputed. If unchecked, the cutoff for censored values is used instead.", class = "icon-tooltip")),value = TRUE
)),
# # cutoff for censored
# conditionalPanel(condition = "input.censInt == 'NA' || input.censInt == '0'",
Expand Down
9 changes: 9 additions & 0 deletions R/module-statmodel-server.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ statmodelServer = function(id, parent_session, loadpage_input, qc_input,
choices = c("Turnover Curve" = CONSTANTS_STATMODEL$plot_type_response_curve),
selected = CONSTANTS_STATMODEL$plot_type_response_curve)
updateCheckboxInput(session, NAMESPACE_STATMODEL$modeling_response_curve_increasing_trend, value = TRUE)
shinyjs::hide("statmodel_contrast_header", asis = TRUE)
shinyjs::hide("statmodel_workflow_bullet_default", asis = TRUE)
shinyjs::show("statmodel_workflow_bullet_response_curve", asis = TRUE)
} else if (template == TEMPLATES$chemoproteomics) {
updateRadioButtons(session, NAMESPACE_STATMODEL$comparison_mode,
choices = c("Create dose-response curves" = CONSTANTS_STATMODEL$comparison_mode_response_curve),
Expand All @@ -61,6 +64,9 @@ statmodelServer = function(id, parent_session, loadpage_input, qc_input,
choices = c("Dose-Response Curve" = CONSTANTS_STATMODEL$plot_type_response_curve),
selected = CONSTANTS_STATMODEL$plot_type_response_curve)
updateCheckboxInput(session, NAMESPACE_STATMODEL$modeling_response_curve_increasing_trend, value = FALSE)
shinyjs::hide("statmodel_contrast_header", asis = TRUE)
shinyjs::hide("statmodel_workflow_bullet_default", asis = TRUE)
shinyjs::show("statmodel_workflow_bullet_response_curve", asis = TRUE)
} else {
updateRadioButtons(session, NAMESPACE_STATMODEL$comparison_mode,
choices = c(
Expand All @@ -77,6 +83,9 @@ statmodelServer = function(id, parent_session, loadpage_input, qc_input,
"Comparison Plot" = CONSTANTS_STATMODEL$plot_type_comparison_plot
))
updateCheckboxInput(session, NAMESPACE_STATMODEL$modeling_response_curve_increasing_trend, value = FALSE)
shinyjs::show("statmodel_contrast_header", asis = TRUE)
shinyjs::show("statmodel_workflow_bullet_default", asis = TRUE)
shinyjs::hide("statmodel_workflow_bullet_response_curve", asis = TRUE)
}
}, ignoreInit = FALSE)

Expand Down
1 change: 1 addition & 0 deletions R/statmodel-ui-comparisons.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ create_contrast_radio_buttons <- function(ns) {
ns(NAMESPACE_STATMODEL$comparison_mode),
label = h4(
"1. Define comparisons - contrast matrix",
id = "statmodel_contrast_header",
class = "icon-wrapper",
icon("question-circle", lib = "font-awesome"),
div("Define what conditions you want to compare here", class = "icon-tooltip")
Expand Down
7 changes: 6 additions & 1 deletion R/statmodel-ui-headers.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ create_header_section <- function() {
tagList(
headerPanel("Statistical modeling and inference"),
p("In this tab, build your statistical model in three steps:"),
p("(i) Create a contrast matrix for a group comparison or set up a configuration for a response curve analysis,"),
p(id = "statmodel_workflow_bullet_default",
"(i) Create a contrast matrix for a group comparison,"),
shinyjs::hidden(
p(id = "statmodel_workflow_bullet_response_curve",
"(i) Configure the response curve analysis,")
),
p("(ii) generate the model and "),
p("(iii) view result plots."),
p("More info ", a("here", href="https://www.rdocumentation.org/packages/MSstats/versions/3.4.0/topics/groupComparisonPlots"))
Expand Down
Loading