colByValue | R Documentation |
Given a set of values, return a color for each of them based on their numeric value.
colByValue(value, colors, min=NULL, max=NULL)
value |
A vector of numeric values |
colors |
(color) The colors to built the color ramp. Refer to |
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) |
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
A vector of colors
Alpha values (transparency) are also used in the color computation (see examples)
kpPoints, colByChr
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.