agentsclimarketplace

Mass trace separation by grouping

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/mass-trace-separation-by-grouping

Use when your pandas DataFrame contains mass spectrometry data with retention time (rt) and intensity columns AND a column representing different mass-to-charge (m/z) values or ion identifiers. This is particularly relevant when generating chromatogram plots from data with multiple mass traces (e.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill mass-trace-separation-by-grouping

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

6.7 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it

mass-trace-separation-by-grouping

Summary

Separate multiple mass-to-charge (m/z) traces within a single chromatogram visualization by using the 'by' parameter to group data into faceted subplots. This skill is essential when a mass spectrometry dataset contains multiple ion traces and you need to visualize them as distinct chromatographic profiles rather than as an overlaid composite.

When to use

Use this skill when your pandas DataFrame contains mass spectrometry data with retention time (rt) and intensity columns AND a column representing different mass-to-charge (m/z) values or ion identifiers. This is particularly relevant when generating chromatogram plots from data with multiple mass traces (e.g., selected ion monitoring or multiple reaction monitoring experiments) where overlaid traces would be difficult to interpret or where regulatory/publication standards require trace-by-trace visualization.

When NOT to use

  • When you have only a single mass trace in your data; use standard (non-grouped) chromatogram plotting instead.
  • When your DataFrame does not contain a column suitable for grouping (i.e., no m/z, compound ID, or ion identifier column).
  • When you intentionally want to overlay all traces on a single plot for direct intensity comparison across masses.

Inputs

  • pandas DataFrame with columns: retention_time (rt), intensity (y), and mass_trace_identifier (e.g., m/z or ion_id)

Outputs

  • matplotlib Figure object with multiple chromatogram subplots (one per unique mass trace)
  • PNG file (optional, via savefig)

How to apply

Load your mass spectrometry data into a pandas DataFrame with columns for retention time (x-axis), intensity (y-axis), and a grouping column (e.g., m/z or compound identifier). Set the pandas plotting backend to 'ms_matplotlib' using pd.set_option('plotting.backend', 'ms_matplotlib'). Call the .plot() method with parameters x='rt', y='intensity', kind='chromatogram', and crucially add the 'by' parameter set to the name of your grouping column (e.g., by='m_z' or by='ion_id'). pyOpenMS-viz will automatically generate separate chromatogram subplots—one for each unique value in the 'by' column—with aligned axes and consistent styling. The resulting figure can be saved as PNG using matplotlib's savefig() method. The rationale is that faceted visualization prevents visual overlap and makes it easier to assess peak shape, retention time shifts, and intensity patterns within each mass trace independently.

Related tools

  • pyOpenMS-viz (Core library providing the .plot() method with 'by' parameter for faceted mass trace separation in pandas DataFrames) — https://github.com/OpenMS/pyopenms_viz
  • pandas (Data container and manipulation library; provides the DataFrame and plotting backend integration mechanism)
  • matplotlib (Backend renderer for static faceted chromatogram plots; handles figure layout, axis formatting, and file export)

Examples

ms_data.plot(x="rt", y="intensity", kind="chromatogram", by="m_z")

Evaluation signals

  • Output figure contains N subplots, where N equals the count of unique values in the 'by' grouping column.
  • Each subplot displays a chromatogram with the correct retention time and intensity values for that mass trace.
  • All subplots share consistent axis limits and styling (legend, labels, grid) as per matplotlib conventions.
  • PNG file is created without errors and displays readable subplots when opened.
  • The 'by' parameter value correctly maps to an existing column name in the DataFrame; mismatched names should raise a KeyError or warning.

Limitations

  • The 'by' parameter requires an exact column name match; typos will cause the plotting call to fail or be silently ignored depending on pandas/pyOpenMS-viz version.
  • Faceted layouts may become difficult to read if the number of unique mass traces exceeds ~9–12 (depending on figure size); in such cases, consider filtering or aggregating traces first.
  • The matplotlib backend produces static (non-interactive) subplots; for interactive exploration of many traces, consider switching to the bokeh or plotly backend.
  • Missing or NaN values in the grouping column may produce unexpected subplots or exclude rows from visualization; data cleaning is recommended beforehand.

Evidence

  • [other] Optionally use the 'by' parameter to separate different mass traces if multiple mass-to-charge values are present in the data.: "Optionally use the 'by' parameter to separate different mass traces if multiple mass-to-charge values are present in the data."
  • [readme] Flexible plotting API that interfaces directly with Pandas DataFrames: "Flexible plotting API that interfaces directly with Pandas DataFrames"
  • [other] ms_data.plot(x="rt", y="intensity", kind="chromatogram"): "ms_data.plot(x="rt", y="intensity", kind="chromatogram")"
  • [readme] Visualization of various mass spectrometry data types, including 1D chromatograms, spectra, and 2D peak maps: "Visualization of various mass spectrometry data types, including 1D chromatograms, spectra, and 2D peak maps"
  • [readme] integrates seamlessly with various plotting library backends (matpotlib, bokeh and plotly): "integrates seamlessly with various plotting library backends (matpotlib, bokeh and plotly)"

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.