Runs PCA on normalized counts. Makes PCA and scree plots. Tests for significant clustering based on specific variables using PERMANOVA and Euclidean distances.

plot_PCA(
  x,
  norm_cts_type = "edger",
  assay_name = "norm_log_cpm",
  color_by = colnames(colData(x))[[1]],
  shape_by = colnames(colData(x))[[1]],
  adonis = TRUE,
  adonis_by = colnames(colData(x))[[1]]
)

Arguments

x

A BbcSE object.

norm_cts_type

"edger" or "deseq2"

assay_name

Name of assay from the 'norm_cts' slot. Option was implemented with the idea of being able to plot batch-corrected data.

color_by

colData column to color by for PCA plot

shape_by

colData column to shape by for PCA plot

adonis

logical for whether vegan::adonis should be run. If TRUE, adonis() will be run with Euclidean distance calculated from the same normalized counts as used for PCA.

adonis_by

colData column to test using PERMANOVA. May be a vector of values; in this case, each variable is tested sequentially using adonis().

Value

A list containing ggplot objects for 1. PCA 2. scree plot 3. prcomp()$x merged with meta data. Handy if visualizations of >PC2 are needed 4. a list of output from vegan::adonis()

See also