Computes PCA using one of the methods provided in the Bioconductor package pcaMethods and plots the two first principal components.
Usage
plot_pca(
object,
pcs = c(1, 2),
all_features = FALSE,
center = TRUE,
scale = "uv",
color = NULL,
shape = color,
label = NULL,
density = FALSE,
title = "PCA",
subtitle = NULL,
color_scale = NA,
shape_scale = getOption("notame.shape_scale"),
fill_scale = getOption("notame.fill_scale_dis"),
text_base_size = 14,
point_size = 2,
assay.type = NULL,
...
)
Arguments
- object
a
SummarizedExperiment
orMetaboSet
object- pcs
numeric vector of length 2, the principal components to plot
- all_features
logical, should all features be used? If FALSE (the default), flagged features are removed before visualization.
- center
logical, should the data be centered prior to PCA? (usually yes)
- scale
scaling used, as in
prep
. Default is "uv" for unit variance- color
character, name of the column used for coloring the points. Set to NULL for black color.
- shape
character, name of the column used for shape. Set to NULL for uniform round shapes.
- label
character, name of the column used for point labels
- density
logical, whether to include density plots to both axes. The density curves will be split and colored by the 'color' variable.
- title, subtitle
the titles of the plot
- color_scale
the color scale as returned by a ggplot function. Set to NA to choose the appropriate scale based on the class of the coloring variable.
- shape_scale
the shape scale as returned by a ggplot function
- fill_scale
the fill scale used for density curves. If a continuous variable is used as color, density curve will be colorless.
- text_base_size
numeric, base size for text
- point_size
numeric, size of the points
- assay.type
character, assay to be used in case of multiple assays
- ...
additional arguments passed to
pca
Value
A ggplot object. If density
is TRUE
, the plot will
consist of multiple parts and is harder to modify.
Examples
data(example_set)
plot_pca(example_set, color = "Injection_order", shape = "Group")
#> svd calculated PCA
#> Importance of component(s):
#> PC1 PC2
#> R2 0.2504 0.05641
#> Cumulative R2 0.2504 0.30681