colByValue: colByValue

Description Usage Arguments Details Value Note See Also Examples

View source: R/color.R

Description

Given a set of values, return a color for each of them based on their numeric value.

Usage

1

Arguments

value

A vector of numeric values

colors

(color) The colors to built the color ramp. Refer to colorRamp for more details.

min

(NULL or numeric) The min value used to normalize the values. If NULL, min(value) will be used. (defaults to NULL)

max

(NULL or numeric) The max value used to normalize the values. If NULL, max(value) will be used. (defaults to NULL)

Details

A color ramp (similar to a gradient) will be built using the colors in the 'colors' parameter using colorRamp. Values will be normalized to [0,1] using 'min' and 'max' (if NULL, min(value) will be 0 and max(value) will be 1) and these values will be used to determine the color. It uses

Value

A vector of colors

Note

Alpha values (transparency) are also used in the color computation (see examples)

See Also

kpPoints, colByChr

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
colByValue(c(0,0.25,0.5,0.75,1), colors=c("red", "green"))
colByValue(c(0,0.25,0.5,0.75,1), colors=c("#00000000", "#00000011"))

data <- toGRanges("chr1", c(1e6*1:245), c(1e6*1:245)+10)
data$y <- rnorm(n = length(data), mean = 0.5, sd = 0.15)

kp <- plotKaryotype(chromosomes="chr1")
kpPoints(kp, data=data, r0=0, r1=0.3)
kpPoints(kp, data=data, r0=0.35, r1=0.65, col=colByValue(data$y, colors=c("black", "green")) )
kpPoints(kp, data=data, r0=0.7, r1=1, col=colByValue(data$y, colors=c("black", "green"), min=0.4, max=0.6))

kp <- plotKaryotype(chromosomes="chr1")
kpPoints(kp, data=data, r0=0, r1=0.3, col=colByValue(data$y, colors=c("#00000000", "#000000FF")))
kpPoints(kp, data=data, r0=0.35, r1=0.65, col=colByValue(data$y, colors=c("black", "orange", "green")) )
kpPoints(kp, data=data, r0=0.7, r1=1, col=colByValue(data$y, colors=c("red", "#00000022","#00000022", "green"),min=0.4, max=0.6))

karyoploteR documentation built on Nov. 8, 2020, 5:52 p.m.