Plot PCA Rotation
plot_rotation.Rd
Plot the features from a PCA rotation in a 2-dimensional scatter plot. Note: The precedence for the ordering of the coloring is as follows:
col
scores
Usage
plot_rotation(
data.prcomp,
dims = 1:2L,
classes = NULL,
scores = NULL,
col = NULL,
set1 = NULL,
set2 = NULL,
set3 = NULL,
set4 = NULL,
set5 = NULL,
lab_cex = 3,
pt_cex = 2.5,
auto_ident = TRUE,
...
)
Arguments
- data.prcomp
A prcomp class object. Typically the object returned by
prcomp2()
.- dims
integer(2)
. Which dimensions to plot.- classes
Optional. A vector indicating the classes of features used for coloring the points. Must be the same length as the number of features.
- scores
Optional. Statistical scores to pass through for the coloring of the points during plotting. If a training data set is passed and
scores = NULL
, then KS-distances (scores) will be calculated under the hood and used to determine point color. Can be either a single value (e.g. "red") or a vector of color values the same length as the number of observations. This overrides the point color assigned byclasses
above.- col
character(1)
. The color of the points. Can be either a single value (e.g. "red") or a vector of color values the same length as the number of observations. This parameter overrides the point colors determined by both theclasses
andscores
parameters above.- set1
Optional. A vector of feature ids to mark on the plot. Typically a vector of analytes of clinical relevance, e.g. sample handling. Marked with a hollow diamond (see
pch()
).- set2
Optional. An additional vector of feature ids to mark on the plot, separately from those in
set1
. Marked with a hollow triangle (seepch()
).- set3
Optional. An additional vector of feature ids to mark on the plot, separately from those in
set1
. Marked with a hollow square (seepch()
).- set4
Optional. An additional vector of feature ids to mark on the plot, separately from those in
set1
. Marked with a hollow circle (seepch()
).- set5
Optional. An additional vector of feature ids to mark on the plot, separately from those in
set1
. Marked with a hollow upside-down triangle (seepch()
).- lab_cex
numeric(1)
. Font size of the point labels generated byauto_ident
.auto_ident
must be TRUE.- pt_cex
numeric(1)
. Character expansion for the points.- auto_ident
logical(1)
. Should the top 10 features, in both dimensions, be identified and labeled on the plot?- ...
Additional arguments passed to
plot_pca_dims()
.
See also
Other PCA plots:
plot_pca_dims()
,
plot_projection()
,
screeplot_auc()
Examples
pca <- center_scale(pcapkg:::log10_ft(simdata), center = TRUE, scale = FALSE) |>
feature_matrix() |>
prcomp2()
plot_rotation(pca, col = "green")
class <- withr::with_seed(123, sample(simdata$class_response, 40L))
plot_rotation(pca, classes = class)
y <- withr::with_seed(123, sample(pcapkg:::get_analytes(simdata), 10L))
plot_rotation(pca, set1 = y)