| OpenMS 2.5.0

Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
BinnedSpectrum Class Reference
Spectrum Comparison

This is a binned representation of a PeakSpectrum. More...

`#include <OpenMS/COMPARISON/SPECTRA/BinnedSpectrum.h>`

## Public Types

using | SparseVectorType = Eigen::SparseVector< float >
| typedef for the underlying sparse vector More...
using | SparseVectorIndexType = Eigen::SparseVector< float >::Index
| typedef for the index into the sparse vector More...
using | SparseVectorIteratorType = Eigen::SparseVector< float >::InnerIterator
| typedef for the index into the sparse vector More...

## Public Member Functions

| BinnedSpectrum ()
| default constructor More...
| BinnedSpectrum (const PeakSpectrum &ps, float size, bool unit_ppm, UInt spread, float offset)
| detailed constructor More...
| BinnedSpectrum (const BinnedSpectrum &)=default
| copy constructor More...
virtual | ~BinnedSpectrum ()
| destructor More...
BinnedSpectrum & | operator= (const BinnedSpectrum &)=default
| assignment operator More...
bool | operator== (const BinnedSpectrum &rhs) const
| equality operator More...
bool | operator!= (const BinnedSpectrum &rhs) const
| inequality operator More...
float | getBinIntensity (double mz)
| returns the bin intensity at a given m/z position More...
SparseVectorIndexType | getBinIndex (float mz) const
| return the bin index of a given m/z position More...
float | getBinLowerMZ (size_t i) const
| return the lower m/z of a bin given its index More...
float | getBinSize () const
| get the bin size More...
size_t | getBinSpread () const
| get the bin spread More...
const SparseVectorType & | getBins () const
| immutable access to the bin container More...
SparseVectorType & | getBins ()
| mutable access to the bin container More...
float | getOffset () const
| return offset More...
const std::vector< Precursor > & | getPrecursors () const
| immutable access to precursors More...
std::vector< Precursor > & | getPrecursors ()
| mutable access to precursors More...

## Static Public Member Functions

static bool | isCompatible (const BinnedSpectrum &a, const BinnedSpectrum &b)
| Check if two BinnedSpectrum objects have equally sized bins and offset. More...

## Static Public Attributes

static constexpr const float | DEFAULT_BIN_WIDTH_LOWRES = 1.0005f
static constexpr const float | DEFAULT_BIN_WIDTH_HIRES = 0.02f
static constexpr const float | DEFAULT_BIN_OFFSET_HIRES = 0.0f
| default bin offset for high-resolution data (adapted from doi:10.1007/s13361-015-1179-x) More...
static constexpr const float | DEFAULT_BIN_OFFSET_LOWRES = 0.4f
| default bin offset for low-resolution data (adapted from doi:10.1007/s13361-015-1179-x) More...
static const SparseVectorType | EmptySparseVector
| the empty SparseVector More...

## Private Member Functions

void | binSpectrum_ (const PeakSpectrum &ps)
| calculate binning of peak spectrum More...

## Private Attributes

UInt | bin_spread_
| the spread to left or right More...
float | bin_size_
| the size of each bin More...
bool | unit_ppm_
| absolute bin size or relative bin size More...
float | offset_
| offset of bin start More...
SparseVectorType | bins_
| bins More...
std::vector< Precursor > | precursors_
| precursor information More...

## Static Private Attributes

static constexpr const float | MIN_MZ_ = 1.0

## Detailed Description

This is a binned representation of a PeakSpectrum.

Parameters

  sz | the size of the bins and
  sp | number of neighboring bins to both sides affected by a peak contribution
  ps | the PeakSpectrum, used to calculate the binned spectrum

sz denotes the size of a bin in `Th`, thereby deciding the number of bins (all of size sz) the spectrum is discretized to. Each bin will represent a certain `Th` range and the peaks will be put in the respective bins and sum up inside. sp denotes the number of neighboring bins to the left and the number of neighboring bins to the right a peak is also added to. E.g. a BinnedSpectrum with binsize of 0.5 `Th` will have a peak at 100 `Th` in bin no. 200, a peak at 100.1 `Th` will be in bin no. 201. If the binspread is 1, the peak at 100 Th will be added to bin no. 199, 200 and 201. If the binspread is 2, the peak at 100 `Th` will also be added to bin no. 198 and 202, and so on.

Many operations are provided by the underlying SparseVector implementation:

- bin-wise addition (e.g.: c = a.getBins() + b.getBins())
- bin-wise scaling (e.g.: c = a.getBins() * 5f)
- to get the number of filled bins, call: getBins().nonZeros()
- many more... See the Eigen SparseVector implementation for details.

Implementation detail: Eigen SparseVectors need to have the same dimensionality. EmptySparseVector provides an empty SparseVector with compatible dimension to perform all supported operations.

## Member Typedef Documentation

## ◆ SparseVectorIndexType

using SparseVectorIndexType = Eigen::SparseVector<float>::Index

typedef for the index into the sparse vector

## ◆ SparseVectorIteratorType

using SparseVectorIteratorType = Eigen::SparseVector<float>::InnerIterator

typedef for the index into the sparse vector

## ◆ SparseVectorType

using SparseVectorType = Eigen::SparseVector<float>

typedef for the underlying sparse vector

## Constructor & Destructor Documentation

## ◆ BinnedSpectrum() [1/3]

BinnedSpectrum | ( |  | ) |

inline

default constructor

## ◆ BinnedSpectrum() [2/3]

BinnedSpectrum | ( | const PeakSpectrum & | ps,
|  | float | size,
|  | bool | unit_ppm,
|  | UInt | spread,
|  | float | offset
| ) |  |

detailed constructor

## ◆ BinnedSpectrum() [3/3]

BinnedSpectrum | ( | const BinnedSpectrum & |  | ) |

default

copy constructor

## ◆ ~BinnedSpectrum()

virtual ~BinnedSpectrum | ( |  | ) |

virtual

destructor

## Member Function Documentation

## ◆ binSpectrum_()

void binSpectrum_ | ( | const PeakSpectrum & | ps | ) |

private

calculate binning of peak spectrum

## ◆ getBinIndex()

SparseVectorIndexType getBinIndex | ( | float | mz | ) | const

inline

return the bin index of a given m/z position

## ◆ getBinIntensity()

float getBinIntensity | ( | double | mz | ) |

inline

returns the bin intensity at a given m/z position

## ◆ getBinLowerMZ()

float getBinLowerMZ | ( | size_t | i | ) | const

inline

return the lower m/z of a bin given its index

## ◆ getBins() [1/2]

const SparseVectorType& getBins | ( |  | ) | const

immutable access to the bin container

## ◆ getBins() [2/2]

SparseVectorType& getBins | ( |  | ) |

mutable access to the bin container

## ◆ getBinSize()

float getBinSize | ( |  | ) | const

inline

get the bin size

## ◆ getBinSpread()

size_t getBinSpread | ( |  | ) | const

inline

get the bin spread

## ◆ getOffset()

float getOffset | ( |  | ) | const

inline

return offset

## ◆ getPrecursors() [1/2]

const std::vector<Precursor>& getPrecursors | ( |  | ) | const

immutable access to precursors

## ◆ getPrecursors() [2/2]

std::vector<Precursor>& getPrecursors | ( |  | ) |

mutable access to precursors

## ◆ isCompatible()

static bool isCompatible | ( | const BinnedSpectrum & | a,
|  | const BinnedSpectrum & | b
| ) |  |

static

Check if two BinnedSpectrum objects have equally sized bins and offset.

## ◆ operator!=()

bool operator!= | ( | const BinnedSpectrum & | rhs | ) | const

inequality operator

## ◆ operator=()

BinnedSpectrum& operator= | ( | const BinnedSpectrum & |  | ) |

default

assignment operator

## ◆ operator==()

bool operator== | ( | const BinnedSpectrum & | rhs | ) | const

equality operator

## Member Data Documentation

## ◆ bin_size_

float bin_size_

private

the size of each bin

## ◆ bin_spread_

UInt bin_spread_

private

the spread to left or right

## ◆ bins_

SparseVectorType bins_

private

bins

## ◆ DEFAULT_BIN_OFFSET_HIRES

constexpr const float DEFAULT_BIN_OFFSET_HIRES = 0.0f

static

default bin offset for high-resolution data (adapted from doi:10.1007/s13361-015-1179-x)

Referenced by TOPPGNPSExport::main_().

## ◆ DEFAULT_BIN_OFFSET_LOWRES

constexpr const float DEFAULT_BIN_OFFSET_LOWRES = 0.4f

static

default bin offset for low-resolution data (adapted from doi:10.1007/s13361-015-1179-x)

## ◆ DEFAULT_BIN_WIDTH_HIRES

constexpr const float DEFAULT_BIN_WIDTH_HIRES = 0.02f

static

Referenced by TOPPGNPSExport::main_().

## ◆ DEFAULT_BIN_WIDTH_LOWRES

constexpr const float DEFAULT_BIN_WIDTH_LOWRES = 1.0005f

static

Sensible default values and notes from doi:10.1007/s13361-015-1179-x Low-resolution MS/MS data: bin width = 1.0005 offset = 0.4 spread should be 0

High-resolution MS/MS data: bin width = 0.02 offset = 0.0 spread should be 0 Note: in sum scores, intensities from neighboring bins should be considered with half intensity of each flanking bin. : Weighted intensity spread is currently not implemented(but could replace the spread parameter).

## ◆ EmptySparseVector

const SparseVectorType EmptySparseVector

static

the empty SparseVector

## ◆ MIN_MZ_

constexpr const float MIN_MZ_ = 1.0

static private

## ◆ offset_

float offset_

private

offset of bin start

## ◆ precursors_

std::vector<Precursor> precursors_

private

precursor information

## ◆ unit_ppm_

bool unit_ppm_

private

absolute bin size or relative bin size