
Make a PCA-vs-metadata association heatmap with heatmaply()
Source: R/heatmap.R
interactive_pca_metadata_heatmap.RdRuns anova_pca_metadata on the supplied PCA coordinates and
sample metadata, then renders the resulting p value matrix with
interactive_heatmap: -log10(p) sets the cell color, the raw p
values are shown on hover, and variables (rows) with a single, uninformative
value across all shown cells are dropped when cluster_rows is TRUE.
Usage
interactive_pca_metadata_heatmap(
pca_coords,
pcameta,
fraction_explained,
cluster_rows = TRUE,
n_components = 10,
plot_height = NULL,
...
)Arguments
- pca_coords
Data frame of PCA coordinates, with samples by row and components by column (e.g. the
xelement ofrunPCA'sprcompresult).- pcameta
Data frame of sample metadata with sample identifiers by row and variables by column.
- fraction_explained
Numeric vector containing the percent contribution to variance of each component (e.g. from
calculatePCAFractionExplained).- cluster_rows
Cluster variables (rows) by their p value profile across components?
- n_components
Number of leading components to test, passed through to
anova_pca_metadata.- plot_height
The total rendered height of the plot in pixels, passed through to
interactive_heatmap. Defaults to a height scaled to the number of variables.- ...
Additional arguments passed to
interactive_heatmap
Value
output A plotly htmlwidget as produced by interactive_heatmap
Examples
pcameta <- data.frame(
row.names = paste0("sample", 1:6),
treatment = rep(c("control", "treated"), each = 3),
batch = rep(c("a", "b"), 3)
)
pca_coords <- matrix(rnorm(6 * 4), nrow = 6, dimnames = list(rownames(pcameta), paste0("PC", 1:4)))
interactive_pca_metadata_heatmap(pca_coords, pcameta, fraction_explained = c(45, 25, 20, 10))