Skip to content

Refactor the QC page#218

Open
swaraj-neu wants to merge 2 commits into
develfrom
MSstatsShiny/work/20260629_qc-page_refactor
Open

Refactor the QC page#218
swaraj-neu wants to merge 2 commits into
develfrom
MSstatsShiny/work/20260629_qc-page_refactor

Conversation

@swaraj-neu

@swaraj-neu swaraj-neu commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Motivation and context

The QC page had grown into a large, monolithic Shiny UI/server implementation with complex branching across QC workflows—especially PTM vs non-PTM and template-specific behavior (e.g., protein turnover). This made it hard to keep IDs consistent, reason about conditional rendering, and safely extend the QC flow without regressions.

Solution summary

The refactor modularizes the QC page into smaller “registration” helpers (sidebar visibility/options, plots, summarized results, downloads, and turnover ratios) and centralizes QC-related UI/server identifiers via a new NAMESPACE_QC constant. The UI shifts from extensive conditionalPanel(...) logic to shinyjs::hidden(div(...)) containers keyed by those centralized namespace IDs, while the server orchestration is streamlined around a “run → next step → switch tab” flow and delegates to the new registration helpers.

Detailed changes

  • Centralized QC namespaces/constants

    • Added exported NAMESPACE_QC in R/constants.R to map QC input/container IDs (sidebar processing options, summarized-results/plot/download tab IDs, and server-toggled visibility container IDs).
    • Updated exported NAMESPACE_EXPDES by removing result_plot = "result_plot".
  • QC server orchestration refactor

    • In R/module-qc-server.R, replaced a large inline block of QC rendering/wiring (caption/proceed navigation, plots/statistics/quantification UI, CSV/plot downloads, and turnover-ratio sidebar + turnover table/download) with a streamlined flow:
      • simplified caption reactive/event handling on input$run
      • renders a “Next step” button via output$submit.button, enabling it around preprocess_data() completion
      • clicking proceed6 switches the parent tabset to "StatsModel" via onclick(...)
      • delegates setup to helper calls:
        register_qc_visibility_observers, register_qc_sidebar_options, register_qc_plots, register_qc_summary, register_qc_downloads, register_qc_turnover (capturing turnover_ratios from the turnover registration)
  • QC UI conditional rendering refactor

    • In R/module-qc-ui.R, replaced conditionalPanel(...)-based conditional rendering with shinyjs::hidden(div(...)) wrappers.
    • The hidden containers are controlled using ns(NAMESPACE_QC$...) identifiers, covering:
      • normalization/log/summarization/cutoff/standards/local normalization controls
      • censoring/MBi section visibility
      • plot option panels (profile plot legend options and quality-metrics selector)
      • download-button visibility logic
    • Reworked download visibility so “non-PTM” vs “PTM/unmodified protein” controls are grouped into separate hidden panels with dedicated IDs (rather than multiple conditionalPanel(...) branches).
  • New QC sidebar predicates + registration

    • In R/qc-server-sidebar.R, added predicate helpers that decide whether specific QC sidebar panels should be shown, including:
      • TMT vs label-free (qc_show_tmt, qc_show_lf)
      • MSstats+ vs standard maxQC gating (qc_show_maxqc_msstats)
      • standards panel gating (qc_show_standards)
      • top-N feature gating (qc_show_features_topn)
      • censoring/MBi gating (qc_show_mbi)
      • log-section gating (qc_show_log_section)
      • profile plot vs quality-metrics option visibility (qc_show_profileplot_options, qc_show_qualitymetrics_options)
      • download panel gating for non-PTM vs PTM (qc_show_nonptm_downloads, qc_show_ptm_downloads)
    • Added register_qc_visibility_observers(...):
      • mounts hidden QC sidebar containers and uses shinyjs::toggle() to show/hide them via predicates
      • includes special observers for the protein_turnover template to update the UI flow, toggle template-specific sections, and update normalization/feature-subset controls
      • handles enabling/disabling censoring-related controls and uses shinyjs::toggleState() for maxQC / n_feat based on null/all-features settings
    • Added register_qc_sidebar_options(...) to dynamically render:
      • the “standard-name” multiselect (template vs non-template branching)
      • a top-N features slider (max depends on BIO/PTM and feature uniqueness from get_data())
      • a summaryMethod radio selector defaulting to TMP and optionally adding MSstats+ when anomaly scores are enabled
  • New QC plots registration

    • In R/qc-server-plots.R, added register_qc_plots(...) to register the QC “Summarization Plots” tab:
      • plot UI selection (QC/Profile; quality-metrics UI appears only when anomaly scores are enabled)
      • quality metric selector + protein selector for QualityMetricsPlot using metric columns discovered from get_data()
      • “Show plot for” protein/target selector for other plot types, with BIO-dependent option sources
      • implemented shared plotresult() routing to the appropriate plotting function based on PTM/TMT mode
      • added a statistics reactive to compute per-condition summary stats from preprocess_data()$ProteinLevelData
      • wired UI outputs including a stats table and a PDF download that reuses the same plotting route
  • New QC summarized-results registration

    • In R/qc-server-summary.R, added register_qc_summary(...):
      • maintains reactive abundant$results reset when loadpage_input()$proceed1 fires
      • computes results in an eventReactive (abundance) after preprocess_data() completion
      • branches quantification logic by BIO and DDA_DIA (including PTM/TMT column renaming and a dedicated protein-turnover template path that bypasses quantification)
      • renders a data table only when results exist, and adds a date-stamped CSV download for the abundance table
  • New QC downloads registration

    • In R/qc-server-downloads.R, added register_qc_downloads(...):
      • registers download handlers for QC CSV exports at feature and protein levels for both non-PTM and PTM/unmodified protein modes
      • enables PTM/PROTEIN handlers when loadpage_input()$BIO == "PTM", otherwise enables the non-PTM handlers
      • writes CSVs derived from preprocess_data() sub-tables (feature/protein; PTM variants vs protein-side PTM variants)
  • New QC turnover ratios module

    • In R/qc-server-turnover.R, added register_qc_turnover(...):
      • provides a sidebar (for protein_turnover template) and dynamically generated per-condition tracer constant inputs (0–1)
      • on input$run, computes turnover ratios via calculateTurnoverRatios with normalize_tracer = TRUE and defaults missing tracer constants to 1.0
      • renders results in a data table and provides a date-stamped CSV download

Unit tests

  • QC UI rendering and namespace correctness (tests/testthat/test-module-qc-ui.R)

    • Verifies qcUI("test") returns a tagList
    • Ensures rendered HTML contains expected namespaced QC input/container id attributes tied to NAMESPACE_QC
    • Confirms the normalization select (id="test-norm") collapses to a single instance and contains expected option strings (equalizeMedians, quantile, globalStandards)
  • QC server sidebar predicate behavior and NAMESPACE_QC ID stability (tests/testthat/test-qc-server-rendering.R)

    • Adds truth-table style tests for qc_show_* predicate helpers across key driver combinations (TMT vs label-free, summarization requirements, standards/features/censoring/log-section gating)
    • Verifies option visibility keyed by plot/download type1
    • Asserts mutual exclusivity/complementarity of the non-PTM vs PTM download panels
    • Adds a guard test asserting specific literal string values inside NAMESPACE_QC (to prevent QC ID renames)

Coding guidelines violated

  • Potential correctness risk (undefined variable/CI computation): In R/qc-server-plots.R, the statistics reactive that computes CI-width references tab$CI even though tab$CI is not clearly defined in the described function logic, which can lead to incorrect CI calculations or runtime errors.

@swaraj-neu swaraj-neu self-assigned this Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5954332c-d25e-4244-885f-bd4e4b21130c

📥 Commits

Reviewing files that changed from the base of the PR and between 498ae4b and c24df8c.

📒 Files selected for processing (1)
  • R/constants.R
🚧 Files skipped from review as they are similar to previous changes (1)
  • R/constants.R

📝 Walkthrough

Walkthrough

The QC UI and server are split into helper modules for visibility, plots, summary results, downloads, and turnover ratios. Shared QC namespace constants are added, the UI uses hidden panels instead of conditional panels, and tests cover the new IDs and visibility helpers.

Changes

QC Module Decomposition

Layer / File(s) Summary
NAMESPACE QC constants
R/constants.R
Defines NAMESPACE_QC and removes result_plot from NAMESPACE_EXPDES.
QC UI panels
R/module-qc-ui.R
Replaces conditionalPanel branches with shinyjs::hidden panels keyed by NAMESPACE_QC ids for processing options, MBi, plot options, and downloads.
Sidebar predicates and observers
R/qc-server-sidebar.R
Adds qc_show_* predicates and register_qc_visibility_observers/register_qc_sidebar_options to toggle QC panels, update template-specific state, and render sidebar inputs.
QC plots
R/qc-server-plots.R
Adds register_qc_plots with plot type selection, protein/metric selectors, plot routing, summary statistics, and PDF export.
QC summary and CSV downloads
R/qc-server-summary.R, R/qc-server-downloads.R
Adds register_qc_summary and register_qc_downloads for abundance results, table rendering, and feature/protein CSV exports.
Turnover ratios
R/qc-server-turnover.R
Adds register_qc_turnover with tracer-constant inputs, turnover ratio computation, table output, and CSV export.
qcServer delegation
R/module-qc-server.R
Replaces inline qcServer logic with caption/proceed wiring and helper registration calls for the QC sub-modules.
QC UI and server tests
tests/testthat/test-module-qc-ui.R, tests/testthat/test-qc-server-rendering.R
Adds tests for qcUI structure, namespaced ids, sidebar predicate truth tables, download-panel exclusivity, and NAMESPACE_QC literal values.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested labels: Review effort 3/5

Suggested reviewers: tonywu1999

Poem

A bunny hopped through QC land,
And split the tunnels, neat and grand.
Hidden panels blinked to life,
Helpers tamed the server strife.
Fresh namespaces now guide the way,
A tidy hop for bunny play 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: a broad refactor of the QC page and its modules.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch MSstatsShiny/work/20260629_qc-page_refactor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@R/module-qc-server.R`:
- Around line 67-83: The transition gating for proceed6 is ineffective because
`renderUI` in the `observeEvent(input$run, ...)` block creates an enabled
`actionButton`, so users can advance before preprocessing completes. Update the
`proceed6` button creation to start disabled or only render it once
`preprocess_data()` is ready, and keep the `enable("proceed6")` call tied to the
`observeEvent(preprocess_data(), ...)`/preprocessing completion path so
`StatsModel` can’t be reached early.

In `@R/module-qc-ui.R`:
- Around line 51-57: The selectInput for `ns("summarization")` in `module-qc-ui`
uses an invalid default value, since `selected = "log"` does not match any of
the listed choices. Update the default to one of the actual option values used
in that input (for example the value corresponding to the intended summarization
method) so the `summarization` control initializes deterministically in the TMT
branch.

In `@R/qc-server-downloads.R`:
- Around line 8-20: The download buttons are being enabled in
observeEvent(input$run), but the download handlers immediately rely on
preprocess_data(), so users can trigger exports before preprocessing has
finished. Move the enable/disable logic to the point where preprocessing
completion is known (for example, after the preprocess_data() result is ready)
and keep the buttons disabled until then; update the PTM/non-PTM branches
consistently in the related download handlers so they only become clickable once
the required data exists.

In `@R/qc-server-plots.R`:
- Around line 66-67: The download flow for QualityMetricsPlot bypasses the
intended MSstatsQualityMetricsPlot branch because qcPlot() removes input$which
too early, causing plotresult() to fail when it later expects that value. Update
the save/download logic so QualityMetricsPlot is either explicitly disabled or
handled as a special case before plotresult() is called, and ensure qcPlot(),
plotresult(), and MSstatsQualityMetricsPlot() route this plot type without
requiring input$which.
- Around line 148-150: The CI calculation in ConditionPlot is referencing the
wrong columns, so fix the stats table logic in the function that builds `tab` by
using `Number_of_Measurements` consistently and by using the computed `CI_width`
value instead of the nonexistent `tab$CI`. Update the `SE`, `CI_width`, and
`CI_Limits` assignments together so they all refer to the same created columns
and the table renders without missing-field errors.
- Around line 75-80: The PTM selector in qc-server-plots.R is building choices
from get_data()$PTM[1], which is a one-column object instead of the actual PTM
vector. Update the selectizeInput calls in the plotting logic to use the PTM
vector itself from get_data() so the dropdown shows real PTM options, and keep
the existing "ALL PROTEINS" entry only in the branch that needs it.

In `@R/qc-server-sidebar.R`:
- Around line 258-260: The observer using input$all_feat is stale because qcUI
no longer defines that input, so it can evaluate to length-zero and break.
Update the observer in qc-server-sidebar.R to use the current feature-selection
input (features_used) instead of all_feat, and keep the toggleState("n_feat",
...) logic aligned with the new UI state. Make sure the fix is applied in the
observer block that currently references input$all_feat.
- Around line 305-314: The PTM branch in max_feat() is counting a vector element
with nrow(), which returns NULL and can break sliderInput for PTM data. Update
the PTM path in max_feat() to use length() on get_data()$PTM[1] (or the
equivalent PTM vector) instead of nrow(unique(...)), and keep the non-PTM branch
unchanged so sliderInput(ns("n_feat")) always receives a valid numeric max.
- Around line 237-250: The censoring radio selectors in the observer are
currently global and the jQuery lookup is not module-scoped, so update the logic
in observe() to target the module’s namespaced input IDs/classes instead of
plain [value=NA], [value=0], and name=censInt. Use the same unique symbols in
this block, including loadpage_input(), enable("censInt"), disable(), and
runjs(), but scope all selector strings to the module namespace so only this
module’s radios are affected.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9772cb1b-bae0-4ae1-a00d-9c705606511b

📥 Commits

Reviewing files that changed from the base of the PR and between e4342c9 and c57e24b.

📒 Files selected for processing (10)
  • R/constants.R
  • R/module-qc-server.R
  • R/module-qc-ui.R
  • R/qc-server-downloads.R
  • R/qc-server-plots.R
  • R/qc-server-sidebar.R
  • R/qc-server-summary.R
  • R/qc-server-turnover.R
  • tests/testthat/test-module-qc-ui.R
  • tests/testthat/test-qc-server-rendering.R

Comment thread R/module-qc-server.R
Comment thread R/module-qc-ui.R
Comment on lines +51 to +57
selectInput(ns("summarization"),
h4("Summarization method",class = "icon-wrapper",icon("question-circle", lib = "font-awesome"),
div("Select method to be used for protein summarization. For details on each option please see Help tab", class = "icon-tooltip")),
c("MSstats" = "msstats",
"Tukeys median polish" = "MedianPolish",
"Log(Sum)" = "LogSum","Median" = "Median"),
selected = "log")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use a valid default summarization value.

Line 57 sets selected = "log", but "log" is not one of this selectInput’s choices. Pick a real value so the default TMT branch state is deterministic.

Proposed fix
-                      selected = "log")
+                      selected = "msstats")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
selectInput(ns("summarization"),
h4("Summarization method",class = "icon-wrapper",icon("question-circle", lib = "font-awesome"),
div("Select method to be used for protein summarization. For details on each option please see Help tab", class = "icon-tooltip")),
c("MSstats" = "msstats",
"Tukeys median polish" = "MedianPolish",
"Log(Sum)" = "LogSum","Median" = "Median"),
selected = "log")
selectInput(ns("summarization"),
h4("Summarization method",class = "icon-wrapper",icon("question-circle", lib = "font-awesome"),
div("Select method to be used for protein summarization. For details on each option please see Help tab", class = "icon-tooltip")),
c("MSstats" = "msstats",
"Tukeys median polish" = "MedianPolish",
"Log(Sum)" = "LogSum","Median" = "Median"),
selected = "msstats")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@R/module-qc-ui.R` around lines 51 - 57, The selectInput for
`ns("summarization")` in `module-qc-ui` uses an invalid default value, since
`selected = "log"` does not match any of the listed choices. Update the default
to one of the actual option values used in that input (for example the value
corresponding to the intended summarization method) so the `summarization`
control initializes deterministically in the TMT branch.

Comment thread R/qc-server-downloads.R
Comment thread R/qc-server-plots.R
Comment thread R/qc-server-plots.R
Comment thread R/qc-server-sidebar.R
Comment thread R/qc-server-sidebar.R
Comment thread R/qc-server-sidebar.R
@swaraj-neu swaraj-neu force-pushed the MSstatsShiny/work/20260629_qc-page_refactor branch from c57e24b to 498ae4b Compare July 2, 2026 16:20

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
R/qc-server-plots.R (1)

89-133: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Guard on the protein argument, not input$which.

plotresult() receives protein, but Line 89 still checks input$which; when the selector is not initialized this can evaluate if (NULL != "") and error before returning NULL.

Proposed fix
 plotresult = function(saveFile, protein, summary, original, file) {
-  if (input$which != "") {
+  if (length(protein) == 0 || identical(protein, "")) {
+    return(NULL)
+  }
+
     if (loadpage_input()$BIO == "PTM"){
       plot = dataProcessPlotsPTM(preprocess_data(),
...
       return(plot)
     }
-  }
-  else {
-    return(NULL)
-  }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@R/qc-server-plots.R` around lines 89 - 133, The guard in plotresult() is
checking input$which instead of the protein argument, which can fail when the
selector is unset. Update the initial conditional to validate protein directly,
and keep the existing PTM/TMT/default branches unchanged inside plotresult() so
the function returns NULL safely when protein is missing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@R/constants.R`:
- Around line 168-174: `NAMESPACE_EXPDES` is missing the `result_plot` shared id
that the expdes module still expects. Restore the `result_plot` entry in
`NAMESPACE_EXPDES` in constants, or if the id is being renamed/removed, update
both `module-expdes-ui.R` and `module-expdes-server.R` together so every
`NAMESPACE_EXPDES$result_plot` reference uses the same replacement symbol.

In `@R/qc-server-plots.R`:
- Around line 137-139: The statistics reactive is reading
preprocess_data()$ProteinLevelData and input$which without guarding for empty
startup state, so add req(preprocess_data(), input$which) at the start of
statistics() before any subsetting. Update the reactive in qc-server-plots.R so
renderTable(statistics()) only runs after the processed data and selection are
available, using the statistics() and preprocess_data() symbols as the main
touchpoints.
- Around line 195-202: The download handler in the plot export flow is still
calling plotresult() with address set to FALSE, so it stays on the Plotly path
while pdf(file) is open and can produce an empty export. Update the content
function in output$saveplot to pass the download path through to plotresult()
via its saveFile/address parameters, and ensure dev.off() is protected with
on.exit() if the PDF device remains open during plotting.

---

Duplicate comments:
In `@R/qc-server-plots.R`:
- Around line 89-133: The guard in plotresult() is checking input$which instead
of the protein argument, which can fail when the selector is unset. Update the
initial conditional to validate protein directly, and keep the existing
PTM/TMT/default branches unchanged inside plotresult() so the function returns
NULL safely when protein is missing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 31f22ce7-ccd8-427f-bc71-6d45f650c263

📥 Commits

Reviewing files that changed from the base of the PR and between c57e24b and 498ae4b.

📒 Files selected for processing (10)
  • R/constants.R
  • R/module-qc-server.R
  • R/module-qc-ui.R
  • R/qc-server-downloads.R
  • R/qc-server-plots.R
  • R/qc-server-sidebar.R
  • R/qc-server-summary.R
  • R/qc-server-turnover.R
  • tests/testthat/test-module-qc-ui.R
  • tests/testthat/test-qc-server-rendering.R
🚧 Files skipped from review as they are similar to previous changes (8)
  • tests/testthat/test-module-qc-ui.R
  • R/qc-server-turnover.R
  • R/module-qc-server.R
  • R/qc-server-downloads.R
  • R/qc-server-summary.R
  • tests/testthat/test-qc-server-rendering.R
  • R/module-qc-ui.R
  • R/qc-server-sidebar.R

Comment thread R/constants.R
Comment thread R/qc-server-plots.R
@swaraj-neu swaraj-neu requested a review from tonywu1999 July 2, 2026 18:15
@Vitek-Lab Vitek-Lab deleted a comment from coderabbitai Bot Jul 6, 2026
@Vitek-Lab Vitek-Lab deleted a comment from coderabbitai Bot Jul 6, 2026
Comment thread R/qc-server-downloads.R
Comment on lines +27 to +35
if(loadpage_input()$DDA_DIA=='TMT'){

write.csv(preprocess_data()$FeatureLevelData, file, row.names = FALSE)

}
else{

write.csv(preprocess_data()$FeatureLevelData, file, row.names = FALSE)
}

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.

This conditional is not needed right? It's the same line of code.

Comment thread R/qc-server-downloads.R
enable("prepr_csv_prot")
enable("summ_csv_prot")
} else {
enable("prepr_csv")

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.

Rename this to prep_feature_level_data_csv

Comment thread R/qc-server-downloads.R
enable("summ_csv_prot")
} else {
enable("prepr_csv")
enable("summ_csv")

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.

Rename this to prep_protein_level_data_csv

Comment thread R/qc-server-downloads.R
Comment on lines +11 to +14
enable("prepr_csv_ptm")
enable("summ_csv_ptm")
enable("prepr_csv_prot")
enable("summ_csv_prot")

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.

Would rename to:

prep_feature_level_data_csv_ptm
prep_protein_level_data_csv_ptm
prep_feature_level_data_csv_global_proteome
prep_protein_level_data_csv_global_proteome

Comment thread R/qc-server-plots.R
Comment on lines +77 to +80
unique(get_data()$PTM[1])))
} else {
selectizeInput(ns("which"), "Show plot for",
choices = c("", unique(get_data()$PTM[1])))

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.

Rather than a number like get_data()$PTM[1], use get_data()$PTM$ProteinName

Comment thread R/qc-server-plots.R
# which protein to plot (will add "all" for QCPlot)
output$Which = renderUI({
ns <- session$ns
req(input$type1)

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.

Let's do something more descriptive than type1, maybe like qc_page_plot_type

Comment thread R/qc-server-plots.R
Comment on lines +56 to +58
selectizeInput(ns("qm_protein"),
label = h5("Show plot for"),
choices = c("", protein_choices))

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 wonder if this can overlap with the code between lines 63 and 86, seems like duplicate code.

Comment thread R/qc-server-plots.R
Comment on lines +137 to +153
statistics = reactive({
sub = preprocess_data()$ProteinLevelData[which(preprocess_data()$ProteinLevelData$Protein == input$which),]
len = aggregate(sub$LogIntensities~sub$GROUP_ORIGINAL, length, data = sub)
colnames(len)[colnames(len)=="sub$LogIntensities"] = "Number_of_Measurements"
sd = aggregate(sub$LogIntensities~sub$GROUP_ORIGINAL, sd, data = sub)
colnames(sd)[colnames(sd)=="sub$LogIntensities"] = "Standard_Deviation"
mean = aggregate(sub$LogIntensities~sub$GROUP_ORIGINAL, mean, data = sub)
colnames(mean)[colnames(mean)=="sub$LogIntensities"] = "Mean"
tab = merge(len, sd, by="sub$GROUP_ORIGINAL")
tab = merge(mean, tab, by="sub$GROUP_ORIGINAL")
colnames(tab)[colnames(tab)=="sub$GROUP_ORIGINAL"] = "Condition"
SE = tab$Standard_Deviation/sqrt(tab$Number_of_Measurements)
tab$CI_width = qt(.975, df=tab$Number_of_Measurement)*SE
CI_Limits = c(tab$Mean-tab$CI, tab$Mean+tab$CI)

return(tab)
})

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.

Where is the condition plot used exactly? I don't recall there being an option for the condition plot.

My gut tells me this can be removed (and any reference to condition plots, I don't think they're useful tbh)

Comment thread R/qc-server-plots.R
)
tagList(
op,
conditionalPanel(condition = "input['qc-type'] == 'ConditionPlot' && input['qc-which'] != ''",

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 this can be removed. I don't think we give an option for ConditionPlot.

Comment thread R/qc-server-plots.R
Comment on lines +168 to +171
output = plotresult(FALSE, input$which, FALSE, TRUE, FALSE)
}
else if (input$summ == TRUE) {
output = plotresult(FALSE, input$which, TRUE, FALSE, FALSE)

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.

Could you rename plotresult to callDataProcessPlots?

Comment thread R/qc-server-sidebar.R
#' method, reference-channel normalization).
#' @noRd
qc_show_tmt <- function(dda_dia, bio) {
isTRUE(dda_dia == "TMT") || (isTRUE(bio == "PTM") && isTRUE(dda_dia == "TMT"))

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.

This can simply be isTRUE(dda_dia == "TMT") since the right hand side doesn't add anything additional.

Comment thread R/qc-server-sidebar.R
#' censoring, imputation, summary method).
#' @noRd
qc_show_lf <- function(dda_dia, bio) {
isTRUE(dda_dia == "LType") || (isTRUE(bio == "PTM") && !isTRUE(dda_dia == "TMT"))

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.

This can be simplified to only isTRUE(dda_dia == "LType").

Comment thread R/qc-server-sidebar.R
#' Show the top-N feature-count slider: label-free branch with the topN subset selected.
#' @noRd
qc_show_features_topn <- function(dda_dia, bio, features_used) {
qc_show_lf(dda_dia, bio) && isTRUE(features_used == "topN")

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.

it should be sufficient to say isTRUE(features_used == "topN")

Comment thread R/qc-server-sidebar.R
#' Show the global-standards picker: label-free non-PTM with globalStandards normalization.
#' @noRd
qc_show_standards <- function(norm, bio, dda_dia) {
isTRUE(norm == "globalStandards") &&

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.

It should be sufficient to be isTRUE(norm == "globalStandards")

Comment thread R/qc-server-sidebar.R
Comment on lines +212 to +219
shinyjs::hide(NAMESPACE_QC$censoring_section)
shinyjs::hide(NAMESPACE_QC$standards_type_section)
updateSelectInput(session, NAMESPACE_QC$norm,
choices = c("none" = "FALSE", "global standards" = "globalStandards"),
selected = "FALSE")
updateRadioButtons(session, NAMESPACE_QC$features_used,
choices = c("Use all features" = "all"),
selected = "all")

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.

Could this code follow the same hiding/showing logic as seen from lines 169 to 176 with the log section?

Comment thread R/qc-server-sidebar.R
})

observe ({
toggleState("n_feat", input$all_feat == FALSE)

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.

Could you check if all_feat is used anywhere? if not, this can be deleted.

Comment thread R/qc-server-sidebar.R
# Enable the maximum-censored-quantile numeric only when its "do not apply
# cutoff" checkbox is unchecked.
observe ({
shinyjs::toggleState("maxQC", input$null == FALSE)

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.

input$null is really ambiguous. Could you rename to something that is easier to read?

Comment thread R/qc-server-sidebar.R
Comment on lines +295 to +303
## Old code for only 20 features. Meena thought this should be all uniques
## TODO: Need to fix this bc hard to be specific with slider.
# if (nrow(unique(get_data()[1])) < 20) {
# m_feat = nrow(unique(get_data()[1]))
# }
# else
# {
# m_feat = 20
# }

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.

You can remove this code.

Comment thread R/qc-server-sidebar.R
Comment on lines +306 to +308
m_feat = nrow(unique(get_data()$PTM[1]))
} else {
m_feat = nrow(unique(get_data()[1]))

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.

m_feat is ideally determined by finding the number of unique features per protein and taking the maximum among all proteins. Here, a feature is a concatenation of PeptideSequence, PrecursorCharge, FragmentIon, and ProductCharge

If it's too complicated, I'd hard-code this to 100 for now, the current logic doesn't make sense as it takes the number of unique proteins.

Comment thread R/qc-server-sidebar.R
radioButtons(
ns("summaryMethod"),
label = h4(
"6. Summarization",

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.

Would you be able to remove the numbering here? Plus in other pieces of the sidebar too?

Comment thread R/qc-server-summary.R
register_qc_summary <- function(input, output, session, loadpage_input,
preprocess_data, app_template) {

abundant = reactiveValues()

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.

Can you change this variable to a name that is easier to read through? It gets really confusing seeing terms like abundance and abundant in the same file. Maybe something like abundance_table_reactive_values?

Comment thread R/qc-server-turnover.R
register_qc_turnover <- function(input, output, session, app_template, get_data,
get_condition_metadata, preprocess_data) {

output$turnover_ratios_sidebar <- renderUI({

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'd call this tracer_constants_sidebar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants