
Make an interactive boxplot with coloring by experimental variable
Source:R/boxplot.R
interactive_boxplot.RdDraws a plotly box plot of the value distribution in each sample.
Box statistics (quartiles, whiskers, outliers) are computed server-side and
supplied to plotly as precomputed values, so the browser payload scales with
the number of samples rather than the size of the matrix. This makes it
usable on full expression matrices where sending every point would not be.
Usage
interactive_boxplot(
plotmatrices,
experiment,
colorby = NULL,
palette = NULL,
expressiontype = "expression",
palette_name = COLORBLIND_PALETTE_NAME,
whisker_distance = 1.5,
annotate_samples = FALSE,
should_transform = NULL,
max_outliers = 500,
hidden_groups = character(0),
source = NULL
)Arguments
- plotmatrices
Expression/ other data matrix, or named list thereof
- experiment
Annotation for the columns of plotmatrix
- colorby
Column name in
experimentspecifying how boxes should be colored- palette
Palette of colors, one for each unique value derived from
colorby.- expressiontype
Expression type for use in y axis label
- palette_name
Valid R color palette name
- whisker_distance
IQR multiplier for the whiskers, and the boundary beyond which points are drawn as outliers (see
coefingeom_boxplot, default: 1.5)- annotate_samples
Add a suffix to sample labels reflecting their group?
- should_transform
A boolean indicating if the log2 transformation should be applied. If TRUE, log2 transformation is applied unconditionally. If FALSE, no transformation is applied. If NULL, a conditional transformation based on threshold is applied.
- max_outliers
Maximum number of outlier points to draw per facet. When a sample set produces more, the most extreme (furthest from the median) are kept so the overlay stays bounded (default: 500).
Values of
colorbyto exclude: their samples are dropped so the plot is redrawn on the remainder, while they stay in the legend (aslegendonly) so they can be toggled back on.- source
Optional plotly source id used to route legend-click (
plotly_restyle) events back to a Shiny session.
Examples
require(airway)
data(airway, package = "airway")
interactive_boxplot(assays(airway)[[1]], data.frame(colData(airway)), colorby = "dex")