Institute for Advanced Biosciences Keio University
MathDAMP Mathematica package for differential analysis of metabolite profiles
Home Overview Examples Downloads TriDAMP References Contact
MathDAMP > Examples > MathDAMP source > Core Functionality > Miscellaneous functions

Miscellaneous functions

DAMPCheckDir checks if a directory dir exists and creates it, if it does not exist. Parent directory must exist, error message is displayed otherwise. This function is used in some template notebooks to create directories for the saving/export of the results.

DAMPCheckDir[dir_] := Module[{curdir, createrslt}, curdir = Directory[] ; If ... 2371;SetDirectory[curdir] ; ] ; On[SetDirectory :: "cdir"] ; ]

DAMPGenColors generates a list of color specifications having the a specified number of elements. If the number is 6 or less elements, the colors are assigned from the following sequence: blue, red, green, yellow, cyan, magenta. If the number is more than 6, the hue range is split proportionally and the colors are assigned  from this sequence. The function is mostly used to assign comprehensive colors to overlaid chromatogram/electropherogram plots.

DAMPGenColors[nr_] := Module[{}, If[nr≤6, Take[{Hue[2/3], Hue[0], Hue[1/3], Hue[1/6], Hue[1/2], Hue[5/6]}, nr], Table[Hue[i/nr], {i, 0, nr - 1}]] ]

DAMPCalcRelativeDifference calculates a relative difference between two corresponding signal intensities. The difference between the signal intensities is divided by the larger of the two (or an absolute value of their difference if this is bigger than any of the two, when one of the signal intensities is negative).

DAMPCalcRelativeDifference[ref_, smpl_, threshold_:0] := N[(smpl - ref)/(Chop[1.Max[smpl, ref, Abs[smpl - ref]], threshold]/.{0∞, 0.∞})]