tidyms.raw_data_utils¶
Functions used to extract information from raw data.
- accumulate_spectra(ms_data: MSData, *, start_time: float, end_time: float, subtract_left_time: float | None = None, subtract_right_time: float | None = None, ms_level: int = 1) MSSpectrum¶
accumulates a series of consecutive spectra into a single spectrum.
- Parameters:
- ms_dataMSData
- start_time: float
Start accumulating scans at this scan time.
- end_time: float
Ends accumulation after this scan time.
- subtract_left_timefloat or None, default=None
Scans with acquisition times lower than this value are subtracted from the accumulated spectrum. If
None, no subtraction is done.- subtract_right_timefloat or None, default=None
Scans with acquisition times greater than this value are subtracted from the accumulated spectrum. If
None, no subtraction is done.- ms_levelint, default=1
ms level used to build the accumulated spectrum.
- Returns:
- MSSpectrum
- make_chromatograms(ms_data: MSData, mz: ndarray, *, window: float | None = None, accumulator: str = 'sum', fill_missing: bool = True, ms_level: int = 1, start_time: float = 0.0, end_time: float | None = None) List[Chromatogram]¶
Computes extracted ion chromatograms using a list of m/z values.
- Parameters:
- ms_dataMSData
- mzarray
m/z values used to build the EICs.
- windowpositive number or None, default=None
m/z tolerance used to build the EICs. If
ms_data.instrumentis"qtof", the default value is0.05. Ifms_data.instrumentis"orbitrap"the default value is0.005.- accumulator{“sum”, “mean”}, default=”sum”
Mode used to accumulate the values inside the m/z window.
"sum"computes the total intensity inside the window."mean"divides the total intensity using the number of points inside the window.- fill_missingbool, default=True
If
True, sets the intensity to zero if no signal was found in a given scan. IfFalse, missing values are set to NaN.- ms_levelint, default=1
ms level used to build the chromatograms.
- start_timefloat, default=0.0
include scans starting at this acquisition time.
- end_timefloat or None, default=None
Stops when the acquisition time is higher than this value.
- Returns:
- chromatogramsList of Chromatograms
- make_roi(ms_data: MSData, *, tolerance: float | None = None, max_missing: int | None = None, min_length: int | None = None, min_intensity: float = 0.0, multiple_match: str = 'reduce', mz_reduce: str | Callable = 'mean', sp_reduce: str | Callable = 'sum', targeted_mz: ndarray | None = None, pad: int | None = None, ms_level: int = 1, start_time: float = 0.0, end_time: float | None = None, min_snr: float = 10, min_distance: float | None = None) List[Roi]¶
Builds regions of interest (ROI) from raw data.
ROI are created by connecting values across scans based on the closeness in m/z. See the user guide for a description of the algorithm used.
- Parameters:
- ms_dataMSData
- tolerancepositive number or None, default=None
m/z tolerance to connect values across scans. If None, the value is set based on the value of
ms_data.instrument. If"qtof"is used, the tolerance is0.01. If"orbitrap"is used, the tolerance is0.005.- max_missingnon-negative integer or None, default=None
maximum number of consecutive missing values in a valid ROI. If
None, the value is set to1.- min_lengthpositive integer or None, default=None
The minimum length of a valid ROI, defined as the number of non-NaN values in the ROI. If,
None, the value is set based onms_data.separation. If"uplc", the value is set to10. If"hplc", the value is set to20.- min_intensitynon-negative number , default=0.0
Minimum intensity in a valid ROI.
- pad: int or None, default=None
Pad dummy values to the left and right of the ROI. This produces better peak picking results when searching low intensity peaks in a ROI. Using None set the value to
2.- multiple_match{“closest”, “reduce”}, default=”reduce”
How peaks are matched when there is more than one valid match. If
"closest"is used, the closest peak is assigned as a match and the others are used to create new ROIs. If"reduce"is used, unique m/z and intensity values are generated using the reduce function in mz_reduce and sp_reduce respectively.- mz_reduce“mean” or Callable, default=”mean”
Function used to reduce m/z values. If
"mean"is used, the mean value of all valid m/z is used. Any function that accepts numpy arrays and return numbers can be used. Used only when multiple_match is set to"reduce". See the following prototype:def mz_reduce(mz_match: np.ndarray) -> float: pass
- sp_reduce{“mean”, “sum”} or Callable, default=”sum”
Function used to reduce intensity values.
"mean"computes the mean intensity and"sum"computes the total intensity. Any function that accepts numpy arrays and return numbers can be used. Only used when multiple_match is set to"reduce". See the prototype shown on mz_reduce.- targeted_mznumpy.ndarray or None, default=None
A list of m/z values to perform a targeted ROI creation. If this value is provided, only ROI with these m/z values will be created.
- ms_levelint, default=1
ms level used to build the ROI.
- start_timefloat, default=0.0
Use scans starting at this acquisition time.
- end_timefloat or None, default=None
Stops when the acquisition time is higher than this value.
- min_snrpositive number, default=10.0
Minimum signal-to-noise ratio of the peaks. Used only to convert profile data to centroid mode
- min_distancepositive number or None, default=None
Minimum distance between consecutive peaks. If
None, the value is set to 0.01 ifms_data.instrumentis"qtof"or to 0.005 ifms_data.instrumentis"orbitrap". Used only to convert profile data to centroid mode.
- Returns:
- roilist[Roi]
A list with the detected regions of interest.
See also
lcms.RoiRepresentation of a ROI.
lcms.LCRoiROI used in LC data.
- make_tic(ms_data: MSData, *, kind: str = 'tic', ms_level: int = 1, start_time: float = 0.0, end_time: float | None = None) Chromatogram¶
Creates a total ion chromatogram.
- Parameters:
- ms_dataMSData
- kind: {“tic”, “bpi”}, default=”tic”
tic computes the total ion chromatogram. bpi computes the base peak chromatogram.
- ms_levelint, default=1
ms level used to build the chromatogram.
- start_timefloat, default=0.0
include scans starting at this acquisition time.
- end_timefloat or None, default=None
Stops when the acquisition time is higher than this value. If None, it doesn’t filter scans by time.
- Returns:
- chromatogramslcms.Chromatograms