Skip to content

Add metabolomics support to the Network Interpretation tab - #223

Merged
tonywu1999 merged 2 commits into
develfrom
MSstatsShiny/work/20260724_metabolomics_network_interpretation_tab
Jul 30, 2026
Merged

Add metabolomics support to the Network Interpretation tab#223
tonywu1999 merged 2 commits into
develfrom
MSstatsShiny/work/20260724_metabolomics_network_interpretation_tab

Conversation

@swaraj-neu

@swaraj-neu swaraj-neu commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Add metabolomics support to the Network Interpretation tab (Metabolite ID type, analyte-agnostic wording, PTM controls gated)

Motivation and context

The Network Interpretation tab was previously protein/PTM-focused, which constrained usability for metabolomics datasets. The update introduces metabolomics-aware behavior by adding metabolite ID support and switching UI copy/controls based on the selected application template, while also gating PTM-specific options when using metabolomics templates.

Changes

  • Updated visualizeNetworkServer() signature to accept an app_template reactive parameter (defaulting to TEMPLATES$default) and use it to drive metabolomics vs non-metabolomics UI behavior.
  • Wired the selected app_template from server.R into visualizeNetworkServer() so template-derived behavior can be applied.
  • Made help/label UI template-dependent, including:
    • Dynamically setting the “ID type” guidance and labels for metabolomics vs non-metabolomics modes.
    • Dynamically adjusting “node label display” radio-button guidance.
    • Toggling visibility of PTM-only control(s) (e.g., filter_by_ptm_site) via observeEvent(app_template()).
  • Generalized analyte-related wording across the Network Interpretation UI:
    • Replaced protein-specific terminology with analyte-agnostic wording in tooltips, instructions, and notifications (e.g., selection tags, “search in progress/error,” duplicate-add/removal messages).
    • Updated metabolomics radio-button labels (e.g., “Metabolite” → “Metabolite Name”, “Grounded Name” → “Standardized Name”).
    • Updated search failure messaging to reference the “Gilda grounding database.”
  • Adjusted network-building and labeling controls in module-visualize-network-ui.R from protein/PTM concepts to broader analyte/regulatory-network language:
    • Updated tooltip/help text across p-value, logFC, evidence/source, force-include, curation filtering, infinite fold-change inclusion, and regulation-direction explanations.
    • Switched the protein ID / node label display section header to render via uiOutput(...) rather than a static tags$label(...).
    • Changed the gene-name display radio underlying value from hgncName to entityName.
    • Renamed/refined the “Force Include” control and the analyte search placeholder accordingly.
    • Generalized the introduction text from “protein regulatory networks” to “regulatory networks.”

Tests

No unit tests were added or modified.

Coding guideline violations

No coding guideline violations were identified from the provided changes.

…e ID type, analyte-agnostic wording, PTM controls gated)
@swaraj-neu
swaraj-neu requested a review from tonywu1999 July 28, 2026 04:15
@swaraj-neu swaraj-neu self-assigned this Jul 28, 2026
@swaraj-neu swaraj-neu added the enhancement New feature or request label Jul 28, 2026
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

visualizeNetworkServer() now receives app_template, adapts controls for metabolomics mode, and updates network UI terminology from proteins to analytes. The top-level server passes the template through, while labels, tooltips, placeholders, and notifications are generalized.

Changes

Network visualization template support

Layer / File(s) Summary
Template parameter wiring
R/module-visualize-network-server.R, R/server.R
The server module accepts app_template and the top-level server passes it through.
Template-specific controls
R/module-visualize-network-server.R, R/module-visualize-network-ui.R
Metabolomics mode controls dynamic headers, radio-button choices, and PTM filter visibility.
Analyte terminology and guidance
R/module-visualize-network-server.R, R/module-visualize-network-ui.R
Selection messages, control labels, tooltips, placeholders, and network descriptions use analyte or generalized regulatory-network terminology.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested labels: Review effort 3/5

Suggested reviewers: tonywu1999

Sequence Diagram(s)

sequenceDiagram
  participant server
  participant visualizeNetworkServer
  participant networkUI
  server->>visualizeNetworkServer: pass app_template reactive
  visualizeNetworkServer->>visualizeNetworkServer: observe app_template()
  visualizeNetworkServer->>networkUI: update label headers and radio choices
  visualizeNetworkServer->>networkUI: toggle filter_by_ptm_site
Loading

Poem

A rabbit hops through analyte land,
With template switches close at hand.
Labels bloom and filters hide,
New words guide the network ride.
“Protein” molts—“analyte” stays.

🚥 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 summarizes the main change: metabolomics support for the Network Interpretation tab.
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/20260724_metabolomics_network_interpretation_tab

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: 1

🤖 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-visualize-network-server.R`:
- Around line 347-360: The Gene Name option uses entityName without a compatible
Bioconductor/MSstatsBioNet pin. In R/module-visualize-network-server.R lines
347-360 and R/module-visualize-network-ui.R lines 70-74, change the Gene Name
value back to hgncName unless you also add and document a compatible
Bioconductor/MSstatsBioNet pin across DESCRIPTION, renv.lock, and workflows.
🪄 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 Plus

Run ID: b3f5500c-9bed-4fde-8eb4-96d724e76103

📥 Commits

Reviewing files that changed from the base of the PR and between 7bd394b and c4429a5.

📒 Files selected for processing (3)
  • R/module-visualize-network-server.R
  • R/module-visualize-network-ui.R
  • R/server.R

Comment on lines +347 to +360
updateRadioButtons(session, "displayLabelType",
choices = list("Metabolite Name" = "id",
"Grounded Name" = "entityName"),
selected = "id")
shinyjs::hide("filter_by_ptm_site")
} else {
updateRadioButtons(session, "proteinIdType",
choices = list("Uniprot Mnemonic" = "Uniprot_Mnemonic",
"Uniprot" = "Uniprot"),
selected = "Uniprot")
updateRadioButtons(session, "displayLabelType",
choices = list("Protein Name" = "id",
"Gene Name" = "entityName"),
selected = "id")

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 | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n --glob 'DESCRIPTION' --glob 'renv.lock' --glob '*.R' \
  'MSstatsBioNet|displayLabelType|hgncName|entityName' .

Repository: Vitek-Lab/MSstatsShiny

Length of output: 3469


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '--- DESCRIPTION ---\n'
sed -n '1,80p' DESCRIPTION

printf '\n--- renv lock MSstatsBioNet entries ---\n'
if [ -f renv.lock ]; then
  python3 - <<'PY'
import json
from pathlib import Path
p=Path('renv.lock')
data=json.loads(p.read_text())
for section in ('Packages','R'):
    if isinstance(data.get(section), dict):
        for k,v in data[section].items():
            if k=='MSstatsBioNet':
                print(k, v)
PY
fi

printf '\n--- relevant source slices ---\n'
sed -n '330,365p' R/module-visualize-network-server.R
sed -n '655,702p' R/module-visualize-network-server.R
sed -n '55,80p' R/module-visualize-network-ui.R

printf '\n--- tests around expected column / HTML ---\n'
sed -n '24,38p' tests/testthat/test_network_visualization.R
sed -n '295,338p' tests/testthat/test_network_visualization.R

Repository: Vitek-Lab/MSstatsShiny

Length of output: 251


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- DESCRIPTION ---'
sed -n '1,80p' DESCRIPTION

printf '%s\n' ''
printf '%s\n' '--- renv lock MSstatsBioNet entries ---'
if [ -f renv.lock ]; then
  python3 - <<'PY'
import json
from pathlib import Path
p = Path('renv.lock')
data = json.loads(p.read_text())
for section in ('Packages', 'R'):
    if isinstance(data.get(section), dict):
        for k, v in data[section].items():
            if k == 'MSstatsBioNet':
                print(k, v)
PY
fi

printf '%s\n' ''
printf '%s\n' '--- relevant source slices ---'
sed -n '330,365p' R/module-visualize-network-server.R
sed -n '655,702p' R/module-visualize-network-server.R
sed -n '55,80p' R/module-visualize-network-ui.R

printf '%s\n' ''
printf '%s\n' '--- tests around expected column / HTML ---'
sed -n '24,38p' tests/testthat/test_network_visualization.R
sed -n '295,338p' tests/testthat/test_network_visualization.R

Repository: Vitek-Lab/MSstatsShiny

Length of output: 8788


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- networkVisualize function slices ---'
ast-grep outline R/module-visualize-network-server.R --match visualize --view expanded || true
sed -n '170,245p' R/module-visualize-network-server.R
python3 - <<'PY'
from pathlib import Path
p=Path('R/module-visualize-network-server.R')
text=p.read_text()
for needle in ['annotateProteinData', 'cytoscapeNetwork(subnetwork$nodes', 'deleteEdgeFromNetwork(subnetwork$edges']:
    idx=text.find(needle)
    if idx!=-1:
        print('\n--- around', needle[:30], 'at line', text[:idx].count('\n')+1, '---')
        for line in range(max(1,text[:idx].count('\n')-3), min(850,text[:idx].count('\n')+12)):
            print(f'{line:4}:', text.splitlines()[line-1])
PY

python3 - <<'PY'
import re
from pathlib import Path
text = Path('R/module-visualize-network-server.R').read_text()
for i,m in enumerate(re.finditer(r'function\s*\([^)]*\)\s*\{|function\s*\(\s*\)', text)):
    if i<120:
        pass
print('--- parse-like function starts ---')
for m in re.finditer(r'(?<![A-Za-z0-9_.])create_mock_subnetwork_nodes|export_network_html|deleteEdgeFromNetwork|cytoscapeNetwork|renderCytoscapeNetwork|cytoscapeNetwork\(subnetwork', text):
    print(text[:m.start()].count('\n')+1, text[m.start():m.end()])

print('--- line contains displayLabelType occurrences ---')
for i,line in enumerate(text.splitlines(), 1):
    if 'displayLabelType' in line:
        print(f'{i:4}: {line}')
PY

printf '%s\n' ''
printf '%s\n' '--- tests references to displayLabelType/Node Label ---'
rg -n 'displayLabelType|Node Label|hgncName|entityName|cytoscape|exportNetworkToHTML' tests R

Repository: Vitek-Lab/MSstatsShiny

Length of output: 9017


🌐 Web query:

MSstatsBioNet previewNetworkInBrowser displayLabelType hgncName entityName

💡 Result:

In the MSstatsBioNet package, the previewNetworkInBrowser function uses the displayLabelType argument to control which column from the nodes data frame is displayed as the visible label for nodes in the browser-based visualization [1][2][3]. The displayLabelType parameter accepts the following values: "id": This is the default setting, which uses the values in the id column of the nodes data frame as labels [1][2][3]. "entityName": This setting uses the values from the entityName column as labels [4][3]. Note that in some earlier versions or specific documentation contexts, this parameter is documented to accept "hgncName" instead of "entityName" [1][5][6]. Depending on the specific version of the package installed, if "hgncName" does not work, "entityName" should be used, as it is the standard column name described in current technical documentation for groundable entities [4][2][3]. Usage Example: previewNetworkInBrowser(nodes, edges, displayLabelType = "entityName")

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- package dependency files ---'
git ls-files | rg '(^|/)(DESCRIPTION$|DESCRIPTION\.in$|NAMESPACE$|renv\.lock$|LICENSE\.staged$|\.github/.+\.ya?ml$|packrat/|airlock/|requirements\.txt)$' || true

printf '%s\n' ''
printf '%s\n' '--- MSstatsBioNet version pins / refs ---'
rg -n --glob '*.{R,md,yaml,yml,lock,toml}' \
  'MSstatsBioNet|MSstatsBioNetDev|MSstatsBioNetBioc|Bioconductor|biocVersion|packrat|renv|r-dependences|r2d3|DESCRIPTION\.in|staged' . | head -n 200 || true

printf '%s\n' ''
printf '%s\n' '--- GitHub metadata and remote references ---'
git remote -v || true
git branch -a --no-color | head -n 50 || true

Repository: Vitek-Lab/MSstatsShiny

Length of output: 2546


🌐 Web query:

Bioconductor release MSstatsBioNet cytoscapeNetwork displayLabelType entityName hgnc

💡 Result:

In the MSstatsBioNet R package, the cytoscapeNetwork function (and related functions like previewNetworkInBrowser) uses the displayLabelType parameter to control the visible node labels in the generated network visualization [1][2][3]. The valid options for displayLabelType have evolved across package versions: 1. Traditional/Earlier Versions: The option was typically "id" (default) or "hgncName" [1][4][5]. When using "hgncName", the nodes data frame must include a column named hgncName [1][6]. 2. Recent Versions: The parameter has transitioned to using "id" (default) or "entityName" [3]. In these versions, the nodes data frame should include an entityName column (which may contain semicolon-joined names for multi-grounded entities) [3]. To determine which option is correct for your specific installation, you can check your package's documentation using?cytoscapeNetwork in R or by reviewing the manual for your specific version [1][3]. If your nodes data frame contains gene symbols, ensure you are providing the corresponding column name (hgncName or entityName) as the displayLabelType value [6][3].

Citations:


Align the Bioconductor pin with the new entityName display label.

entityName is valid on newer MSstatsBioNet releases, but this package has no locked Bioconductor/MSstatsBioNet version in DESCRIPTION, renv.lock, or workflows. On older Bioconductor releases where node labels use hgncName, selecting “Gene Name” can fail at render/export/script generation. Add a compatible Bioconductor/MSstatsBioNet pin or keep the existing hgncName value until that pin is documented.

📍 Affects 2 files
  • R/module-visualize-network-server.R#L347-L360 (this comment)
  • R/module-visualize-network-ui.R#L70-L74
🤖 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-visualize-network-server.R` around lines 347 - 360, The Gene Name
option uses entityName without a compatible Bioconductor/MSstatsBioNet pin. In
R/module-visualize-network-server.R lines 347-360 and
R/module-visualize-network-ui.R lines 70-74, change the Gene Name value back to
hgncName unless you also add and document a compatible
Bioconductor/MSstatsBioNet pin across DESCRIPTION, renv.lock, and workflows.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
R/module-visualize-network-server.R (2)

322-329: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Align the help text with the radio-button label.

The choice is labeled “Standardized Name”, but the tooltip calls it “Grounded Name”. Use one term consistently so users understand which label they are selecting.

🤖 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-visualize-network-server.R` around lines 322 - 329, Update the
metabolomics tooltip text in output$displayLabelHeader so it uses “Standardized
Name” instead of “Grounded Name,” matching the radio-button label while
preserving the rest of the help text.

342-363: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Reset PTM filtering when switching to metabolomics.

shinyjs::hide() only hides the PTM checkbox’s DOM element; it does not clear input$filter_by_ptm_site. If PTM filtering was enabled in a protein template, the stale TRUE value is still forwarded through getInputParameters() and emitted in generated code, so metabolomics networks can remain PTM-filtered.

Set the checkbox to FALSE when entering the metabolomics template, using shiny::updateCheckboxInput().

🤖 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-visualize-network-server.R` around lines 342 - 363, In the
metabolomics branch of the app_template() observer, reset the filter_by_ptm_site
checkbox to FALSE with shiny::updateCheckboxInput() before or alongside hiding
it; leave the existing protein-template behavior unchanged.
🤖 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.

Outside diff comments:
In `@R/module-visualize-network-server.R`:
- Around line 322-329: Update the metabolomics tooltip text in
output$displayLabelHeader so it uses “Standardized Name” instead of “Grounded
Name,” matching the radio-button label while preserving the rest of the help
text.
- Around line 342-363: In the metabolomics branch of the app_template()
observer, reset the filter_by_ptm_site checkbox to FALSE with
shiny::updateCheckboxInput() before or alongside hiding it; leave the existing
protein-template behavior unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ec8ef77a-bd76-497f-b714-8aed9d8c727f

📥 Commits

Reviewing files that changed from the base of the PR and between c4429a5 and dbfbf3b.

📒 Files selected for processing (1)
  • R/module-visualize-network-server.R

@tonywu1999
tonywu1999 merged commit 63674ae into devel Jul 30, 2026
2 checks passed
@tonywu1999
tonywu1999 deleted the MSstatsShiny/work/20260724_metabolomics_network_interpretation_tab branch July 30, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants