map_to_colors-ColorMapping-method: Map values to colors

Description Usage Arguments Details Value Author(s) Examples

Description

Map values to colors

Usage

1
2
## S4 method for signature 'ColorMapping'
map_to_colors(object, x)

Arguments

object

a ColorMapping-class object.

x

input values.

Details

It maps a vector of values to a vector of colors.

Value

A vector of colors.

Author(s)

Zuguang Gu <z.gu@dkfz.de>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# discrete color mapping for characters
cm = ColorMapping(name = "test",
    colors = c("blue", "white", "red"),
    levels = c("a", "b", "c"))
map_to_colors(cm, "a")
map_to_colors(cm, c("a", "a", "b"))

# discrete color mapping for numeric values
cm = ColorMapping(name = "test",
    colors = c("blue", "white", "red"),
    levels = c(1, 2, 3))
map_to_colors(cm, 1)
map_to_colors(cm, "1")
map_to_colors(cm, c(1, 1, 2, 2))

# continuous color mapping
require(circlize)
cm = ColorMapping(name = "test",
    col_fun = colorRamp2(c(0, 0.5, 1), c("blue", "white", "red")))
map_to_colors(cm, 0.2)
map_to_colors(cm, seq(0.2, 0.8, by = 0.1))

eilslabs/ComplexHeatmap documentation built on May 16, 2019, 1:21 a.m.