Plot a biplot of the PCs from an object generated by perform.PCA. A biplot overlays sample scores (dots) with variable loadings (arrows), showing which proteins contribute most to the separation of samples along the selected principal components.
# S3 method for class 'PC.biplot'
plot(
DEprot.PCA.object,
PC.x = 2,
PC.y = 1,
color.column = "column.id",
shape.column = NULL,
label.column = NULL,
plot.zero.line.x = TRUE,
plot.zero.line.y = TRUE,
n.loadings = 10,
loading.color = "turquoise4",
loading.arrow.size = 0.6,
loading.label.size = 3,
loading.alpha = 0.7,
loading.scale = 0.8
)An object of class DEprot.PCA, as generated by perform.PCA.
Number indicating which Principal Component (PC) to display on the x-axis. Default: 2 (PC2).
Number indicating which Principal Component (PC) to display on the y-axis. Default: 1 (PC1).
String indicating the name of the column in the metadata to use as factor for the dot colors. Default: "column.id" (each sample a color).
String indicating the name of the column in the metadata to use as factor for the dot shapes. Default: NULL (all dots).
String indicating the name of the column in the metadata to use as label of the dots. Default: NULL (no labeling).
Logical value to indicate whether to plot two gray dashed line in correspondence of x=0. Default: TRUE.
Logical value to indicate whether to plot two gray dashed line in correspondence of y=0. Default: TRUE.
Integer indicating the number of top contributing protein loadings (arrows) to display on the biplot. Proteins are ranked by their Euclidean distance from the origin in the selected 2D PC plane. Default: 10.
String indicating the color used for the loading arrows and labels. Default: "turquoise4".
Numeric value indicating the linewidth of the loading arrows. Default: 0.6.
Numeric value indicating the font size of the loading labels. Default: 3.
Numeric value (0 to 1) indicating the transparency of the loading arrows and labels. Default: 0.7.
Numeric value used as a multiplier to manually adjust the scaling of the loading arrows relative to the sample scores. Values > 1 make arrows longer, values < 1 make them shorter. Default: 0.8.
A ggplot object.
The function extracts protein loadings from the PCA object stored in the prcomp slot.
When the PCA was computed using stats::prcomp (no missing values), the protein projections
from prcomp$x are used. When the PCA was computed using pcaMethods::pca (missing values
present), the protein loadings from the loadings slot are used.
In both cases, the loadings are scaled so that the arrows fit visually within the range of the
sample scores. Only the top n.loadings proteins (by Euclidean distance from origin in the
selected PC plane) are displayed to keep the plot readable.
Gene/protein names are extracted from the row names of the loadings matrix.
# Perform Principal Component Analyses (PCA)
pca <- perform.PCA(DEprot.object = DEprot::test.toolbox$dpo.imp)
# Plot biplot of PC1-vs-PC2
plot.PC.biplot(DEprot.PCA.object = pca,
color.column = "condition",
shape.column = "replicate",
n.loadings = 10)
# Plot biplot of PC2-vs-PC3 with more loadings
plot.PC.biplot(DEprot.PCA.object = pca,
PC.x = 3,
PC.y = 2,
color.column = "condition",
n.loadings = 15,
loading.color = "gray30")