Add metabolomics support to the Network Interpretation tab - #223
Conversation
…e ID type, analyte-agnostic wording, PTM controls gated)
📝 WalkthroughWalkthrough
ChangesNetwork visualization template support
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 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
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
R/module-visualize-network-server.RR/module-visualize-network-ui.RR/server.R
| 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") |
There was a problem hiding this comment.
🎯 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.RRepository: 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.RRepository: 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 RRepository: 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:
- 1: https://bioc-release.r-universe.dev/MSstatsBioNet/doc/manual.html
- 2: http://bioconductor.posit.co/packages/3.24/bioc/manuals/MSstatsBioNet/man/MSstatsBioNet.pdf
- 3: http://bioc.r-universe.dev/MSstatsBioNet/MSstatsBioNet.pdf
- 4: http://bioc.r-universe.dev/MSstatsBioNet/doc/manual.html
- 5: https://bioconductor.org/packages/devel/bioc/vignettes/MSstatsBioNet/inst/doc/MSstatsBioNet.html
- 6: https://bioconductor.statistik.uni-dortmund.de/packages/3.23/bioc/manuals/MSstatsBioNet/man/MSstatsBioNet.pdf
🏁 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 || trueRepository: 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:
- 1: https://bioc-release.r-universe.dev/MSstatsBioNet/doc/manual.html
- 2: http://bioconductor-source.posit.co/packages/release/bioc/manuals/MSstatsBioNet/man/MSstatsBioNet.pdf
- 3: http://bioconductor.posit.co/packages/3.24/bioc/manuals/MSstatsBioNet/man/MSstatsBioNet.pdf
- 4: https://bioconductor.posit.co/packages/3.23/bioc/manuals/MSstatsBioNet/man/MSstatsBioNet.pdf
- 5: https://bioconductor.statistik.tu-dortmund.de/packages/3.23/bioc/manuals/MSstatsBioNet/man/MSstatsBioNet.pdf
- 6: https://cran.asia/packages/devel/bioc/vignettes/MSstatsBioNet/inst/doc/Cytoscape-Visualization.html
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.
There was a problem hiding this comment.
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 winAlign 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 winReset PTM filtering when switching to metabolomics.
shinyjs::hide()only hides the PTM checkbox’s DOM element; it does not clearinput$filter_by_ptm_site. If PTM filtering was enabled in a protein template, the staleTRUEvalue is still forwarded throughgetInputParameters()and emitted in generated code, so metabolomics networks can remain PTM-filtered.Set the checkbox to
FALSEwhen entering the metabolomics template, usingshiny::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
📒 Files selected for processing (1)
R/module-visualize-network-server.R
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
visualizeNetworkServer()signature to accept anapp_templatereactive parameter (defaulting toTEMPLATES$default) and use it to drive metabolomics vs non-metabolomics UI behavior.app_templatefromserver.RintovisualizeNetworkServer()so template-derived behavior can be applied.filter_by_ptm_site) viaobserveEvent(app_template()).module-visualize-network-ui.Rfrom protein/PTM concepts to broader analyte/regulatory-network language:uiOutput(...)rather than a statictags$label(...).hgncNametoentityName.Tests
No unit tests were added or modified.
Coding guideline violations
No coding guideline violations were identified from the provided changes.