
Plot expression profiles for a set of feature clusters with plot_ly()
Source: R/clustering.R
interactive_cluster_profiles.RdDraws one sub-plot per cluster of a scaled expression matrix (e.g. as
produced by run_clustering), combined with
plotly::subplot(). Three display modes are available: individual
sample lines, a mean/median line with error bars, or a mean/median line
with a shaded error band. Summary statistics (mean, median and their
spreads) are derived internally with summary_se.
Arguments
- matrices_by_cluster
A named list of matrices/data frames, one per cluster, features by row and samples by column (e.g. the input matrix split by
clustering$clusteringfromrun_clustering). Names should be the cluster numbers as produced bysplit(), sincecolorsis indexed by cluster number.- cluster_display
'filled_line' (a mean/median line with a shaded error band), 'sample_lines' (individual sample profiles) or 'error_bars' (a mean/median line with error bars)
- average_type
'mean' or 'median'
- limits
Which spread to show around the average: 'sd' (standard deviation), 'se' (standard error) or 'ci' (95% confidence interval). Ignored when
cluster_display = "sample_lines"- colors
A vector of colors, indexed by cluster number (i.e.
colors[[2]]colors the cluster named "2" inmatrices_by_cluster). Defaults tomake_color_scale- sample_order
Character vector giving the sample (x axis) display order. Defaults to
colnames()of the first cluster's matrix- max_sample_lines
Maximum number of sample lines drawn per cluster under
cluster_display = "sample_lines"; larger clusters are randomly subsampled to this many rows- summarised_matrices_by_cluster
Precomputed summary statistics, one element per cluster, as returned by
summary_seon each element ofmatrices_by_cluster. Computed internally if not supplied; callers that already have this (e.g. to cache it separately from the display controls below) can pass it through directly
Examples
set.seed(1)
matrices_by_cluster <- list(
`1` = matrix(rnorm(30), nrow = 5, dimnames = list(paste0("gene", 1:5), paste0("sample", 1:6))),
`2` = matrix(rnorm(30), nrow = 5, dimnames = list(paste0("gene", 6:10), paste0("sample", 1:6)))
)
interactive_cluster_profiles(matrices_by_cluster, cluster_display = "filled_line")