DataType

Numeric Maps

A numeric map is a subtype of the general Map type where the values can only be numeric. There are three different types of numeric maps – Sequence Numeric Map, Motif Numeric Map and Module Numeric Map – that hold values for sequences, motifs and modules, respectively. Numeric maps that contain "Data⇔Value" associations for other types of data can be defined using Text Variables.

Creating Numeric Maps

The general syntax for creating Numeric Maps in a protocol is shown below.
MyNumericMap = new <Type> Numeric Map(<key1>=<value1>, <key2>=<value2>, ..., <keyN>=<valueN>, _DEFAULT_=<value>)

The argument is a comma-separated list of "key=value" pairs where the keys can be the name of a single data object (of the applicable type) or a collection. The wildcard operator (*) is also supported. In MotifLab v2, the key can also be a reference to a partition cluster, or it can refer to a range of data objects. The values on the right-hand side of the assignments can only be numeric constants and not references to other data objects (such as Numeric Variables).

Creating Random Numeric Maps
Sometimes it may be desirable to create maps containing a random value for each data item. This can be accomplished by first creating a map and then using the "random" transform operation to assign a random number to each entry. Note, however, that the transformation will only be applied to assigned entries in the map (plus the default value), so for this to work properly, all the entries in the original map must be assigned.

Incorrect way to create random maps
# Create an empty map with default value 0. Note that this map will NOT contain any assigned entries!
MyRandomMap = new Motif Numeric Map(0)
# Apply the random transform operation to change the map values to random numbers between 0 and 10.
# However, since the map does not contain any assigned entries, only the default value will be changed
# and all motifs will thus default to this same number (randomly chosen between 0 and 10)
transform MyRandomMap with random(10)

Correct way to create random maps
# Create an empty map where all motifs as explicitly assigned the value 0 using the wildcard operator
MyRandomMap = new Motif Numeric Map(*=0)
# Apply the random transform operation to change the map values to random numbers between 0 and 10.
# Since all entries were previously assigned, each entry is individually transformed into a new random number.
transform MyRandomMap with random(10)

Modifying Numeric Maps

Values in numeric maps can be set explicitly with the set operation or changed relative to the current values with the arithmetic operations increase, decrease, multiply and divide. Numeric Maps can also be transformed with threshold and transform.

# Increase the value of each map entry in Cutoff by 0.1 (including the default value)
increase cutoff by 0.1
# Multiply the value of each map entry in Map1 by its corresponding value in Map2
multiply Map1 by Map2