Visualize principal component analysis (PCA) results stored within a GenEDA object. This function extracts PCA data via ExtractPCA and provides a flexible ggplot2-based visualization interface.

PlotPCA(
  object,
  x = 1,
  y = 2,
  color_by,
  colors = NULL,
  split_by = NULL,
  shape_by = NULL,
  return_data = FALSE
)

Arguments

object

A GenEDA object containing PCA results in the DimReduction slot.

x

Numeric or character. The principal component to plot on the x-axis (e.g., 1 or "PC1").

y

Numeric or character. The principal component to plot on the y-axis (e.g., 2 or "PC2").

color_by

Character. Column name in the metadata used to color points.

colors

Vector. Custom colors to use for plotting

split_by

Character (optional). Column name in metadata used for faceting (creates separate panels).

shape_by

Character (optional). Column name in metadata used to control point shape.

return_data

Logical (default = FALSE), whether or not to return pca dataframe for more custom plotting.

Value

A ggplot object displaying the PCA scatter plot, or a list of pca_df and plot if return_data = TRUE

Examples

if (FALSE) { # \dontrun{
p <- PlotPCA(obj, x = 1, y = 2, color_by = "condition",
     colors = c("untreated" = "red", "treated" = "blue"),
     split_by = "library")
p
} # }