DIAlign
DIAlign Namespace Reference

Generic namespace for all classes and functions of DIAlign. More...

Namespaces

 AffineAlignment
 Includes functions for the affine-alignment through a score-matrix using gap-opening and gap-closing penalties.
 
 Alignment
 Contains some of the core alignment functions for non-affine alignment.
 
 ConstrainMatrix
 Namespace for constraing similarity score matrix.
 
 SimilarityMatrix
 Similarity matrix namespace.
 
 Traceback
 Generic namespace for Traceback that includes source matrix name and the arrow direction.
 
 Utils
 Utility namespace.
 

Classes

struct  AffineAlignObj
 An affine alignment object. More...
 
struct  AlignedIndices
 Includes aligned indices of signal A and signal B with the cumulative score. More...
 
struct  AlignObj
 An alignment object (for non-affine alignment) More...
 
struct  SimMatrix
 Similarity matrix. More...
 
struct  SimMatrix_bool
 Path matrix. More...
 

Functions

void alignChromatogramsCpp (AffineAlignObj &obj, const std::vector< std::vector< double > > &r1, const std::vector< std::vector< double > > &r2, std::string alignType, const std::vector< double > &tA, const std::vector< double > &tB, const std::string &normalization, const std::string &simType, double B1p=0.0, double B2p=0.0, int noBeef=0, double goFactor=0.125, double geFactor=40, double cosAngleThresh=0.3, bool OverlapAlignment=true, double dotProdThresh=0.96, double gapQuantile=0.5, bool hardConstrain=false, double samples4gradient=100.0)
 Align two pairs of chromatograms derived from two LC-MS/MS experiments A and B. More...
 
SimMatrix getSimilarityMatrix (const std::vector< std::vector< double >> &d1, const std::vector< std::vector< double >> &d2, const std::string &Normalization, const std::string &SimType, double cosAngleThresh, double dotProdThresh)
 Calculates similarity matrix of two fragment-ion chromatogram groups or extracted-ion chromatograms (XICs) derived from two LC-MS/MS experiments A and B. More...
 
void doAffineAlignment (AffineAlignObj &obj, const SimMatrix &s, double goPenalty, double gePenalty, bool OverlapAlignment)
 Performs affine alignment on a given alignment object. More...
 
void getAffineAlignedIndices (AffineAlignObj &obj, int bandwidth=0)
 Compute path using AffineAlignObj. More...
 
double getGapPenalty (const SimMatrix &s, double gapQuantile, std::string SimType)
 returns a gap penalty from the distribution of similarity scores. More...
 
double areaBwBoundaries (std::vector< std::vector< double > > vov, int leftIdx, int rightIdx)
 returns the summation of signals between leftIdx and rightIdx from vov.
 

Variables

const int NA = 0
 

Detailed Description

Generic namespace for all classes and functions of DIAlign.

This contains a brief description of the available functions in DIAlign. The DIAlign algorithm can be called through the interface provided by alignChromatogramsCpp(), which allows alignment of a set of chromatograms.

std::vector< std::vector<double > > data1, data2; // chrom coordinates
std::vector<double > rt_data1, data2; // RT coordinates
std::vector<double > rt_mapping; // global RT alignment
int noBeef = 5; // nr of matrix cells w/o penalty
AffineAlignObj alignment_obj(rt_data1.size(), rt_data1.size(), false); // Initialize AffineAlignObj
alignChromatogramsCpp(alignment_obj,
data1, data2,
"hybrid",
rt_data1, rt_data2,
"mean", "dotProductMasked",
rt_mapping.front(), rt_mapping.back(),
noBeef);

The AffineAlignObj will have the fields indexA_aligned, indexB_aligned and score populated, providing the aligned indices as output.

Individual functions that perform the alignment can be called through getSimilarityMatrix(), doAffineAlignment(), getAffineAlignedIndices().

Function Documentation

void DIAlign::alignChromatogramsCpp ( AffineAlignObj obj,
const std::vector< std::vector< double > > &  r1,
const std::vector< std::vector< double > > &  r2,
std::string  alignType,
const std::vector< double > &  tA,
const std::vector< double > &  tB,
const std::string &  normalization,
const std::string &  simType,
double  B1p = 0.0,
double  B2p = 0.0,
int  noBeef = 0,
double  goFactor = 0.125,
double  geFactor = 40,
double  cosAngleThresh = 0.3,
bool  OverlapAlignment = true,
double  dotProdThresh = 0.96,
double  gapQuantile = 0.5,
bool  hardConstrain = false,
double  samples4gradient = 100.0 
)

Align two pairs of chromatograms derived from two LC-MS/MS experiments A and B.

Parameters
objA object of type AffineAlignObj which needs to have at least capacity of the chromatogram length
r1The first set of chromatograms, where each chromatogram is a vector of intensities. These chromatograms are XICs derived from a single analyte in run A
r2The second set of chromatograms, where each chromatogram is a vector of intensities. These chromatograms are XICs derived from a single analyte in run B
alignTypeAvailable alignment methods, must be one of "global", "local" and "hybrid".
tAThis vector has equally spaced timepoints of the XICs from run A.
tBThis vector has equally spaced timepoints of the XICs from run B.
normalizationNormalization method, must be one of "L2", "mean" or "none".
simTypeSimilarity computation method, defines how similarity between two chromatographic points is computed. Must be one of (dotProductMasked, dotProduct, cosineAngle, cosine2Angle, euclideanDist, covariance, correlation).
B1pTimepoint mapped by global fit for tA[0].
B2pTimepoint mapped by global fit for tA[tA.size()-1].
noBeefIt defines the distance from the global fit, upto which no penalization is performed. The window length will be chosen as = 2*noBeef.
goFactorPenalty for introducing first gap in alignment. This value is multiplied by base gap-penalty.
geFactorPenalty for introducing subsequent gaps in alignment. This value is multiplied by base gap-penalty.
cosAngleThreshIn simType == dotProductMasked mode, angular similarity should be higher than cosAngleThresh otherwise similarity is forced to zero.
OverlapAlignmentIf alignment should be performed with free end-gaps. False: Global alignment, True: overlap alignment.
dotProdThreshIn simType = dotProductMasked mode, values in similarity matrix higher than dotProdThresh quantile are checked for angular similarity.
gapQuantileMust be between 0 and 1. This is used to calculate base gap-penalty from similarity distribution.
hardConstrainWhether a hard constraint should be used for the similarity matrix. If false; indices farther from noBeef distance are filled with distance from linear fit line.
samples4gradientThis parameter modulates penalization of masked indices.
Note
r1 and r2 need to have the same length and the chromatograms need to be in the same order (e.g. r1[0] needs to be the same XIC trace as r2[0])
If no global fit is available, it is recommended to set B1p to tB.front() and B2p to tB.back()
void DIAlign::doAffineAlignment ( AffineAlignObj obj,
const SimMatrix s,
double  goPenalty,
double  gePenalty,
bool  OverlapAlignment 
)

Performs affine alignment on a given alignment object.

Note
Does not perform back-tracking, please call getAffineAlignedIndices() afterwards.
Parameters
objA object of type AffineAlignObj which needs to have at least capacity of the chromatogram length
sA previously computed similarity matrix
goPenaltyPenalty for introducing first gap in alignment.
gePenaltyPenalty for introducing subsequent gaps in alignment.
OverlapAlignmentIf alignment should be performed with free end-gaps. False: Global alignment, True: overlap alignment.
void DIAlign::getAffineAlignedIndices ( AffineAlignObj obj,
int  bandwidth = 0 
)

Compute path using AffineAlignObj.

Parameters
objA object of type AffineAlignObj which needs to have matrices A, B and M filled.
bandwithCompute path for multiple matrix cells (bandwith is number of cells to be computed)
Note
this assumes that matrices A, B and M have been computed. Use after calling doAffineAlignment().
this will compute the following members: indexA_aligned, indexB_aligned, score.
double DIAlign::getGapPenalty ( const SimMatrix s,
double  gapQuantile,
std::string  SimType 
)

returns a gap penalty from the distribution of similarity scores.

For simType = "cosineAngle" and "cosine2Angle", gap penalty = 0.95 Other simType values, gap Penalty is the gapQuantile quantile from the score disctribution of s. gapQuantile must be between 0 and 1.

SimMatrix DIAlign::getSimilarityMatrix ( const std::vector< std::vector< double >> &  d1,
const std::vector< std::vector< double >> &  d2,
const std::string &  Normalization,
const std::string &  SimType,
double  cosAngleThresh,
double  dotProdThresh 
)

Calculates similarity matrix of two fragment-ion chromatogram groups or extracted-ion chromatograms (XICs) derived from two LC-MS/MS experiments A and B.

Parameters
d1The first set of chromatograms, where each chromatogram is a vector of intensities. These chromatograms are XICs derived from a single analyte in run A
d2The second set of chromatograms, where each chromatogram is a vector of intensities. These chromatograms are XICs derived from a single analyte in run B
NormalizationNormalization method, must be one of "L2", "mean" or "none".
SimTypeSimilarity computation method, defines how similarity between two chromatographic points is computed. Must be one of (dotProductMasked, dotProduct, cosineAngle, cosine2Angle, euclideanDist, covariance, correlation).
cosAngleThreshIn simType == dotProductMasked mode, angular similarity should be higher than cosAngleThresh otherwise similarity is forced to zero.
dotProdThreshIn simType = dotProductMasked mode, values in similarity matrix higher than dotProdThresh quantile are checked for angular similarity.
Returns
Returns a similarity matrix