Description Usage Arguments Details Value Categorical colormaps Accessors Setters Examples
ExperimentColorMap class
1 2 3 4 5 6 7 8 9 10 |
assays |
List of colormaps for |
colData |
List of colormaps for |
rowData |
List of colormaps for |
all_discrete |
Colormaps applied to all undefined
categorical |
all_continuous |
Colormaps applied to all undefined
continuous |
global_discrete |
Colormap applied to all undefined categorical covariates. |
global_continuous |
Colormap applied to all undefined continuous covariates. |
... |
additional arguments passed on to the |
Colormaps must all be functions that take at least one argument: the number
of (named) colours to return as a character
vector.
This argument may be ignored in the body of the colormap function
to produce constant colormaps.
An object of class ExperimentColorMap
The default categorical colormap emulates the default ggplot2 categorical color palette (Credit: https://stackoverflow.com/questions/8197559/emulate-ggplot2-default-color-palette). This palette returns a set of colors sampled in steps of equal size that correspond to approximately equal perceptual changes in color:
1 2 3 4 |
To change the palette for all categorical variables,
users must supply a colormap that returns a similar value;
namely, an unnamed character vector of length n
.
For instance, using the base R palette rainbow.colors
1 2 3 |
In the following code snippets, x
is an ExperimentColorMap
object.
If the colormap can not immediately be found in the appropriate slot,
discrete
is a logical(1)
that indicates
whether the default colormap returned should be categorical TRUE
or continuous (FALSE
, default).
assayColorMap(x, i, ..., discrete=FALSE)
:Get an assays
colormap.
colDataColorMap(x, i, ..., discrete=FALSE)
:Get a colData
colormap.
rowDataColorMap(x, i, ..., discrete=FALSE)
:Get a rowData
colormap.
In the following code snippets, x
is an ExperimentColorMap
object,
and i
is a character or numeric index.
assayColorMap(x, i, ...) <- value
:Set an assays
colormap.
colDataColorMap(x, i, ...) <- value
:Set a colData
colormap.
rowDataColorMap(x, i, ...) <- value
:Set a rowData
colormap.
assay(x, i, ...) <- value
:Alias. Set an assays
colormap.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # Example colormaps ----
count_colors <- function(n){
c("black", "brown", "red", "orange", "yellow")
}
fpkm_colors <- viridis::inferno
tpm_colors <- viridis::plasma
qc_color_fun <- function(n){
qc_colors <- c("forestgreen", "firebrick1")
names(qc_colors) <- c("Y", "N")
return(qc_colors)
}
# Constructor ----
ecm <- ExperimentColorMap(
assays=list(
counts=count_colors,
tophat_counts=count_colors,
cufflinks_fpkm=fpkm_colors,
rsem_tpm=tpm_colors
),
colData=list(
passes_qc_checks_s=qc_color_fun
)
)
# Accessors ----
# assay colormaps
assayColorMap(ecm, "logcounts") # [undefined --> default]
assayColorMap(ecm, "counts")
assayColorMap(ecm, "cufflinks_fpkm")
assay(ecm, "cufflinks_fpkm") # alias
# colData colormaps
colDataColorMap(ecm, "passes_qc_checks_s")
colDataColorMap(ecm, "undefined")
# rowData colormaps
rowDataColorMap(ecm, "undefined")
# generic accessors
assays(ecm)
assayNames(ecm)
# Setters ----
assayColorMap(ecm, "counts") <- function(n){c("blue", "white", "red")}
assay(ecm, 1) <- function(n){c("blue", "white", "red")}
colDataColorMap(ecm, "passes_qc_checks_s") <- function(n){NULL}
rowDataColorMap(ecm, "undefined") <- function(n){NULL}
# Categorical colormaps ----
# Override all discrete colormaps using the base rainbow palette
ecm <- ExperimentColorMap(global_discrete = rainbow)
n <- 10
plot(1:n, col=assayColorMap(ecm, "undefined", discrete = TRUE)(n), pch=20, cex=3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.