Rename metabolomics upload labels and expand tooltips - #226
Conversation
📝 WalkthroughWalkthroughThe MZmine metabolomics upload guidance now separates sample metadata annotations from compound annotations. Tooltips document required fields and SIRIUS handling. Generated workflow labels and UI tests use the updated terminology. ChangesAnnotation input terminology
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 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
🧹 Nitpick comments (2)
R/module-loadpage-ui.R (1)
310-314: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winDocument the SIRIUS schema version.
The tooltip lists
mappingFeatureIdandname, but MSstatsConvert validates the input against SIRIUS 6 output. Users of other SIRIUS versions may need to rename columns before upload. Add this caveat to prevent failures when users follow the displayed field list. (bioconductor.posit.co)🤖 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-loadpage-ui.R` around lines 310 - 314, Update the tooltip text in the sirius_annotations fileInput to state that the expected schema is from SIRIUS 6 and that other SIRIUS versions may require column renaming before upload, while retaining the existing mappingFeatureId and name guidance.Source: MCP tools
tests/testthat/test-module-loadpage-ui.R (1)
589-590: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winTest the expanded tooltip contract.
These assertions cover the two renamed headings, but not the new required-column and matching guidance. Add checks for the MZmine columns,
Run/Condition/BioReplicate,id/compound_name/score, andmappingFeatureId/name. Add a focusedgetDataCode()assertion to verify that the sample metadata and compound annotation paths remain mapped to distinct converter arguments.Proposed assertions
expect_true(grepl("Sample metadata annotations", uploads_html, fixed = TRUE)) expect_true(grepl("Compound annotations", uploads_html, fixed = TRUE)) + expect_true(grepl("row ID, row m/z and row retention time", uploads_html, fixed = TRUE)) + expect_true(grepl("Run, Condition and BioReplicate", uploads_html, fixed = TRUE)) + expect_true(grepl("id, compound_name and score", uploads_html, fixed = TRUE)) + expect_true(grepl("mappingFeatureId and name", uploads_html, fixed = TRUE))🤖 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 `@tests/testthat/test-module-loadpage-ui.R` around lines 589 - 590, Expand the tooltip assertions near the existing “Sample metadata annotations” and “Compound annotations” checks to cover the required MZmine columns, Run/Condition/BioReplicate, id/compound_name/score, and mappingFeatureId/name guidance. Add a focused getDataCode() assertion verifying that sample metadata and compound annotation paths map to distinct converter arguments.
🤖 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-loadpage-ui.R`:
- Around line 301-304: Update the “Sample metadata annotations” tooltip text in
the h5 markup to state that MZMinetoMSstatsFormat() standardizes a value such as
“sampleA.mzML Peak area” to “sampleAmzML”, and instruct users that Run must
match this standardized name; remove the claim that spaces and dots are ignored
during matching.
---
Nitpick comments:
In `@R/module-loadpage-ui.R`:
- Around line 310-314: Update the tooltip text in the sirius_annotations
fileInput to state that the expected schema is from SIRIUS 6 and that other
SIRIUS versions may require column renaming before upload, while retaining the
existing mappingFeatureId and name guidance.
In `@tests/testthat/test-module-loadpage-ui.R`:
- Around line 589-590: Expand the tooltip assertions near the existing “Sample
metadata annotations” and “Compound annotations” checks to cover the required
MZmine columns, Run/Condition/BioReplicate, id/compound_name/score, and
mappingFeatureId/name guidance. Add a focused getDataCode() assertion verifying
that sample metadata and compound annotation paths map to distinct converter
arguments.
🪄 Autofix
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: ad7e8bc2-eecf-4eca-817c-96b5a3fdaceb
📒 Files selected for processing (3)
R/module-loadpage-ui.RR/utils.Rtests/testthat/test-module-loadpage-ui.R
| h5("Sample metadata annotations", class = "icon-wrapper", | ||
| icon("question-circle", lib = "font-awesome"), | ||
| div("Maps each run/sample to its condition and bioreplicate.", | ||
| div("Describes the experimental design, using the columns Run, Condition and BioReplicate. Each Run should be the sample name from the quant table with the trailing Peak area dropped, so 'sampleA.mzML Peak area' becomes 'sampleA.mzML'. Spaces and dots are ignored when matching, so they do not need to be exact.", | ||
| class = "icon-tooltip"))), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- target file context ---'
cat -n R/module-loadpage-ui.R | sed -n '285,320p'
printf '%s\n' '--- normalization-related references ---'
rg -n -i 'Peak area|mappingFeatureId|sample.*name|normalize|MSstatsConvert|Run' . \
-g '!*.Rproj.user/**' -g '!renv/library/**' | head -200
printf '%s\n' '--- repository metadata ---'
git ls-files | rg '(^|/)(DESCRIPTION|NAMESPACE|renv.lock|R/module-loadpage-ui\\.R)$' || trueRepository: Vitek-Lab/MSstatsShiny
Length of output: 24058
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- MZMine conversion call path ---'
cat -n R/utils.R | sed -n '300,370p'
printf '%s\n' '--- MZMine-related tests and fixtures ---'
rg -n -i 'mzmine|MZMinetoMSstatsFormat|Peak area|mzML|mappingFeatureId|sirius' tests R DESCRIPTION vignettes \
-g '*.R' -g '*.Rmd' -g '*.csv' -g '*.tsv' | head -250
printf '%s\n' '--- package/version declarations ---'
rg -n 'MSstatsConvert|Version|Remotes|Depends|Imports' DESCRIPTION renv.lock 2>/dev/null || trueRepository: Vitek-Lab/MSstatsShiny
Length of output: 12601
🌐 Web query:
MSstatsConvert MZMinetoMSstatsFormat Run sample name spaces dots Peak area normalization
💡 Result:
In MSstatsConvert, the MZMinetoMSstatsFormat function processes MZMine feature-quantification tables by automatically standardizing column names [1][2]. During this standardization process, spaces and dots are removed from the column names [1][2]. Specifically, when preparing your annotation file, you must match the Run values to these standardized names [1][3]. For example, a raw column name in your MZMine input such as "sampleA.mzML Peak area" is transformed into "sampleAmzML" after the spaces and dots are removed and the trailing "Peakarea" suffix is stripped [1]. Consequently, your annotation file should use "sampleAmzML" as the Run identifier [1]. Regarding normalization, MSstats does not perform peak area normalization within the MZMinetoMSstatsFormat conversion function itself [1][2]. Instead, normalization is typically handled downstream by the MSstats dataProcess function [4]. A standard discovery workflow involves using the equalizeMedians normalization method within dataProcess, which operates on the long-format data produced by the conversion [4]. Summary of Key Steps: 1. Standardization: MZMinetoMSstatsFormat collapses spaces and removes dots from sample-specific " Peak area" column headers (e.g., "sampleA.mzML Peak area" becomes "sampleAmzML") [1][2]. 2. Annotation: Ensure your annotation table's Run column values match these standardized names [1]. 3. Normalization: Perform normalization after conversion using the dataProcess function (e.g., setting normalization = "equalizeMedians") [4].
Citations:
- 1: https://bioc.r-universe.dev/MSstatsConvert/MSstatsConvert.pdf
- 2: https://bioconductor.posit.co/packages/3.24/bioc/manuals/MSstatsConvert/man/MSstatsConvert.pdf
- 3: https://bioconductor.statistik.tu-dortmund.de/packages/3.24/bioc/manuals/MSstatsConvert/man/MSstatsConvert.pdf
- 4: http://bioconductor.posit.co/packages/devel/bioc/vignettes/MSstats/inst/doc/MSstatsMetabolomics.html
🏁 Script executed:
#!/bin/bash
set -eu
python3 - <<'PY'
from urllib.request import Request, urlopen
from urllib.parse import quote
import re
urls = [
"https://raw.githubusercontent.com/Vitek-Lab/MSstatsConvert/master/R/MZMinetoMSstatsFormat.R",
"https://raw.githubusercontent.com/Vitek-Lab/MSstatsConvert/main/R/MZMinetoMSstatsFormat.R",
"https://bioconductor.org/packages/release/bioc/src/contrib/MSstatsConvert_2.0.0.tar.gz",
]
for url in urls:
print(f"--- {url} ---")
try:
req = Request(url, headers={"User-Agent": "Mozilla/5.0"})
data = urlopen(req, timeout=15).read()
print(f"bytes={len(data)}")
if url.endswith(".R"):
text = data.decode("utf-8", "replace")
for i, line in enumerate(text.splitlines(), 1):
if re.search(r"Run|Peak|gsub|colnames|annotation|mzmine", line, re.I):
print(f"{i}: {line}")
else:
print(data[:80])
except Exception as exc:
print(type(exc).__name__, exc)
PYRepository: Vitek-Lab/MSstatsShiny
Length of output: 885
🌐 Web query:
site:github.com MSstatsConvert MZMinetoMSstatsFormat source Run Peak area
💡 Result:
The MZMinetoMSstatsFormat function is a converter provided by the R package MSstatsConvert that imports metabolomics data processed in MZmine into the format required for statistical analysis by MSstats [1][2]. Regarding your query about Run and Peak area: 1. Data Requirements: MSstatsConvert functions, including MZMinetoMSstatsFormat, expect input data to represent features (such as ions or compounds) across various runs (samples) [1]. 2. Peak Area: The function is designed to handle quantitative representations of feature abundance, which commonly include peak areas under the curve (AUC), peak heights, or other relevant intensity metrics [3]. 3. Workflow Context: When using MZMinetoMSstatsFormat, the conversion process typically involves: - Defining ProteinName assignments: The converter uses a three-tier strategy to assign identities to features: first by the best MZmine spectral-library compound name, second (optionally) by SIRIUS structure-identification mappings, and third by a fallback identifier based on m/z and retention time (e.g., round(m/z)_round(RT)) [4][2]. - Integration with MSstats: Once converted, this data is prepared for MSstats workflows, such as data processing (summarization), normalization (e.g., equalizeMedians), and differential abundance testing [4]. For further implementation details, you can refer to the official documentation and the MSstatsMetabolomics vignette within the MSstats ecosystem, which demonstrates the full workflow from data conversion to visualization [4][5].
Citations:
- 1: https://github.com/Vitek-Lab/MSstatsConvert/
- 2: Add SIRIUS annotations and mz_rt fallback to MZMine converter (three-tier ProteinName) MSstatsConvert#138
- 3: https://github.com/Vitek-Lab/MSstatsConvert/blob/devel/vignettes/msstats_data_format.Rmd
- 4: Add MZMine metabolomics vignette and re-export MZMinetoMSstatsFormat MSstats#211
- 5: https://github.com/bioc/MSstatsConvert
🏁 Script executed:
#!/bin/bash
set -eu
python3 - <<'PY'
from urllib.request import Request, urlopen
import ssl, re
ctx = ssl._create_unverified_context()
urls = [
"https://raw.githubusercontent.com/Vitek-Lab/MSstatsConvert/devel/R/MZMinetoMSstatsFormat.R",
"https://raw.githubusercontent.com/Vitek-Lab/MSstatsConvert/master/R/MZMinetoMSstatsFormat.R",
"https://raw.githubusercontent.com/Vitek-Lab/MSstatsConvert/main/R/MZMinetoMSstatsFormat.R",
]
for url in urls:
print(f"--- {url} ---")
try:
req = Request(url, headers={"User-Agent": "Mozilla/5.0"})
text = urlopen(req, context=ctx, timeout=15).read().decode("utf-8", "replace")
print(f"bytes={len(text.encode())}")
for i, line in enumerate(text.splitlines(), 1):
if re.search(r"Run|Peak|gsub|colnames|annotation|mzmine", line, re.I):
print(f"{i}: {line}")
except Exception as exc:
print(type(exc).__name__, exc)
PYRepository: Vitek-Lab/MSstatsShiny
Length of output: 565
🏁 Script executed:
#!/bin/bash
set -eu
python3 - <<'PY'
from urllib.request import Request, urlopen
import json, ssl
ctx = ssl._create_unverified_context()
url = "https://api.github.com/repos/Vitek-Lab/MSstatsConvert/git/trees/devel?recursive=1"
req = Request(url, headers={"User-Agent": "Mozilla/5.0", "Accept": "application/vnd.github+json"})
try:
data = json.loads(urlopen(req, context=ctx, timeout=20).read())
for item in data.get("tree", []):
path = item.get("path", "")
if "MZmine" in path or "mzmine" in path or path.endswith(".R"):
print(path)
except Exception as exc:
print(type(exc).__name__, exc)
PYRepository: Vitek-Lab/MSstatsShiny
Length of output: 3311
🏁 Script executed:
#!/bin/bash
set -eu
python3 - <<'PY'
from urllib.request import Request, urlopen
import ssl
ctx = ssl._create_unverified_context()
base = "https://raw.githubusercontent.com/Vitek-Lab/MSstatsConvert/devel/"
paths = [
"R/converters_MZMinetoMSstatsFormat.R",
"R/clean_MZMine.R",
"inst/tinytest/test_converters_MZMinetoMSstatsFormat.R",
]
for path in paths:
print(f"--- {path} ---")
req = Request(base + path, headers={"User-Agent": "Mozilla/5.0"})
text = urlopen(req, context=ctx, timeout=20).read().decode("utf-8", "replace")
for i, line in enumerate(text.splitlines(), 1):
print(f"{i}: {line}")
PYRepository: Vitek-Lab/MSstatsShiny
Length of output: 21402
Document the standardized Run value.
MZMinetoMSstatsFormat() converts sampleA.mzML Peak area to sampleAmzML. The annotation Run value must match this standardized name. Do not state that spaces and dots are ignored during matching.
🤖 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-loadpage-ui.R` around lines 301 - 304, Update the “Sample metadata
annotations” tooltip text in the h5 markup to state that MZMinetoMSstatsFormat()
standardizes a value such as “sampleA.mzML Peak area” to “sampleAmzML”, and
instruct users that Run must match this standardized name; remove the claim that
spaces and dots are ignored during matching.
Source: MCP tools
Motivation and context
Metabolomics upload labels did not clearly distinguish sample metadata annotations from compound annotations. The upload guidance also needed more detail about required columns, matching behavior, and optional SIRIUS annotation fields.
The changes rename the labels, expand the guidance, update generated MZmine workflow paths, and add UI test coverage.
Changes
R/module-loadpage-ui.R.R/utils.Rto use separate sample metadata and compound annotation file paths.Unit tests
tests/testthat/test-module-loadpage-ui.R.Sample metadata annotationsandCompound annotationslabels in the MZmine upload UI.Coding guidelines
No coding-guideline violations were identified.