Skip to main content

Spectral denoising and denoising search

Project description

[Test Spectral denoising package]

If you have any questions, feel free to send me E-mails: fzkong@ucdavis.edu. If you find this package useful, please consider citing the following papers:

. Denoising Search doubles the number of metabolite and exposome annotations in human plasma using an Orbitrap Astral mass spectrometer, Res Sq, 2024). [https://doi.org/10.1038/s41592-023-02012-9]

Project information

Remove noise ions from MS/MS spectra has been tackled for years by mass spectrometrists. Noise ions in MS/MS spectra are largely categorized as 1. electronic noises and 2. chemical noises. In this project, we aim to eliminate both chemical noise and electronic noises for improving high-confidence compound identification. Integrating such process into spectra matching process, we developed denoising search, which psudo-denoise spectra based on molecular information fetched from reference databases. This project also provides useful tools to read, write, visualize and compare spectra.

How to use this package

This repository in Python. A python version >= 3.8 is preferred.

Installation

pip install spectral-denoising

Usage of Classical spectral denoising (electronic denoising and chemical denoising)

import numpy as np
import spectral_denoising as sd
import spectral_denoising.spectral_operations as so

quene_data = sd.read_msp('../sample_data/noisy_spectra.msp').iloc[0] # just use the first spectra
reference_data= sd.read_msp('../sample_data/clean_spectra.msp').iloc[0] 
quene_spectra, quene_smiles, quene_adduct, quene_pmz = quene_data['peaks'], quene_data['smiles'], quene_data['adduct'], quene_data['precursor_mz']
reference_spectra = reference_data['peaks']

# Visualize the head-to-tail plots
sd.head_to_tail_plot(quene_spectra, reference_spectra, pmz = quene_pmz)

# Run spectra denoising will remove electronic noises and chemical noises.
msms_denoised = sd.spectra_denoising(quene_spectra, quene_smiles, quene_adduct) #denoise the spectrum based on the smiles/adduct information

# Calculate spectral entropy before and after denoising.
print(f'the raw spectra has spectral entropy of {so.spctrum_entropy(quene_spectra):.2f}')
print(f'the denoised spectra has spectral entropy of {so.spctrum_entropy(msms_denoised):.2f}')
# Calculate entropy similarity.
sd.head_to_tail_plot(msms_denoised, reference_spectra, pmz = quene_pmz)

Example of usage for batch mode can be found in /notebook/spectral_denoising_demo.ipynb

Usage of Flash Entropy Search

import spectral_denoising as sd
data_dir = '../sample_data/'
quene_spectra= sd.read_msp(os.path.join(data_dir, 'quene_spectra.msp'))
reference_library =sd.read_msp(os.path.join(data_dir, 'sample_library.msp'))
quene_spectrum, quene_pmz = quene_spectra.iloc[0]['peaks'], quene_spectra.iloc[0]['precursor_mz']
sd.denoising_search(quene_spectrum, quene_pmz, reference_library)

Example of usage for batch mode can be found in /notebook/denoising_search_demo.ipynb

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

spectral_denoising-0.0.5.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spectral_denoising-0.0.5-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file spectral_denoising-0.0.5.tar.gz.

File metadata

  • Download URL: spectral_denoising-0.0.5.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for spectral_denoising-0.0.5.tar.gz
Algorithm Hash digest
SHA256 5fc19dfa5cfe604ad1cb62da3262c58038600bff4c77f09f48b5e2c6f025e27c
MD5 adb8f49452e7b70648a65c73a292c86c
BLAKE2b-256 449ec10a1a9c4a669bbdf67b6f6344bd21bfc0a06811e1127e6c974551d73eba

See more details on using hashes here.

File details

Details for the file spectral_denoising-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for spectral_denoising-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e58b518e6d6ddcfc949b478877b8ed33232bcf07b8d1ad47531c0ef58f9a5ff0
MD5 58ef2354d5c664e0c1ae9be82d57262a
BLAKE2b-256 5d0057463ee6191fa2ee03190637f6e0611cf1762e0b38251880249dbd7a4806

See more details on using hashes here.

Supported by

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