% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/qc_plots.R
\name{diff_expr_PCA_ggplot}
\alias{diff_expr_PCA_ggplot}
\title{Function to generate an ordinary two-dimensional PCA plot using `ggplot2`}
\usage{
diff_expr_PCA_ggplot(
  PCA,
  samp.name = NULL,
  groups,
  grp.nam = NULL,
  PC = c(1, 2),
  main = NULL,
  ellipse = TRUE,
  ellipse.mapping.groups = NULL,
  ellipse.grp.nam = NULL,
  label.samples = TRUE,
  geom.point.size = 2,
  label.font.size = 5,
  plot.ellipse.legend = NA,
  do.plot = TRUE
)
}
\arguments{
\item{PCA}{List of class \code{prcomp} or just a list having a component \code{x} that contains the rotated variables from \code{prcomp}.}

\item{samp.name}{Optional sample names to be used in the plot, given as character vector.}

\item{groups}{Sample groups for plot annotation as character vector or factor.}

\item{grp.nam}{Legend title.}

\item{PC}{Integer vector of length two specifying the principal components to be plotted.}

\item{main}{Plot title.}

\item{ellipse}{Logical indicating whether to draw an ellipse around the sample groups.}

\item{ellipse.mapping.groups}{Optional additional grouping for ellipse drawing. Overrides sample groups.
Use for selective highlighting of user-defined sample groups.}

\item{ellipse.grp.nam}{Not implemented.}

\item{label.samples}{Logical; should the points be annotated with sample name labels?}

\item{geom.point.size}{Numeric passed to \code{geom_point} giving the point size.}

\item{label.font.size}{Numeric passed to \code{geom_text_repel} giving the label font size.}

\item{plot.ellipse.legend}{Logical; should the ellipse legend be plotted. \code{NA}, the default, will plot it if any aesthetics are mapped.}

\item{do.plot}{Logical; should the plot be printed to the graphics device? Defaults to \code{TRUE}.}
}
\value{
A \code{ggplot} object containing the labelled PCA scatterplot.
}
\description{
Function to generate an ordinary two-dimensional PCA plot using `ggplot2`
}
\examples{
si <- diff_expr_get_samp_info(diffwrap_samp_info, "SampleName", "Group")
counts <- diff_expr_filter_counts(diff_expr_read_counts(diffwrap_counts, si), si)
groups <- stats::relevel(si$Groups, ref = "control")
pca <- diff_expr_PCA(edgeR::cpm(counts, log = TRUE), n = 100)
g <- diff_expr_PCA_ggplot(pca, samp.name = NULL, groups = groups, do.plot = FALSE)
class(g)
}
\seealso{
[stat_ellipse()]
}
