Skip to main content

iMSminer provides user-friendly, partially GPU- or compiler-accelerated multi-condition, multi-ROI, and multi-dataset preprocessing and mining of larger-than-memory imaging mass spectrometry datasets in Python.

Project description

Welcome to iMSminer!

iMSminer provides user-friendly, partially GPU- or compiler-accelerated multi-ROI and multi-dataset preprocessing and mining of larger-than-memory imaging mass spectrometry datasets in Python.

Resources

Features

  • Interactive input prompts to enhance user-friendliness
  • Preprocesses imzML datasets via peak picking, baseline subtraction (optional), mass alignment (optional), and peak integration
  • Interactive ROI annotation and selection
  • Optional data normalization, internal calibration, MS1 search, MS2 confirmation, and analyte filtering
  • Unsupervised learning to extract patterns based on molecular co-localization or in situ molecular profile
  • Univariate fold-change statistics with ROI statistics
  • Visualiztion of ion image and ion statistics
  • Quickstart guides on Google Colab

Installation (Local)

iMSminer

pip install iMSminer

GPU-Accelerated Packages

For optional NVIDIA® CUDA® GPU acceleration, install:

Cupy

RAPIDS

Usage

Usage guide with commonly tuned parameters

# =====Load iMSminer Modules===== #
from iMSminer import data_preprocessing, data_analysis, utils, ImzMLParser_chunk

# =====Preprocess imzML===== #
## specify folder path containing imzML's to preprocess and folder path to save preprocessed data and figures 
preprocess = data_preprocessing.Preprocess()
## peak picking with optional mass alignment (if `peak_alignment=True`) and baseline subtraction (if `baseline_subtract=True`)
preprocess.peak_pick(
    percent_RAM=5,
    pp_method="automatic",
    rel_height=0.9,
    peak_alignment=True,
    align_threshold=1,
    align_halfwidth=100,
    grid_iter_num=20,
    align_reduce=False,
    reduce_halfwidth=200,
    plot_aligned_peak=True,
    index_peak_plot=50,
    plot_num_peaks=10,
    baseline_subtract=True,
    baseline_method="regression",
)
## peak integration with bounds rel_height and optional mass alignment (if `peak_alignment=True`)
preprocess.run(
    percent_RAM=5,
    peak_alignment=True,
    integrate_method="peak_width",
    align_halfwidth=100,
    grid_iter_num=20,
    align_reduce=False,
    reduce_halfwidth=200,
    plot_aligned_peak=True,
    index_peak_plot=50,
    plot_num_peaks=10,
)

# =====Analyze Preprocessed Data===== #
# FOR OPTIONAL FUNCTIONS, SKIP THE LINE IF NOT USING THE CAPABILITY
## specify folder path containing preprocessed data
analyze = data_analysis.DataAnalysis()
## ROI annotation and selection
analyze.load_preprocessed_data()
## optional normalization 
analyze.normalize_pixel(method="TIC")
## optional internal calibration
analyze.calibrate_mz()
## optional MS1_search 
analyze.MS1_search(
    ppm_threshold=5, MS1_search_method="avg_sepctrum", filter_db=True, percent_RAM=5
)
## optional analyte filtering 
analyze.filter_analytes(method="MS1")
## optional evaluation of image cluster validity  
analyze.optimize_image_clustering(k_max=min(10, analyze.mz.shape[0] - 1))
## optional evaluation of validity of in situ molecular profile 
analyze.optimize_insitu_clustering(k_max=10)
## image clustering with optional 3D t-SNE mapped in situ (if `insitu_tsne=True`)
analyze.image_clustering(
    k=5,
    perplexity=5,
    insitu_tsne=False,
    insitu_perplexity=3,
    zoom=0.15,
    quantile=99.9,
    replicate=0,
    img_plot_method="plot_ROI",
    feature_label="mz",
    jitter_amount=2,
    jitter_factor=5,
    font_size=20,
    ROI_size_divisor=10
)
# in situ segmentation
analyze.insitu_clustering(
    k=5, perplexity=15, show_ROI=True, show_square=True, replicate=0, ROI_size_divisor=10
) 
# volcano plot; heatmap (if `get_hm=True`) 
analyze.make_FC_plot(
    legend_label="condition",
    feature_label="mz",
    jitter_amount=0.5,
    jitter_factor=3,
    get_hm=True,
    hm_width_factor=10,
    hm_height_factor=20,
    hm_fontsize=20,
    hm_wspace=1.5,
    font_size=20,
)
# box plot ROI statistics
analyze.make_boxplot()
# ion image visualization
analyze.get_ion_image(
    replicate=0,
    show_ROI=True,
    show_square=True,
    color_scheme="inferno",
    quantile=99.9,
    ROI_size_divisor=10
)

Call for Contributions

We appreciate contributions of any form, from feedback to debugging to method development. We enthusiastically welcome developers to interface their published models with iMSminer and host quickstart guides on Google Colab. Please feel free to contact us at prenticelabuf@gmail.com.

Citation

Please consider citing iMSminer and related packages if iMSminer is helpful to your work

@article{Lin2024,
  title = {iMSminer: A Data Processing and Machine Learning Package for Imaging Mass Spectrometry},
  url = {http://dx.doi.org/10.26434/chemrxiv-2024-kxjgg},
  DOI = {10.26434/chemrxiv-2024-kxjgg},
  publisher = {American Chemical Society (ACS)},
  author = {Lin,  Yu Tin and Bao,  Haohui and Scoggins,  Troy and Prentice,  Boone},
  year = {2024},
  month = jun 
}

@software{pyimzml,
  author = {Alexandrov Team, EMBL},
  title = {{pyimzML}: A Parser to Read .imzML Files},
  url = {https://github.com/alexandrovteam/pyimzML},
  version = {1.5.4},
  year = {2024},
}

@software{msalign2024,
  author = {Lukasz G. Migas},
  title = {{msalign}: Spectral alignment based on MATLAB's `msalign` function},
  url = {https://github.com/lukasz-migas/msalign},
  version = {0.2.0},
  year = {2024},
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imsminer-1.0.6.tar.gz (233.7 kB view details)

Uploaded Source

Built Distribution

iMSminer-1.0.6-py3-none-any.whl (243.9 kB view details)

Uploaded Python 3

File details

Details for the file imsminer-1.0.6.tar.gz.

File metadata

  • Download URL: imsminer-1.0.6.tar.gz
  • Upload date:
  • Size: 233.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for imsminer-1.0.6.tar.gz
Algorithm Hash digest
SHA256 59c92475fbbe14691e6c753d4747b40f0e9c7ba636450d3fd000b586fdfce446
MD5 1a5f393e8b2219a962f0ccfdc0f2f03e
BLAKE2b-256 4c5a727b89a89403068c20efef19d3a03cc11568c9d4ebc15d9120ba9d5ff836

See more details on using hashes here.

File details

Details for the file iMSminer-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: iMSminer-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 243.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for iMSminer-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2442a9a60c3ded59a63b36fcc20b86288a08d9e3fb4aed54fc3adfee358ce24b
MD5 b12d80baedca3c46ec578c37b7754383
BLAKE2b-256 8b90157aaf998ee19977f920efc053c569960e4b1af0b2c76734ebc6eedcc568

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page