spxtacular is a Python library for mass spectrometry spectrum processing. It provides a chainable Spectrum API covering the full centroid-to-neutral-mass pipeline: denoising, isotope deconvolution, neutral mass conversion, fragment matching, and PSM scoring — with interactive Plotly visualizations throughout.
Part of the tacular-omics ecosystem alongside peptacular, paftacular, and mzmlpy.
pip install spxtacular
# Optional: Numba JIT acceleration (~3–4× faster deconvolution)
pip install spxtacular[numba]
# Optional: share spectra as compact URL-safe tokens (spectrl)
pip install spxtacular[spectrl]
# Optional: raw-file readers — Bruker .d (bruker) and/or mzML (mzml)
pip install spxtacular[bruker] # tdfpy — DReader
pip install spxtacular[mzml] # mzmlpy — MzmlReader
pip install spxtacular[readers] # both readers
# Everything (numba + both readers + spectrl)
pip install spxtacular[all]import spxtacular as spx
spec = spx.Spectrum(mz=mz_array, intensity=intensity_array)
# Full pipeline: denoise → deconvolute → filter → neutral mass
neutral = (
spec
.denoise(method="mad")
.deconvolute(charge_range=(1, 5), tolerance=10, tolerance_type="ppm", min_score=0.4)
.decharge()
)
neutral.plot(title="Neutral masses").show()| Feature | Description |
|---|---|
| Isotope deconvolution | Bhattacharyya-scored greedy algorithm; optional Numba JIT acceleration |
| Quality filtering | min_score, m/z, intensity, charge, and ion mobility filters |
| Neutral mass conversion | decharge() converts charged clusters to neutral masses |
| Fragment matching | match_fragments() with ppm/Da tolerance |
| PSM scoring | Hyperscore, spectral angle, matched fraction, and more |
| Interactive visualization | Stick plots, mirror plots, annotated fragment spectra (Plotly) |
| File reading | Bruker timsTOF .d files (DReader) and mzML (MzmlReader) |
| Spectrum sharing | Encode a full spectrum to a compact, URL-safe spectrl token or link (to_spectrl_token / to_spectrl_url) |
# 1. Find isotope clusters → assign monoisotopic m/z + charge + Bhattacharyya score
decon = spec.deconvolute(charge_range=(1, 5), tolerance=10, tolerance_type="ppm")
# charge > 0 → assigned cluster
# charge = -1 → singleton / unassigned
# score 0–1 → isotope profile quality (0.0 for singletons)
# 2. Keep only high-confidence clusters
filtered = decon.filter(min_score=0.5)
# 3. Convert to neutral masses (drops singletons)
neutral = filtered.decharge()With the optional [spectrl] extra, encode a complete spectrum (peaks, charges,
ion mobility, and MSn metadata) into a single compact, URL-safe token — or a
ready-to-share link — with no backend required.
token = spec.to_spectrl_token() # spectrl1.… token
restored = spx.Spectrum.from_spectrl_token(token)
url = spec.to_spectrl_url("https://example.com/view") # …#spectrl1.… (shareable)
restored = spx.Spectrum.from_spectrl_url(url)Full documentation with API reference, guides, and interactive plots is available at tacular-omics.github.io/spxtacular.