plot_pca_biplot: Plot a biplot from a PCAtools 'pca' object

View source: R/plotting_qc.R

plot_pca_biplotR Documentation

Plot a biplot from a PCAtools pca object

Description

This function plots a biplot from a PCAtools pca object.

Usage

plot_pca_biplot(
  pca.res,
  dim.x = "PC1",
  dim.y = "PC2",
  dim.z = NULL,
  plot.title = "PCA Biplot",
  color.by = NULL,
  shape.by = NULL,
  hover.info = NULL,
  show.loadings = FALSE,
  n.loadings = 3,
  pt.size = 12
)

Arguments

pca.res

A pca generated by the PCAtools package.

dim.x

Character scalar for the principal component to plot on the x-axis.

dim.y

Character scalar for the principal component to plot on the y-axis.

dim.z

Character scalar for the principal component to plot on the z-axis.

plot.title

Character scalar for the title of the plot.

color.by

Character scalar for the column name to use for coloring points.

shape.by

Character scalar for the column name to use for shaping points.

hover.info

Character vector of column name(s) to include in the hover info for each point.

show.loadings

Boolean indicating whether to show component loadings on the plot.

n.loadings

Integer for number of loadings to show.

pt.size

Numeric size of the plotted points.

Value

A plotly plot of the PCA biplot, or a text grob indicating no PCA was provided.

Author(s)

Jared Andrews

See Also

pca

Examples

library("PCAtools")
library("CRISPRball")
col <- 10
row <- 2000
mat <- matrix(
    rexp(col * row, rate = 0.1),
    ncol = col
)
rownames(mat) <- paste0("gene", seq_len(nrow(mat)))
colnames(mat) <- paste0("sample", seq_len(ncol(mat)))

metadata <- data.frame(row.names = colnames(mat))
metadata$Group <- rep(NA, ncol(mat))
metadata$Group[seq(1, 10, 2)] <- "A"
metadata$Group[seq(2, 10, 2)] <- "B"

p <- pca(mat, metadata = metadata, removeVar = 0.1)
plot_pca_biplot(p, color.by = "Group")

j-andrews7/CRISPRball documentation built on Nov. 30, 2023, 7:34 p.m.