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.8.tar.gz (31.0 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.8-py3-none-any.whl (36.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spectral_denoising-0.0.8.tar.gz
  • Upload date:
  • Size: 31.0 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.8.tar.gz
Algorithm Hash digest
SHA256 5895c127bf626bec1ea1bd820c2cec3f6c460d92f67061526e811c8a9a7375e2
MD5 b9340521e68bf51136a935c121f754b9
BLAKE2b-256 bf58813b0dd24638e90d3434c16e78333811769948a81dfb88a9e4d789387068

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spectral_denoising-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 ba289087bb814e689908a785f7d9e42862dc7aca08edfd12e669a4c8b9ab095d
MD5 5d6ddf301fc4aace6d4fc169adfd3456
BLAKE2b-256 e99f9a897e848d69b6c8bdfae79187ed052a496ba2563ea216dfa772d3828c42

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