View source: R/base_package_functions.R View source: R/Package-Code5-Compiled.R
myColorRamp5 | R Documentation |
Based on a provided numeric vector, returns a color gradient based on quartiles indicating level of expression.
myColorRamp5(colors, values, percent.mad = 0.5)
colors |
a character vector of length 5 providing the colors for which the gradient will be based on |
values |
numeric vector for which the gradient will be based on |
percent.mad |
percent of the median absolute deviation away from the median value that will determine the binning of the data |
The function differs from the standard colorRamp in that the input values are binned before being assigned colors to avoid the heavy influence of extreme values on the color gradient. This function separates the values into quartiles based on the median value of the data and the indicated percent.mad which determines how the upper and lower bins are assigned.
The lowest quartile set from colors[1]-colors[2] ranges from min(values) < x <= median(values) - percent.mad*mad(values)
The lower middle quartile set from colors[2]-colors[3] ranges from median(values) - percent.mad*mad(values) < x <= median(values)
The higher middle quartile set from colors[3]-colors[4] ranges from median(values) < x <= median(values) + percent.mad*mad(values)
The highest quartile set from colors[4]-colors[5] ranges from median(values) + percent.mad*mad(values) < x <= max(values)
(NAs are removed for all calculations)
a vector of color assignments for the values provided (in the same order)
Mostly used internally by plotting functions where points are colored by expression level
~~Alison Moss~~
##initiate parameters
initiate_params()
##for a given gene of interest, color samples by expression level,
goi <- "Th"
genedat<- RAGP_norm[goi,]
cols <- myColorRamp5(params$expression_gradient.colors,genedat, percent.mad = 0.5)
cols <- myColorRamp5(c("red","orange","yellow","green","blue"),genedat, percent.mad = 0.75)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.