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
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
_\.new\.png$
^\.positai$
^\.claude$
^plans$
MSstats_log_.*\.log$
^[^/]*\.csv$
^\.github$
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ vignettes/*.pdf

/*.csv
.positai

# Local planning docs (not part of the package)
plans/
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ importFrom(stats,hclust)
importFrom(stats,median)
importFrom(stats,na.omit)
importFrom(stats,qt)
importFrom(stats,setNames)
importFrom(stringr,str_detect)
importFrom(stringr,str_extract)
importFrom(stringr,str_extract_all)
Expand Down
14 changes: 13 additions & 1 deletion R/constants.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,19 @@ NAMESPACE_QC = list(
ptm_downloads_panel = "ptm_downloads_panel",
# Data Upload tab template-gated upload panels
data_upload_mapping_panel = "data_upload_mapping_panel",
data_upload_ratios_panel = "data_upload_ratios_panel"
data_upload_ratios_panel = "data_upload_ratios_panel",
tracer_constants_panel = "tracer_constants_panel",
tracer_constants_file = "tracer_constants_file",
tracer_constants_clear = "tracer_constants_clear",
tracer_constants_status = "tracer_constants_status"
)

CONSTANTS_QC = list(
tracer_min = 0.01,
tracer_max = 1,
tracer_source_upload = "upload",
tracer_source_none = "none",
tracer_source_not_run = "not_run"
)

NAMESPACE_EXPDES = list(
Expand Down
18 changes: 13 additions & 5 deletions R/module-qc-server.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
#' @param parent_session session of the main calling module
#' @param loadpage_input input object from loadpage UI
#' @param get_data stored function that returns the data from loadpage
#' @param app_template reactive (or NULL) returning the selected template name (e.g. TEMPLATES$default)
#' @param get_condition_metadata reactive (or NULL) returning the condition metadata table
#'
#' @return input object with user selected options
#' @return a list with four elements: `input` (the module's input object),
#' `preprocessData` (reactive returning the preprocessed data),
#' `turnoverRatios` (reactive returning the turnover ratios, or the uploaded
#' ratios when those override them), and `tracerConstants` (reactive
#' returning the tracer-constant provenance record snapshotted at Run)
#'
#' @export
#' @examples
Expand All @@ -25,12 +31,13 @@ qcServer <- function(input, output, session, parent_session, loadpage_input, get
preprocessData(input, loadpage_input(), get_data())
})

turnover_ratios <- register_qc_turnover(input, output, session, app_template, get_data,
get_condition_metadata, preprocess_data)
turnover = register_qc_turnover(input, output, session, app_template, get_data,
get_condition_metadata, preprocess_data)

data_upload = register_qc_data_upload(input, output, session, loadpage_input,
app_template, get_data, preprocess_data,
get_condition_metadata, turnover_ratios)
get_condition_metadata, turnover$ratios,
turnover$tracer_upload)

effective_preprocess_data <- data_upload$effective_preprocess_data

Expand Down Expand Up @@ -97,7 +104,8 @@ qcServer <- function(input, output, session, parent_session, loadpage_input, get
list(
input = input,
preprocessData = effective_preprocess_data,
turnoverRatios = data_upload$effective_turnover_ratios
turnoverRatios = data_upload$effective_turnover_ratios,
tracerConstants = turnover$tracer_constants
)
)
}
36 changes: 33 additions & 3 deletions R/module-qc-ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,37 @@ qcUI <- function(id) {

)),

tags$hr(),
uiOutput(ns("tracer_constants_sidebar")),
# Tracer constants (protein turnover only), toggled server-side by
# register_qc_turnover.
shinyjs::hidden(div(
id = ns(NAMESPACE_QC$tracer_constants_panel),
tags$hr(),
h4("Tracer constants", class = "icon-wrapper",
icon("question-circle", lib = "font-awesome"),
div(paste0(
"Optional: corrects each condition's heavy fraction for ",
"incomplete label enrichment by dividing it by this constant ",
"(1 = no correction; leave empty to use 1 everywhere). ",
"Upload a CSV with columns ",
paste(get_qc_required_tracer_columns(), collapse = ", "),
" (case-sensitive), one row per condition -- GROUP must match ",
"your experimental condition names exactly, including case. ",
"TracerConstant must be between ", CONSTANTS_QC$tracer_min,
" and ", CONSTANTS_QC$tracer_max, ". Example: header ",
"'GROUP,TracerConstant', then '0h,0.98', '6h,0.95', ",
"'24h,0.93'. Condition names must start with a number of ",
"hours (d or w for days/weeks); names the app can't parse, ",
"or that duplicate a timepoint, are rejected."),
class = "icon-tooltip")),
fileInput(ns(NAMESPACE_QC$tracer_constants_file),
"Upload tracer constants (CSV)", accept = ".csv"),
p(tags$strong("Required columns: "),
paste(get_qc_required_tracer_columns(), collapse = ", ")),
actionButton(ns(NAMESPACE_QC$tracer_constants_clear), "Clear",
class = "btn-sm"),
tags$br(), tags$br(),
uiOutput(ns(NAMESPACE_QC$tracer_constants_status))
)),
actionButton(ns("run"), "Run summarization"),
width = 3
),
Expand Down Expand Up @@ -230,7 +259,8 @@ qcUI <- function(id) {
id = ns(NAMESPACE_QC$data_upload_ratios_panel),
tags$hr(),
fileInput(ns("upload_turnover_ratios"), "Upload Turnover Ratios (CSV)", accept = ".csv"),
p(tags$strong("Required columns: "), "Protein, TimeVal, H_frac, L_frac")
p(tags$strong("Required columns: "), "Protein, TimeVal, H_frac, L_frac"),
p("Ratios uploaded here are used as given. The tracer-constants upload in the side panel does not apply on this flow: these H_frac and L_frac values are already computed, so any correction for incomplete label enrichment must be applied before upload.")
))
)
),
Expand Down
12 changes: 10 additions & 2 deletions R/module-statmodel-server.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
#' @param get_data stored function that returns the data from loadpage
#' @param preprocess_data stored function that returns preprocessed data
#' @param app_template reactive returning the selected template name (e.g. TEMPLATES$default)
#' @param turnover_ratios reactive returning the calculated turnover ratios
#' @param condition_metadata reactive returning the condition metadata table
#' @param tracer_constants reactive returning the tracer-constant provenance
#' record snapshotted by the QC page at Run (values / source / file), or
#' NULL when the data-processing page has not been run in this session
#'
#' @importFrom MSstatsResponse visualizeResponseProtein
#'
Expand All @@ -27,7 +32,8 @@ statmodelServer = function(id, parent_session, loadpage_input, qc_input,
get_data, preprocess_data,
app_template = reactive(TEMPLATES$default),
turnover_ratios = reactive(NULL),
condition_metadata = reactive(NULL)) {
condition_metadata = reactive(NULL),
tracer_constants = reactive(NULL)) {
moduleServer(
id,
function(input, output, session) {
Expand Down Expand Up @@ -394,7 +400,9 @@ statmodelServer = function(id, parent_session, loadpage_input, qc_input,
data_comparison_code = eventReactive(input[[NAMESPACE_STATMODEL$modeling_start]], {
req(contrast$matrix)
comp_mat = contrast$matrix
generate_analysis_code(qc_input(), loadpage_input(), comp_mat, input, app_template())
tracer_used = tryCatch(tracer_constants(), error = function(e) NULL)
generate_analysis_code(qc_input(), loadpage_input(), comp_mat, input,
app_template(), tracer_used)
})

SignificantProteins = eventReactive(input[[NAMESPACE_STATMODEL$modeling_start]], {
Expand Down
Loading
Loading