Single-Cell Mass Spectrometry Imaging
IonScell is a Python pipeline for Single-Cell Mass Spectrometry Imaging (SCMSI). It processes raw imzML files acquired on MALDI, DESI, SpiderMass-imaging or other MSI platforms and performs the full analytical workflow, from data loading, single cells isolation, cells populations analysis through soft clustering and quality control, to lipid/metabolite annotation and export.
IonScell is available in two complementary formats in this repository:
| Format | Best for |
|---|---|
Jupyter Notebook (ionScell_notebook.ipynb) |
Step-by-step exploratory analysis, publication figures |
Python class (ionscell_pipeline.py) |
Integration into existing pipelines, scripting |
The IonScell Desktop GUI is distributed separately โ download it here:
๐ฅ [https://nextcloud.univ-lille.fr/index.php/s/wefM34McLdbjsnX]
All datasets used to develop and validate IonScell are publicly available on Zenodo:
Single-cell MALDI-MSI datasets of breast cancer and glioblastoma cell lines for ionScell validation
Zirem Y., Ledoux L., Defrance J., Lagache L., Fournier I., Salzet M. โ PRISM U1192
The repository contains MALDI-MSI acquisitions (Bruker rapifleX, 10 ยตm, m/z 350โ1100, centroid imzML/ibd) of cytospin-deposited human cell lines in both positive and negative ionisation modes:
- AU565 โ HER2-positive breast cancer
- MDA-MB-231 โ triple-negative breast cancer
- MCF7 โ luminal breast cancer
- NCH82 โ glioblastoma
- AU565 + NCH82 โญ โ binary mixed population (pos + neg)
- AU565 + MCF7 + MDA-MB-231 โ ternary mixed population (pos + neg)
๐ก Start with
au565_nch82_negorau565_nch82_posโ the binary mixed cell datasets are the smallest files (~57 MB and ~180 MB combined) and are ideal for a first run. They demonstrate IonScell's ability to resolve molecularly distinct cell populations via soft clustering.
- Flexible m/z binning โ Fixed (0.1 Da) or adaptive (instrument-matched ppm resolution)
- Adaptive TIC thresholding โ 8 algorithms (GMM, Otsu, Triangle, Li, Yen, โฆ) with automatic selection
- Cell segmentation โ Watershed and DFS algorithms with size filtering in pixels or ยตm
- Soft clustering โ Gaussian Mixture Models (GMM) and Fuzzy C-Means (FCM) with probabilistic membership
- Quality control โ SNR, sparsity, dynamic range, spectral entropy, number of detected peaks
- Clone quality assessment โ Confidence scores, within-clone CV, between-clone separability
- Differential analysis โ Kruskal-Wallis or ANOVA with BH FDR correction, volcano plots, Z-score heatmaps
- Ion spatial mapping โ Single-ion and multi-ion overlay with cell contours
- Lipid annotation โ Embedded LIPID MAPS / HMDB database, no internet required, adduct-aware
- Export โ CSV (metadata + spectra), imzML
git clone https://github.com/yanisZirem/ionScell.git
cd ionScellconda create -n ionscell python=3.10 -y conda activate ionscell
pip install -r requirements.txt
Optional (for Fuzzy C-Means):
pip install scikit-fuzzy
jupyter notebook ionScell_notebook.ipynb
Click the badge to open the notebook directly in Colab:
Step 0 of the notebook auto-detects Colab, installs all dependencies, and lets you upload your data or download the test dataset directly from Zenodo.
from ionscell_pipeline import SCMSIPipeline, LipidAnnotator pipe = SCMSIPipeline() pipe.load_imzml("data/au565_nch82_neg.imzML") pipe.build_datacube(mz_min=350, mz_max=1100, mz_bin=0.1, normalization="TIC") thresh, _ = pipe.auto_TIC_threshold(method='auto') pipe.watershed_or_dfs_from_mask(TIC_threshold=thresh, method='watershed', min_cell_size=4, pixel_size_um=10) pipe.extract_cell_spectra(agg='mean') pipe.compute_spectral_quality_metrics() pipe.filter_low_quality_cells(snr_threshold=2.0) pipe.compute_soft_clustering(n_clusters=None, max_clusters=8) pipe.assess_clone_quality() pipe.show_umap_with_quality_overlay() pipe.overlay_clusters_on_image_plotly() pipe.plot_clone_spectra_with_uncertainty() top_markers, _ = pipe.run_differential_analysis(method='kruskal') ann_df, enrichment = pipe.annotate_ions(mode='neg', ppm_tolerance=10.0) pipe.export_cells_to_csv("results/cells.csv")
๐ฅ Download IonScell GUI โ extract and launch ionScell.exe.
See docs/user_manual_interface.md for the full guide.
imzML file
โ
โผ
load_imzml()
โ
โผ
make_mz_axis() / build_adaptive_mz_axis()
โ
โผ
build_datacube() โ normalization: TIC / RMS / MEDIAN
โ
โผ
auto_TIC_threshold() โ 8 algorithms, automatic selection
โ
โผ
watershed_or_dfs_from_mask() โ Watershed or DFS
โ โ size filtering (px or ยตm)
โโโ remove_cells() โ manual artefact removal
โ
โผ
extract_cell_spectra() โ mean / median / sum per cell
โ
โผ
compute_spectral_quality_metrics()
filter_low_quality_cells()
โ
โผ
compute_soft_clustering() โ GMM (auto k via BIC/silhouette)
or compute_fuzzy_cmeans() โ FCM
โ
โผ
assess_clone_quality()
โ
โโโ show_umap_with_quality_overlay()
โโโ overlay_clusters_on_image_plotly()
โโโ plot_clone_spectra_with_uncertainty()
โโโ show_mz_distribution_in_cells_plotly()
โโโ plot_multi_ion_overlay()
โโโ plot_distribution_by_clone()
โ
โผ
run_differential_analysis() โ Kruskal-Wallis / ANOVA + BH FDR
โ
โผ
annotate_ions() โ LipidAnnotator (embedded DB)
โ
โผ
export_cells_to_csv()
export_cells_to_imzML()
| Method | Description |
|---|---|
load_imzml(path) |
Load imzML file |
make_mz_axis(mz_min, mz_max, mz_bin) |
Fixed-grid m/z axis |
build_adaptive_mz_axis(...) |
Instrument-matched adaptive binning |
build_datacube(mz_min, mz_max, normalization) |
Build 3D data cube |
| Method | Description |
|---|---|
auto_TIC_threshold(method) |
Adaptive TIC threshold (8 methods + auto) |
watershed_or_dfs_from_mask(...) |
Cell segmentation |
remove_cells(remove_ids) |
Remove artefact cells |
| Method | Description |
|---|---|
extract_cell_spectra(agg) |
One spectrum per cell |
compute_spectral_quality_metrics() |
SNR, entropy, sparsity, โฆ |
filter_low_quality_cells(...) |
Flag/remove low-quality cells |
| Method | Description |
|---|---|
compute_soft_clustering(n_clusters) |
GMM soft clustering |
compute_fuzzy_cmeans(max_clusters) |
Fuzzy C-Means |
assess_clone_quality() |
Quality report per clone |
| Method | Description |
|---|---|
remove_clone(clone_id) |
Remove entire clone |
combine_clones(clone_ids) |
Merge clones |
remove_clusters(clusters_to_remove) |
Remove by cluster ID |
| Method | Description |
|---|---|
show_TIC_plotly() |
TIC heatmap |
show_umap_with_quality_overlay() |
UMAP coloured by clone + confidence |
overlay_clusters_on_image_plotly() |
Spatial clone map |
plot_cell_contours_by_clone() |
Contours on white/TIC background |
plot_clone_spectra_with_uncertainty() |
Mean spectra ยฑ SD |
plot_global_spectrum() |
Global mean spectrum |
show_mz_distribution_in_cells_plotly(mz_value) |
Single-ion map |
plot_multi_ion_overlay(mz_list) |
Multi-ion RGB overlay |
plot_distribution_by_clone(mz_value) |
Violin/box plots |
| Method | Description |
|---|---|
run_differential_analysis(method) |
Statistical DA + volcano + heatmap |
annotate_ions(mode, ppm_tolerance) |
Lipid/metabolite annotation |
export_cells_to_csv(path) |
Export to CSV |
export_cells_to_imzML(path) |
Export to imzML |
ann = LipidAnnotator(mode='pos', ppm_tolerance=5.0) hits = ann.annotate_peak(800.56) df = ann.annotate_peak_list(mz_array) results, enrichment = ann.annotate_clones(pipeline) df = ann.search("ceramide")
Positive adducts: [M+H]+, [M+Na]+, [M+K]+, [M+NH4]+, [M+Li]+, [M+H-H2O]+, [M+2H]2+
Negative adducts: [M-H]-, [M+Cl]-, [M+FA-H]-, [M+Ac-H]-, [M-H-H2O]-, [M+Br]-, [M-2H]2-
ionScell/
โโโ ionscell_pipeline.py โ SCMSIPipeline + LipidAnnotator class
โโโ ionScell_notebook.ipynb โ Jupyter notebook (imports class)
โโโ requirements.txt
โโโ README.md
โโโ logo.png
โโโ docs/
โโโ user_manual_jupyter.md โ Jupyter + Google Colab user manual
โโโ user_manual_interface.md โ Desktop GUI user manual
| Instrument | Format | Notes |
|---|---|---|
| MALDI-TOF/TOF | imzML | Continuous or processed mode |
| MALDI-Orbitrap | imzML | Use adaptive binning for best annotation |
| DESI-MS | imzML | |
| SIMS | imzML |
IonScell is currently under submission to a journal.
If you use the test datasets, please cite:
Zirem Y., Ledoux L., Defrance J., Lagache L., Fournier I., Salzet M.
Single-cell MALDI-MSI datasets of breast cancer and glioblastoma cell lines for ionScell validation, Zenodo, 2026.
MIT License โ see LICENSE for details.
๐ฌ [email protected] โ [email protected]
๐ Issues & feature requests: github.com/yanisZirem/ionScell/issues
