#mass-spectrometry #signal-processing #peak-picking

bin+lib mzsignal

A library for mass spectrometry signal processing

33 releases (breaking)

new 0.27.0 Nov 10, 2024
0.25.0 Oct 14, 2024
0.18.0 Jul 17, 2024
0.12.0 Feb 23, 2024
0.2.3 Aug 7, 2021

#73 in Science

Download history 30/week @ 2024-07-25 7/week @ 2024-08-01 235/week @ 2024-08-08 30/week @ 2024-08-15 25/week @ 2024-08-22 363/week @ 2024-08-29 179/week @ 2024-09-05 118/week @ 2024-09-12 115/week @ 2024-09-19 91/week @ 2024-09-26 23/week @ 2024-10-03 353/week @ 2024-10-10 77/week @ 2024-10-17 28/week @ 2024-10-24 32/week @ 2024-10-31 216/week @ 2024-11-07

376 downloads per month
Used in 5 crates (2 directly)

Apache-2.0

320KB
7.5K SLoC

mzsignal - Low Level Signal Processing For Mass Spectra

mzsignal is a library for performing low-level signal processing on mass spectra en-route to converting a continuous profile-mode spectrum into a centroided peak list.

The peak picking facility can be used directly with PeakPicker which implements a simple gaussian peak shape fitter. There are a some threshold criteria that can be manipulated to control which fits are reported, see its documentation for more details.

When one spectrum is insufficient, averaging the signal from multiple spectra together can be better. The average sub-module includes components for merging together multiple profile spectra.

Usage

use std::fs;
use std::io;
use std::io::prelude::*;

use mzsignal;

// Read in signal arrays from a text file
let mut mz_array: Vec<f64> = Vec::new();
let mut intensity_array: Vec<f32> = Vec::new();
let reader = io::BufReader::new(fs::File::open("./test/data/test.txt").unwrap());
for line in reader.lines() {
    let line = line.unwrap();
    let pref = line.trim();
    let chunks: Vec<&str> = pref.split("\t").collect();
    mz_array.push(chunks[0].parse::<f64>().expect("Expected number for m/z"));
    intensity_array.push(chunks[1].parse::<f32>().expect("Expected number for intensity"));
}

// Create a peak picker
let picker = mzsignal::PeakPicker::default();

// Create an accumulator
let mut acc = Vec::new();

// Pick peaks
let peak_count = picker.discover_peaks(&mz_array, &intensity_array, &mut acc).unwrap();
assert_eq!(peak_count , 4);

for peak in acc.iter() {
    println!("{}", peak);
}

Building

This library needs a small amount of linear algebra, so it depends on either nalgebra or ndarray+ndarray-linalg.

If the you wish to use ndarray-linalg, it needs a LAPACK implementation, controlled by the following features:

  • intel-mkl
  • openblas
  • netlib

otherwise, the default nalgebra backend will be used.

Dependencies

~4–15MB
~225K SLoC