Institute for Advanced Biosciences Keio University
TriDAMP MathDAMP extension for three-way comparisons of metabolite profiles
Home Overview Examples References MathDAMP Contact
TriDAMP > Examples > 01-TriDAMP-Basics

01-TriDAMP-Basics

This notebook demonstrates the basic functionality of the TriDAMP package using simple simulated datasets. The individual steps are briefly explained. For more information regarding the implementation please refer to the TriDAMP.nb (available upon request) notebook.

First, both the MathDAMP and TriDAMP packages have to be loaded. Please adjust the paths to package files according to their location on your system.

<<"/home/baran/math/ms/MathDAMP.1.0.0/MathDAMP.m"

<<"/home/baran/math/ms/TriDAMP.1.0.0/TriDAMP.m"

MathDAMP version 1.0.0 loaded (2006/04/26)

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

TriDAMP version 1.0.0 loaded (2006/05/09)

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Sample Data

Three simple datasets, named A, B, and C and each containing 7 dummy chromatograms, are generated. A dummy annotation table is also generated to number the peaks for easier reference and orientation on the density plots.

dummytimepoints = Range[0, 20, .2] ;

TMPGaussian[A_, x0_, w_] := A ^(-((# - x0)/w)^2) &/@dummytimepoints ;

peakrts = {{4, 16}, {10}, {4, 16}, {10}, {4, 16}, {10}, {4, 16}} ;

peakamplitudes = { {{3, 7}, {0}, {12, 0}, {10}, {12, 3}, {1}, {8, 8}},  {{12 ... {10}, {11.8, 3}, {3}, {0, 12}},  {{11.8, 2}, {.2}, {6, 8}, {10}, {5, 3}, {5}, {2, 7}}} ;

dummyints = ((Plus @@ (TMPGaussian[Sequence @@ #, 1] &/@#)) &/@(Transpose[#] &/@Transpose[{#, peakrts}])) &/@peakamplitudes ;

dummymzs = Range[101., 100. + Length[peakrts]] ;

antbl = MapIndexed[Join[#1, Table[ToString[#2〚1〛], {2}], {1}] &, (Join @@  ... 314;2〛 ; {mzitm, #} &/@#〚1〛) &/@Transpose[{peakrts, dummymzs}]))] ;

Off[General :: "spell1"] ; Off[General :: "spell"] ;

{Aset, Bset, Cset} = {#〚1〛, dummymzs, dummytimepoints, {SampleName#〚2〛}} &/@Transpose[{dummyints, {"A", "B", "C"}}] ;

On[General :: "spell1"] ; On[General :: "spell"] ;

chromplotopts = {LegendDataTranspose[{{Hue[0], Hue[1/3], Hue[2/3]}, (SampleName/.#)  ...  PlotOptions {AspectRatio.17, PlotStyle {Hue[0], Hue[1/3], Hue[2/3]}}} ;

(DAMPPlotChromatogram[{Aset, Bset, Cset}, #1, Sequence @@ chromplotopts, AnnotationTableantbl] &)/@Aset〚2〛 ;

[Graphics:HTMLFiles/index_19.gif]

[Graphics:HTMLFiles/index_20.gif]

[Graphics:HTMLFiles/index_21.gif]

[Graphics:HTMLFiles/index_22.gif]

[Graphics:HTMLFiles/index_23.gif]

[Graphics:HTMLFiles/index_24.gif]

[Graphics:HTMLFiles/index_25.gif]

DAMPDensityPlot[#, MaxScale12, PlotOptions {ImageSize300, AspectRati ... 2754; {{LabelSize {5, .9}, TextStyleDAMPTextStyle}}] &/@{Aset, Bset, Cset} ;

Show[GraphicsArray[%, GraphicsSpacing0], DisplayFunction$DisplayFunction, ImageSize700] ;

[Graphics:HTMLFiles/index_28.gif]

3-Way Comparisons

The TriDAMPCompare function performs a 3-way comparison between datasets of interest and the TriDAMPDensityPlot function displays the results on a density plot. Reference information about the functions can be displayed by executing ?FunctionName.

? TriDAMPCompare

TriDAMPCompare[msdatas,options] performs a three way comparison of msdatas (a list of three  ... rior to the three way comparison. This produces a relative three way comparison (default: False)

Absolute and relative 3-way comparisons are perfomed for the A, B , and C datasets. The results are plotted below.

absrslt = TriDAMPCompare[{Aset, Bset, Cset}] ;

relrslt = TriDAMPCompare[DAMPThreshold[#, .1] &/@{Aset, Bset, Cset}, RelativeTrue] ;

rsltplotopts = {PlotOptions {ImageSize700, AspectRatio.45}, LegendSi ... tbl}, AnnotationOptions {{LabelSize {5, .9}, TextStyleDAMPTextStyle}}} ;

TriDAMPDensityPlot[#, Sequence @@ rsltplotopts] &/@{absrslt, relrslt} ;

[Graphics:HTMLFiles/index_35.gif]

[Graphics:HTMLFiles/index_36.gif]

The simulated data are 'perfect' - the gaussian peaks have a nonzero signal intensity over the whole time range. The relative result would therefore provide fully colored lanes if the compared datasets were not subjected to a threshold filtering prior to the 3-way comparison. The filtering is also the cause of the differently colored edges of some of the bands (only one or two of the corresponding signal intensities were leveled to 0 at those time points).

Filtering the Results

The 3-way comparison results datasets can be filtered to select only signals exceeding a certain threshold. Any custom function to filter the data can be specified also.

? TriDAMPFilter

TriDAMPFilter[threewaycomparison,criteria,threshold,options] sets to {0,0,1} those color spe ... leName function (used internally), so the function's ShareBands option may be specified as well.

Below is a density plot of the absolute result from which result intensities (corresponding to saturations in the color specifications) below a threshold value of 7.1 are filtered out. Please note also that the intensity scale was modified to assign a wider saturation range to higher values. The three unlabeled tickmarks on the legend's scale axis indicate the location of the quarters of the range (3, 6, and 9 respectively).

TriDAMPDensityPlot[TriDAMPFilter[absrslt, absrslt, 5.01], ScaleModifier (#^2&), Sequence @@ rsltplotopts] ;

[Graphics:HTMLFiles/index_40.gif]

As mentioned previously, a custom function can be defined to filter out results of interest. Below is an example of selecting only those results for which the signal intensities from datasets A and C are the most distant. In other words, only results from the red to blue gradient (running via pink) are selected. The hue specification borderlines are set to tolerate small deviations from this gradient (a strict definition would be 2/3≤#[[1]]≤1||#[[1]]==0).
The custom filter function is expected to generate a matrix by which the original color specification matrix in the filtered dataset is multiplied. Multiplying any color specification by {1,1,1} leaves the original values, multiplying by {0,0,1} changes the original color to white (assuming the brightness specification in the original color is 1).

TriDAMPDensityPlot[TriDAMPFilter[absrslt, absrslt, (If[1.9/3≤#〚1〛≤ ... 14;1〛<.1/3, {1, 1, 1}, {0, 0, 1}] &/@#&/@#&)], Sequence @@ rsltplotopts] ;

[Graphics:HTMLFiles/index_42.gif]

Candidate Differences

Overlaid chromatograms for the candidate differences from a result of interest can be generated in a descending order of significance using the TriDAMPPlotCandidates function. The function is very similar to MathDAMP's DAMPPlotCandidates. DAMPPlotCandidates is actually used internally and all options passed to TriDAMPPlotCandidates are passed further to DAMPPlotCandidates.

TriDAMPPlotCandidates[{Aset, Bset, Cset}, absrslt, PlotCount8, PlotVicinity3 ... All, 4〛}], PlotOptions {AspectRatio.25}, AnnotationTableantbl}] ;

[Graphics:HTMLFiles/index_44.gif]

[Graphics:HTMLFiles/index_45.gif]

[Graphics:HTMLFiles/index_46.gif]

[Graphics:HTMLFiles/index_47.gif]

[Graphics:HTMLFiles/index_48.gif]

[Graphics:HTMLFiles/index_49.gif]

[Graphics:HTMLFiles/index_50.gif]

[Graphics:HTMLFiles/index_51.gif]