Skip to contents

Stacks interactive_screeplot directly above interactive_pca_metadata_heatmap in a single figure, sharing one x-axis. Both plots use identical, identically-ordered PC labels as their x-categories, so this lines each scree point up above its corresponding heatmap column, letting a "this PC is significantly associated" cell be read alongside how much variance that PC actually explains.

Usage

interactive_pca_variance_heatmap(
  pca_coords,
  pcameta,
  fraction_explained,
  cluster_rows = TRUE,
  n_components = 10,
  heatmap_height = 600,
  scree_height = 200,
  ...
)

Arguments

pca_coords

Data frame of PCA coordinates, with samples by row and components by column (e.g. the x element of runPCA's prcomp result).

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 show/test, passed to both interactive_screeplot and interactive_pca_metadata_heatmap.

heatmap_height

The rendered height, in pixels, of the heatmap portion of the combined figure.

scree_height

The rendered height, in pixels, of the scree portion of the combined figure.

...

Additional arguments passed to interactive_pca_metadata_heatmap

Value

output A plotly htmlwidget combining both plots

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_variance_heatmap(pca_coords, pcameta, fraction_explained = c(45, 25, 20, 10))