BioInfWeb Main Page
Home / Help / Calculating node/branch data
  Article Discussion Edit History

Help - Calculating node/branch data

From TreeGraph help

Jump to: navigation, search

The Calculate node/branch data... function allows you to specify an mathematical expression which defines values for all lines of a node/branch data column. In this expression you can reference the current values of the specified column as well as the values of all other columns. Additionally a set of predefined functions and constants (see below) can be used.

Note that this feature was not available before version 2.0.24. The Edit node/branch data-dialog which was present before this version offered a set of rescaling operations instead. It is recommended to use the latest version of TreeGraph 2.

Contents

The dialog

The "Calculate node/branch data"-dialog
Enlarge
The "Calculate node/branch data"-dialog


To access the Calculate node/branch data-dialog select EditNode/branch dataCalculate node/branch data... from the main menu.

Column

Here you can select the node/branch data column that shall be calculated. The column which was selected in the document window is preselected here if it is editable.

Expression

You can type in a mathematical expression like it is describes below here.

Recently used expressions

In this list you select one of the last 25 valid expressions you have specified to use them again.

Expressions

Accessing node/branch data

The function getValue returns the value of a specified node/branch data column in the line which is currently calculated. It can take one or two parameters. The first parameter always specifies the column that should be referenced either by its ID (if it is a hidden node/branch data or a label column) or by a special key word (see below) used to identify the default node name-, node name- or branch length-column.

The second parameter is optional and defines a default value which is returned if the referenced column does not contain a value in the current line. If no default value is specified and the referenced column contains no value the calculation for this line is aborted and the value stored in the target column will be empty.

Examples

Expression: Description:
getValue(NAME) Returns the node name in the current line. (Could be a numeric or a textual value.)
getValue(LENGTH) Returns the branch length in the current line.
getValue(LENGTH, 0) Returns the branch length in the current line or 0 if no branch length is specified.
getValue("id1") Returns the value of the column with the ID "id1" in the current line. (This could be a hidden node data-, a hidden branch data or a label column.)

Checking node/branch data

The function hasValue can be used to check whether a node/branch data column contains a value in the current line. It has one parameter which specifies the column (analog to getValue) that shall be checked.

This function can be helpful in combination with the if-function (see below) in an expression like this:

if(hasValue("id1") || hasValue("id2"), getValue(NAME), "undefined")

Special keywords

The following special keywords can be used with the getValue or hasValue functions.

  • THIS: References the column which shall be calculated by this expression (e.g. getValue(THIS) * 2).
  • UNIQUE: References the unique node name column.
  • NAME: References the node name column.
  • LENGTH: References the branch length column.

Operators

The following list contains all valid operators. Each operator binds as much or more than all operators listed below. The right columns indicate of which types the operands have to be.

Name: Operator: Numeric: Textual: Boolean: Example:
Power ^ Image:YesSymbol.png Image:NoSymbol.png Image:NoSymbol.png 10^-2 (= 0.02)
Unary plus + Image:YesSymbol.png Image:NoSymbol.png Image:NoSymbol.png +4
Unary minus - Image:YesSymbol.png Image:NoSymbol.png Image:NoSymbol.png -4
Modulo % Image:YesSymbol.png Image:NoSymbol.png Image:NoSymbol.png 10 % 4 (= 2)
Division / Image:YesSymbol.png Image:NoSymbol.png Image:NoSymbol.png getValue(LENGTH) / 2
Multiplication * Image:YesSymbol.png Image:NoSymbol.png Image:NoSymbol.png getValue("id1") * 100
Addition + Image:YesSymbol.png Image:YesSymbol.png Image:NoSymbol.png
getValue("id1") + 10
"Two " + "words"
Less or Equal <= Image:YesSymbol.png Image:NoSymbol.png Image:NoSymbol.png if(getValue(THIS) <= 100, getValue(THIS), 100)
More or Equal >= Image:YesSymbol.png Image:NoSymbol.png Image:NoSymbol.png if(getValue(THIS) <= 100, "A", "B")
Less than < Image:YesSymbol.png Image:NoSymbol.png Image:NoSymbol.png if(getValue(THIS) < 100, getValue(THIS), 100)
Greater than > Image:YesSymbol.png Image:NoSymbol.png Image:NoSymbol.png if(getValue(THIS) < 100, "A", "B")
Equal = Image:YesSymbol.png Image:YesSymbol.png Image:NoSymbol.png if(getValue(THIS) = 100, getValue("id"), getValue("id2"))
Not equal != Image:YesSymbol.png Image:YesSymbol.png Image:NoSymbol.png if(getValue(THIS) != "empty", getValue("id1"), 0)
And && Image:NoSymbol.png Image:NoSymbol.png Image:YesSymbol.png if(getValue(THIS) < 100 && getValue(THIS) > 50, getValue("id1"), "")
Or || Image:NoSymbol.png Image:NoSymbol.png Image:YesSymbol.png if(hasValue("id1") || hasValue("id2"), getValue(NAME), "undefined")

General functions

Name: Definition: Description:
Sine sin(Numeric x) Calculates the sine of the passed numeric value.
Cosine cos(Numeric x) Calculates the cosine of the passed numeric value.
Tangent tan(Numeric x) Calculates the tangent of the passed numeric value.
Inverse sine asin(Numeric x) Calculates the inverse sine of the passed numeric value.
Inverse cosine acos(Numeric x) Calculates the inverse cosine of the passed numeric value.
Inverse tangent atan(Numeric x) Calculates the inverse tangent of the passed numeric value.
Inverse tangent atan2(Numeric x, Numeric y) Calculates the inverse tangent (or arcus tangent) of y / x given adjacent and x. The result is between -π and π
Hyperbolic sine sinh(Numeric x) Calculates the hyperbolic sine of the given angle.
Hyperbolic cosine cosh(Numeric x) Calculates the hyperbolic cosine of the given angle.
Hyperbolic tangent tanh(Numeric x) Calculates the hyperbolic tangent of the given angle.
Inverse hyperbolic sine asinh(Numeric x) Calculates the inverse hyperbolic sine of the given angle.
Inverse hyperbolic cosine acosh(Numeric x) Calculates the inverse hyperbolic cosine of the given angle.
Inverse hyperbolic tangent atanh(Numeric x) Calculates the inverse hyperbolic tangent of the given angle.
Natural logarithm ln(Numeric x) Calculates the natural logarithm of the passed numeric value.
Logarithm to the base 10 log(Numeric x) Calculates the logarithm to the base 10 of the passed numeric value.
Exponential function exp(Numeric x) Calculates the exponential function to the base e. It is the inverse function of the natural logarithm (ln).
Magnitude abs(Numeric x) Returns the absolute value of the passed numeric parameter.
Random number rand(Numeric x) Returns a random number between 0 and 1.
Square Root sqrt(Numeric x) Calculates the square root of the passed numeric parameter.
Alternative if(Boolean condition, Numeric or textual trueValue, Numeric or textual falseValue) Returns the second parameter if the condition is true or the third if not.
Number to text str(Numeric or textual x) Returns a textual representation of the passed parameter.
Number to text str(Numeric or textual x) Returns a textual representation of the passed parameter.

Constants

  • Euler's number: e
  • π: pi

See also

TreeGraph 2