Builds a vector of #conditions
colors for a set of samples. One color is
given for a given condition. This function extends a base palette from the
package RColorBrewer to 'n' colors.
The colors in the returned palette are always in the same order
SampleColors(conds, pal.name = "Set1")
ExtendPalette(n, pal.name = "Set1")
GetColorsForConditions(conds, pal = NULL)
A character()
of conditions. The length of the vector is
the number of samples in the dataset.
A character(1)
which is the name of the palette from the
package RColorBrewer from which the colors are taken. Default value
is 'Set1'.
The number of desired colors in the palette
A vector of HEX color code that form the basis palette from which to build the complete color vector for the conditions.
A vector
A vector
A vector
#-----------------------------------------------
# Builds a palette for a dataset with 3 conditions
# of 3 samples each.
#------------------------------------------------
conds <- c(rep("A", 3), rep("B", 3), rep("C", 3))
SampleColors(conds)
#> [1] "#E41A1C" "#E41A1C" "#E41A1C" "#377EB8" "#377EB8" "#377EB8" "#4DAF4A"
#> [8] "#4DAF4A" "#4DAF4A"
SampleColors(conds, "Dark2")
#> [1] "#1B9E77" "#1B9E77" "#1B9E77" "#D95F02" "#D95F02" "#D95F02" "#7570B3"
#> [8] "#7570B3" "#7570B3"
#-----------------------------------------------
# Extend the default palette to 12 colors
#-----------------------------------------------
ExtendPalette(12)
#> [1] "#E41A1C" "#377EB8" "#4DAF4A" "#984EA3" "#FF7F00" "#FFFF33" "#A65628"
#> [8] "#F781BF" "#999999" "#8D4C6A" "#986433" "#BE345F"
data(vdata)
conds <- get_group(vdata)
GetColorsForConditions(conds, ExtendPalette(2))
#> [1] "#E41A1C" "#E41A1C" "#E41A1C" "#377EB8" "#377EB8" "#377EB8"