# Module: LocusZoom_TransformationFunctions

Transformation functions: used to transform a raw data value. For example, a template or axis label can convert from pvalue to -log10pvalue by specifying the following field name (the `|funcname` syntax indicates applying a function):

`{{assoc:pvalue|neglog10}}`

Transforms can also be chained so that several are used in order from left to right: `{{log_pvalue|logtoscinotation|htmlescape}}`

Most parts of LocusZoom that rely on being given a field name (or value) can be used this way: axis labels, position, match/filter logic, tooltip HTML template, etc. If your use case is not working with filters, please file a bug report!

NOTE: for best results, don't specify filters in the `fields` array of a data layer- only specify them where the transformed value will be used.

Source:
  - helpers/transforms.js, line 1

### Methods

#### (static) htmlescape(value) → {string}

HTML-escape user entered values for use in constructed HTML fragments

For example, this filter can be used on tooltips with custom HTML display. This protects against some forms of XSS injection when plotting user-provided data, as well as display artifacts from field values with HTML symbols such as `<` or `>`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`value` | String | HTML-escape the provided value

Source:
  - helpers/transforms.js, line 104

##### Returns:

Type
  string

#### (static) is_numeric(value) → {boolean}

Return true if the value is numeric (including 0)

This is useful in template code, where we might wish to hide a field that is absent, but show numeric values even if they are 0 Eg, `{{#if value|is_numeric}}...{{/if}}

##### Parameters:

Name | Type | Description
--- | --- | ---
`value` | Number |

Source:
  - helpers/transforms.js, line 137

##### Returns:

Type
  boolean

#### (static) log10(value) → {null|number}

Return the log10 of a value. Can be applied several times in a row for, eg, loglog plots.

##### Parameters:

Name | Type | Description
--- | --- | ---
`value` | number |

Source:
  - helpers/transforms.js, line 25

##### Returns:

Type
  null | number

#### (static) logtoscinotation(value) → {string}

Convert a number from logarithm to scientific notation. Useful for, eg, a datasource that returns -log(p) by default

##### Parameters:

Name | Type | Description
--- | --- | ---
`value` | number |

Source:
  - helpers/transforms.js, line 49

##### Returns:

Type
  string

#### (static) neglog10(value) → {number}

Return the -log (base 10), a common means of representing pvalues in locuszoom plots

##### Parameters:

Name | Type | Description
--- | --- | ---
`value` | number |

Source:
  - helpers/transforms.js, line 37

##### Returns:

Type
  number

#### (static) scinotation(value) → {String}

Represent a number in scientific notation

##### Parameters:

Name | Type | Description
--- | --- | ---
`value` | Number |

Source:
  - helpers/transforms.js, line 73

##### Returns:

Type
  String

#### (static) urlencode(value) → {string}

URL-encode the provided text, eg for constructing hyperlinks

##### Parameters:

Name | Type | Description
--- | --- | ---
`value` | String |

Source:
  - helpers/transforms.js, line 146

##### Returns:

Type
  string