spectrum-peak-counting-and-reporting
Summary
Count and report the number of peaks retained in a mass spectrum after applying a selected noise-threshold method (relative_abundance, signal_noise, or log mode), producing structured records of method identifier and peak counts per ionization mode for comparative evaluation.
When to use
When you need to quantify and compare the filtering efficacy of mutually exclusive noise-threshold methods on the same input mass spectrum, or when validating that a selected noise-filtering strategy retains an expected number of peaks for downstream molecular formula assignment.
When NOT to use
- Input is a mass list that has already been noise-filtered or centroided by the instrument vendor; peak counting is post-hoc reporting, not applicable to data that lacks the raw signal intensity distribution needed to re-apply threshold criteria.
- Analysis goal requires identification of isotopic clusters or fine structure; peak counting reports total peaks but does not distinguish monoisotopic, isotopic, or artifact peaks.
- Spectrum has already been processed through multiple conflicting noise-threshold steps; multiple successive applications of different methods will compound filtering artifacts.
Inputs
- Raw mass spectrum file (Bruker .d, ThermoFisher .raw, or CoreMS HDF5 format)
- MSParameters configuration object with noise-threshold method selection
- Noise-threshold parameters: relative_abundance minimum threshold, signal_noise ratio threshold, or log standard deviation cutoff
Outputs
- Peak count (integer) per noise-threshold method
- Method identifier (string: 'relative_abundance', 'signal_noise', or 'log')
- Ionization mode label (e.g., 'ESI_NEG')
- Structured JSON or CSV record with method name, peak count, and mode
How to apply
Load a raw mass spectrum (e.g., ESI_NEG_SRFA.d in Bruker or .raw format) using CoreMS MSParameters factory. Select one of three mutually exclusive noise-threshold methods: 'relative_abundance' (filtered by minimum relative abundance parameter), 'signal_noise' (filtered by signal-to-noise ratio threshold), or 'log' (filtered by standard deviation parameter). Apply the selected method to the loaded spectrum using CoreMS peak-filtering routines. Capture and serialize the resulting peak count, method name, and ionization mode identifier as a structured JSON or CSV record. Compare peak counts across methods to evaluate which filtering strategy best balances noise suppression and analyte retention for your analysis goal.
Related tools
- CoreMS (Provides MSParameters factory to instantiate noise-threshold configuration, implements conditional dispatch logic for three mutually exclusive threshold methods, and applies peak-filtering routines to compute final peak counts.) — https://github.com/EMSL-Computing/CoreMS
- pandas (Serializes peak count results and method metadata into structured DataFrames; enables export to CSV or Excel for downstream comparison.)
- Docker (Provides containerized execution environment to ensure reproducible CoreMS-based peak counting workflows across systems.)
Examples
from corems.encapsulation.factory.parameters import MSParameters
from corems.data_source.data_source_factory import run_from_file
import json
ms_obj = run_from_file('tests/tests_data/ftms/ESI_NEG_SRFA.d', MSParameters)
for spectrum in ms_obj:
spectrum.apply_noise_threshold(SNR_threshold=10, noise_method='signal_noise')
result = {'method': 'signal_noise', 'peak_count': len(spectrum.peaks), 'ionization_mode': 'ESI_NEG'}
print(json.dumps(result))
Evaluation signals
- Peak count is a non-negative integer; verify it is ≥ 0 and ≤ total m/z centroids detected in the raw spectrum.
- Method identifier matches exactly one of: 'relative_abundance', 'signal_noise', or 'log'; no other mode is reported.
- Peak counts differ across the three mutually exclusive methods applied to the same input spectrum (different methods should produce different retention counts unless the spectrum is trivial).
- Ionization mode label is correctly inherited from input spectrum metadata (e.g., 'ESI_NEG' for negative-ion ESI data).
- JSON or CSV output conforms to expected schema: columns for method name, peak_count, ionization_mode, and optional timestamp; no missing or malformed entries.
Limitations
- Peak count is a global statistic; it does not distinguish peak quality, confidence, or role in molecular formula assignment.
- The three noise-threshold methods are mutually exclusive; a single spectrum can be processed under only one method at a time, preventing simultaneous multi-method evaluation within a single call.
- Peak counting does not account for m/z calibration accuracy; miscalibrated spectra may produce artificially high or low peak counts if threshold criteria are m/z-dependent.
- CoreMS peak-filtering routines are designed for small-molecule analysis (ESI and FT-MS); applicability to GC-MS, LC-MS, or high-resolution imaging mass spectrometry workflows is not documented in the provided evidence.
Evidence
- [other] CoreMS provides three mutually exclusive noise threshold methods: 'relative_abundance' (filtered by minimum relative abundance parameter), 'signal_noise' (filtered by signal-to-noise ratio threshold), and 'log' (filtered by standard deviation parameter), each producing different peak retention counts for the same input spectrum.: "CoreMS provides three mutually exclusive noise threshold methods: 'relative_abundance' (filtered by minimum relative abundance parameter), 'signal_noise' (filtered by signal-to-noise ratio"
- [other] Load mass spectrum data from ESI_NEG_SRFA.d using CoreMS MSParameters factory to instantiate noise-threshold configuration. Implement conditional dispatch logic that selects one of three mutually exclusive noise-threshold methods (COND-001, COND-002, COND-003) based on spectrum properties or user input. Apply the selected noise-threshold method to the loaded spectrum using CoreMS peak-filtering routines. Capture the resulting peak count per ionization mode and method name. Serialize the results (method identifier, peak count per mode) as a structured JSON or CSV record.: "Load mass spectrum data from ESI_NEG_SRFA.d using CoreMS MSParameters factory to instantiate noise-threshold configuration...Apply the selected noise-threshold method to the loaded spectrum using"
- [readme] CoreMS is a comprehensive mass spectrometry framework for software development and data analysis of small molecules analysis.: "CoreMS is a comprehensive mass spectrometry framework for software development and data analysis of small molecules analysis"
- [other] from corems.encapsulation.factory.parameters import MSParameters: "from corems.encapsulation.factory.parameters import MSParameters"
- [readme] Bruker Solarix (CompassXtract), Bruker Solarix transients, ser and fid (FT magnitude mode only), ThermoFisher (.raw), Spectroswiss signal booster data-acquisition station (.hdf5): "Bruker Solarix (CompassXtract), Bruker Solarix transients, ser and fid (FT magnitude mode only), ThermoFisher (.raw)"
1---2name: spectrum-peak-counting-and-reporting3description: Use when when you need to quantify and compare the filtering efficacy of mutually exclusive noise-threshold methods on the same input mass spectrum, or when validating that a selected noise-filtering strategy retains an expected number of peaks for downstream molecular formula assignment.4license: CC-BY-4.05---67# spectrum-peak-counting-and-reporting89## Summary1011Count and report the number of peaks retained in a mass spectrum after applying a selected noise-threshold method (relative_abundance, signal_noise, or log mode), producing structured records of method identifier and peak counts per ionization mode for comparative evaluation.1213## When to use1415When you need to quantify and compare the filtering efficacy of mutually exclusive noise-threshold methods on the same input mass spectrum, or when validating that a selected noise-filtering strategy retains an expected number of peaks for downstream molecular formula assignment.1617## When NOT to use1819- Input is a mass list that has already been noise-filtered or centroided by the instrument vendor; peak counting is post-hoc reporting, not applicable to data that lacks the raw signal intensity distribution needed to re-apply threshold criteria.20- Analysis goal requires identification of isotopic clusters or fine structure; peak counting reports total peaks but does not distinguish monoisotopic, isotopic, or artifact peaks.21- Spectrum has already been processed through multiple conflicting noise-threshold steps; multiple successive applications of different methods will compound filtering artifacts.2223## Inputs2425- Raw mass spectrum file (Bruker .d, ThermoFisher .raw, or CoreMS HDF5 format)26- MSParameters configuration object with noise-threshold method selection27- Noise-threshold parameters: relative_abundance minimum threshold, signal_noise ratio threshold, or log standard deviation cutoff2829## Outputs3031- Peak count (integer) per noise-threshold method32- Method identifier (string: 'relative_abundance', 'signal_noise', or 'log')33- Ionization mode label (e.g., 'ESI_NEG')34- Structured JSON or CSV record with method name, peak count, and mode3536## How to apply3738Load a raw mass spectrum (e.g., ESI_NEG_SRFA.d in Bruker or .raw format) using CoreMS MSParameters factory. Select one of three mutually exclusive noise-threshold methods: 'relative_abundance' (filtered by minimum relative abundance parameter), 'signal_noise' (filtered by signal-to-noise ratio threshold), or 'log' (filtered by standard deviation parameter). Apply the selected method to the loaded spectrum using CoreMS peak-filtering routines. Capture and serialize the resulting peak count, method name, and ionization mode identifier as a structured JSON or CSV record. Compare peak counts across methods to evaluate which filtering strategy best balances noise suppression and analyte retention for your analysis goal.3940## Related tools4142- **CoreMS** (Provides MSParameters factory to instantiate noise-threshold configuration, implements conditional dispatch logic for three mutually exclusive threshold methods, and applies peak-filtering routines to compute final peak counts.) — https://github.com/EMSL-Computing/CoreMS43- **pandas** (Serializes peak count results and method metadata into structured DataFrames; enables export to CSV or Excel for downstream comparison.)44- **Docker** (Provides containerized execution environment to ensure reproducible CoreMS-based peak counting workflows across systems.)4546## Examples4748```49from corems.encapsulation.factory.parameters import MSParameters50from corems.data_source.data_source_factory import run_from_file51import json5253ms_obj = run_from_file('tests/tests_data/ftms/ESI_NEG_SRFA.d', MSParameters)54for spectrum in ms_obj:55 spectrum.apply_noise_threshold(SNR_threshold=10, noise_method='signal_noise')56 result = {'method': 'signal_noise', 'peak_count': len(spectrum.peaks), 'ionization_mode': 'ESI_NEG'}57 print(json.dumps(result))58```5960## Evaluation signals6162- Peak count is a non-negative integer; verify it is ≥ 0 and ≤ total m/z centroids detected in the raw spectrum.63- Method identifier matches exactly one of: 'relative_abundance', 'signal_noise', or 'log'; no other mode is reported.64- Peak counts differ across the three mutually exclusive methods applied to the same input spectrum (different methods should produce different retention counts unless the spectrum is trivial).65- Ionization mode label is correctly inherited from input spectrum metadata (e.g., 'ESI_NEG' for negative-ion ESI data).66- JSON or CSV output conforms to expected schema: columns for method name, peak_count, ionization_mode, and optional timestamp; no missing or malformed entries.6768## Limitations6970- Peak count is a global statistic; it does not distinguish peak quality, confidence, or role in molecular formula assignment.71- The three noise-threshold methods are mutually exclusive; a single spectrum can be processed under only one method at a time, preventing simultaneous multi-method evaluation within a single call.72- Peak counting does not account for m/z calibration accuracy; miscalibrated spectra may produce artificially high or low peak counts if threshold criteria are m/z-dependent.73- CoreMS peak-filtering routines are designed for small-molecule analysis (ESI and FT-MS); applicability to GC-MS, LC-MS, or high-resolution imaging mass spectrometry workflows is not documented in the provided evidence.7475## Evidence7677- [other] CoreMS provides three mutually exclusive noise threshold methods: 'relative_abundance' (filtered by minimum relative abundance parameter), 'signal_noise' (filtered by signal-to-noise ratio threshold), and 'log' (filtered by standard deviation parameter), each producing different peak retention counts for the same input spectrum.: "CoreMS provides three mutually exclusive noise threshold methods: 'relative_abundance' (filtered by minimum relative abundance parameter), 'signal_noise' (filtered by signal-to-noise ratio"78- [other] Load mass spectrum data from ESI_NEG_SRFA.d using CoreMS MSParameters factory to instantiate noise-threshold configuration. Implement conditional dispatch logic that selects one of three mutually exclusive noise-threshold methods (COND-001, COND-002, COND-003) based on spectrum properties or user input. Apply the selected noise-threshold method to the loaded spectrum using CoreMS peak-filtering routines. Capture the resulting peak count per ionization mode and method name. Serialize the results (method identifier, peak count per mode) as a structured JSON or CSV record.: "Load mass spectrum data from ESI_NEG_SRFA.d using CoreMS MSParameters factory to instantiate noise-threshold configuration...Apply the selected noise-threshold method to the loaded spectrum using"79- [readme] CoreMS is a comprehensive mass spectrometry framework for software development and data analysis of small molecules analysis.: "CoreMS is a comprehensive mass spectrometry framework for software development and data analysis of small molecules analysis"80- [other] from corems.encapsulation.factory.parameters import MSParameters: "from corems.encapsulation.factory.parameters import MSParameters"81- [readme] Bruker Solarix (CompassXtract), Bruker Solarix transients, ser and fid (FT magnitude mode only), ThermoFisher (.raw), Spectroswiss signal booster data-acquisition station (.hdf5): "Bruker Solarix (CompassXtract), Bruker Solarix transients, ser and fid (FT magnitude mode only), ThermoFisher (.raw)"