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.6.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.6-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spectral_denoising-0.0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 4ec37106b0104da72f28ba2869a9274c7fc90f10321d683291faa027e9903c36
MD5 ae80cb35effebd831e92a9b98cc99b6f
BLAKE2b-256 b8ed9470f4ceecacd949fe60dd4140a7f08a376edd9bfa6f2bd0ae218763f18b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spectral_denoising-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4db15a16876a44ea98981d8fee3bbe225f0e404a52f6e1e38c745591c3ac0b87
MD5 455a7149d07d3dda1cb7ee1895e1b84a
BLAKE2b-256 05bc7d1a20dab2653f408b98474f4c077da22b0c844457f41703f62fa3659b7f

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