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.

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

Also, refer to MSViewer repository for a working example of using this package in a web application.

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.4.tar.gz (22.4 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.4-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spectral_denoising-0.0.4.tar.gz
  • Upload date:
  • Size: 22.4 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.4.tar.gz
Algorithm Hash digest
SHA256 cacf678d72edbb4135d1e635ab48c579c5a1e6a6703abf3eaaecc0bfc214a494
MD5 e69cd586c8e204227ed0a9117760acec
BLAKE2b-256 c424dc6ecfe71d407fd7a106e15f2a64fa79c85838d2efb05b5a888569fb0ff2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spectral_denoising-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 dcdae6011d9e6cbca5df15bdf4d488b28dda90949b5937940b9afc7d306cd853
MD5 dc8da0104905868bf54d7bf3bbae1d6f
BLAKE2b-256 8fe3e07757b2e3cfa014731d5df44ce4e2a3fb9ab69f34c630d20ff08d507d90

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