Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Classes | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
FeatureDistance Class Reference

A functor class for the calculation of distances between features or consensus features. More...

#include <OpenMS/ANALYSIS/MAPMATCHING/FeatureDistance.h>

Inheritance diagram for FeatureDistance:
DefaultParamHandler

Classes

struct  DistanceParams_
 Structure for storing distance parameters. More...
 

Public Member Functions

 FeatureDistance (double max_intensity=1.0, bool force_constraints=false)
 Constructor. More...
 
virtual ~FeatureDistance ()
 Destructor. More...
 
FeatureDistanceoperator= (const FeatureDistance &other)
 Assignment operator. More...
 
std::pair< bool, doubleoperator() (const BaseFeature &left, const BaseFeature &right)
 Evaluation operator - checks constraints and computes the distance between two features. More...
 
- Public Member Functions inherited from DefaultParamHandler
 DefaultParamHandler (const String &name)
 Constructor with name that is displayed in error messages. More...
 
 DefaultParamHandler (const DefaultParamHandler &rhs)
 Copy constructor. More...
 
virtual ~DefaultParamHandler ()
 Destructor. More...
 
virtual DefaultParamHandleroperator= (const DefaultParamHandler &rhs)
 Assignment operator. More...
 
virtual bool operator== (const DefaultParamHandler &rhs) const
 Equality operator. More...
 
void setParameters (const Param &param)
 Sets the parameters. More...
 
const ParamgetParameters () const
 Non-mutable access to the parameters. More...
 
const ParamgetDefaults () const
 Non-mutable access to the default parameters. More...
 
const StringgetName () const
 Non-mutable access to the name. More...
 
void setName (const String &name)
 Mutable access to the name. More...
 
const std::vector< String > & getSubsections () const
 Non-mutable access to the registered subsections. More...
 

Static Public Attributes

static const double infinity
 Value to return if max. difference is exceeded or if charge states don't match. More...
 

Protected Member Functions

void updateMembers_ ()
 Docu in base class. More...
 
double distance_ (double diff, const DistanceParams_ &params) const
 Computes a distance component given absolute difference and parameters. More...
 
- Protected Member Functions inherited from DefaultParamHandler
void defaultsToParam_ ()
 Updates the parameters after the defaults have been set in the constructor. More...
 

Protected Attributes

DistanceParams_ params_rt_
 Storage of parameters for the individual distance components. More...
 
DistanceParams_ params_mz_
 
DistanceParams_ params_intensity_
 
double total_weight_reciprocal_
 Reciprocal value of the total weight in the distance function. More...
 
double max_intensity_
 Maximum intensity of features (for normalization) More...
 
bool ignore_charge_
 Compute a distance even if charge states don't match? More...
 
bool force_constraints_
 Always return infinity if "max. difference" constraints are not met? More...
 
- Protected Attributes inherited from DefaultParamHandler
Param param_
 Container for current parameters. More...
 
Param defaults_
 Container for default parameters. This member should be filled in the constructor of derived classes! More...
 
std::vector< Stringsubsections_
 Container for registered subsections. This member should be filled in the constructor of derived classes! More...
 
String error_name_
 Name that is displayed in error messages during the parameter checking. More...
 
bool check_defaults_
 If this member is set to false no checking if parameters in done;. More...
 
bool warn_empty_defaults_
 If this member is set to false no warning is emitted when defaults are empty;. More...
 

Detailed Description

A functor class for the calculation of distances between features or consensus features.

It implements a customizable distance function of the following form:

\[ w_{RT} \cdot \left( \frac{\left| RT_1 - RT_2 \right|}{\Delta RT_{max}} \right)^{p_{RT}} + w_{MZ} \cdot \left( \frac{\left| MZ_1 - MZ_2 \right|}{\Delta MZ_{max}} \right)^{p_{MZ}} + w_{int} \cdot \left( \frac{\left| int_1 - int_2 \right|}{int_{max}} \right)^{p_{int}} \]

This function returns a normalized distance between zero and one (unless constraints are violated, see below).

$ RT_i $, $ MZ_i $, and $ int_i $ are the RT, m/z, and intensity values of the respective feature.

$ {\Delta RT_{max}} $ and $ {\Delta MZ_{max}} $ are the maximum allowed differences in RT and m/z, respectively. They are specified by the parameters distance_RT:max_difference and distance_MZ:max_difference, and are used for normalization. If an absolute difference exceeds the specified maximum, the behavior depends on the value used for check_constraints in the constructor: If "false", the distance will be computed normally, but may become greater than 1; if "true", the fixed value infinity is returned.

$ int_{max} $ is the maximum intensity that can occur for features compared by this distance function. It is not a parameter specified by the user, but depends on the data at hand and is thus set in the constructor (via parameter max_intensity).

$ w_X $ is the weight of distance component X, specified by the parameter distance_X:weight. The weights can be used to increase or decrease the contribution of RT, m/z, or intensity in the distance function. (Note that the default weight for the intensity component is zero, i.e. intensity is not considered by default.)

$ p_X $ is the exponent for distance component X, specified by the parameter distance_X:exponent. Normalized differences are taken to this power. This makes it possible to compare values using linear, quadratic, etc. distance.

By default, two features are only compared if they have the same charge state (or charge state 0 for "undefined") - otherwise, infinity is returned. This behavior can be changed by the ignore_charge parameter.

Note
Peptide identifications annotated to features are not taken into account here, because they are stored in a format that is not suitable for rapid comparison.
Parameters of this class are:

NameTypeDefaultRestrictionsDescription
ignore_charge stringfalse true, falseCompare features normally even if their charge states are different
distance_RT:max_difference float100 min: 0Maximum allowed difference in RT in seconds
distance_RT:exponent float1 min: 0Normalized RT differences are raised to this power (using 1 or 2 will be fast, everything else is REALLY slow)
distance_RT:weight float1 min: 0RT distances are weighted by this factor
distance_MZ:max_difference float0.3 min: 0Maximum allowed difference in m/z (unit defined by 'unit')
distance_MZ:unit stringDa Da, ppmUnit of the 'max_difference' parameter
distance_MZ:exponent float2 min: 0Normalized m/z differences are raised to this power (using 1 or 2 will be fast, everything else is REALLY slow)
distance_MZ:weight float1 min: 0m/z distances are weighted by this factor
distance_intensity:exponent float1 min: 0Differences in relative intensity are raised to this power (using 1 or 2 will be fast, everything else is REALLY slow)
distance_intensity:weight float0 min: 0Distances based on relative intensity are weighted by this factor

Note:

Constructor & Destructor Documentation

FeatureDistance ( double  max_intensity = 1.0,
bool  force_constraints = false 
)

Constructor.

Parameters
max_intensityMaximum intensity of features (for normalization)
force_constraintsCheck "max. difference" constraints given in the parameters and return infinity if violated?
virtual ~FeatureDistance ( )
virtual

Destructor.

Member Function Documentation

double distance_ ( double  diff,
const DistanceParams_ params 
) const
inlineprotected

Computes a distance component given absolute difference and parameters.

std::pair<bool, double> operator() ( const BaseFeature left,
const BaseFeature right 
)

Evaluation operator - checks constraints and computes the distance between two features.

Returns
In the first element, whether constraints were satisfied; in the second element, the distance (infinity if constraints were violated and force_constraints_ is true).
FeatureDistance& operator= ( const FeatureDistance other)

Assignment operator.

void updateMembers_ ( )
protectedvirtual

Docu in base class.

Reimplemented from DefaultParamHandler.

Member Data Documentation

bool force_constraints_
protected

Always return infinity if "max. difference" constraints are not met?

bool ignore_charge_
protected

Compute a distance even if charge states don't match?

const double infinity
static

Value to return if max. difference is exceeded or if charge states don't match.

double max_intensity_
protected

Maximum intensity of features (for normalization)

DistanceParams_ params_intensity_
protected
DistanceParams_ params_mz_
protected
DistanceParams_ params_rt_
protected

Storage of parameters for the individual distance components.

double total_weight_reciprocal_
protected

Reciprocal value of the total weight in the distance function.


OpenMS / TOPP release 2.0.0 Documentation generated on Wed Mar 30 2016 16:18:44 using doxygen 1.8.5