pcaPlot | R Documentation |
Create a PCA scatter plot from log-expression data with sample labels.
pcaPlot(
logcounts,
Sample,
Group,
title,
palette,
maxOverlaps,
sizeLabel,
center,
scale
)
logcounts |
Numeric matrix of log-CPM values (genes × samples), e.g., from edgeR::cpm. |
Sample |
Character vector of sample names corresponding to the columns of "logcounts". |
Group |
Factor or character vector denoting group/condition for each sample. |
title |
Character. Title for the PCA plot. |
palette |
Character. Name of a discrete color palette from the "paletteer" package. |
maxOverlaps |
Integer. Maximum number of overlapping labels allowed by "ggrepel". |
sizeLabel |
Numeric. Font size for sample labels. |
center |
Logical. If TRUE, center variables before PCA. |
scale |
Logical. If TRUE, scale variables to unit variance before PCA. |
This function performs Principal Component Analysis (PCA) on a log-count matrix and visualizes the first two principal components using ggplot2 and ggrepel. Each point represents a sample, colored by group, with hover labels.
Transposes the "logcounts" matrix so samples are rows.
Runs PCA via "stats::prcomp()" with centering and scaling options.
Calculates percent variance explained by PC1 and PC2.
Builds a scatter plot with black‐bordered points and non‐overlapping labels.
A "ggplot" object displaying the PCA scatter plot of PC1 vs PC2.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.