-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add one more peak picker that might be more robust
- Loading branch information
1 parent
4389b1a
commit 8725b0b
Showing
4 changed files
with
68 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/depiction/spectrum/peak_picking/ms_peak_picker_wrapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# TODO better name | ||
|
||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
from typing import TYPE_CHECKING | ||
|
||
import loguru | ||
import ms_peak_picker | ||
import numpy as np | ||
import scipy | ||
|
||
from depiction.spectrum.peak_picking.basic_peak_picker import BasicPeakPicker | ||
|
||
if TYPE_CHECKING: | ||
from numpy.typing import NDArray | ||
from depiction.spectrum.peak_filtering import PeakFilteringType | ||
|
||
|
||
@dataclass | ||
class MSPeakPicker: | ||
"""Interfaces to the ms-peak-picker Python package. | ||
TODO proper description and better name | ||
""" | ||
|
||
fit_type: str = "quadratic" | ||
peak_filtering: PeakFilteringType | None = None | ||
|
||
def pick_peaks(self, mz_arr: NDArray[float], int_arr: NDArray[float]) -> tuple[NDArray[float], NDArray[float]]: | ||
peak_list = ms_peak_picker.pick_peaks(mz_arr, int_arr, fit_type=self.fit_type) | ||
peak_mz = np.array([peak.mz for peak in peak_list]) | ||
peak_int = np.array([peak.intensity for peak in peak_list]) | ||
|
||
if self.peak_filtering is not None: | ||
peak_mz, peak_int = self.peak_filtering.filter_peaks( | ||
spectrum_mz_arr=mz_arr, | ||
spectrum_int_arr=int_arr, | ||
peak_mz_arr=peak_mz, | ||
peak_int_arr=peak_int, | ||
) | ||
|
||
return peak_mz, peak_int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters