plotReduced: Score plot of dimension-reduced data

View source: R/plotReduced.R

plotReducedR Documentation

Score plot of dimension-reduced data

Description

Function to visualize dimension-reduced data matrices mainly produced by reduceFeatures, including reduced.pca, reduced.tsne, and reduced.plsda objects (or a matrix with the same structure).

Usage

plotReduced(
  x,
  comp = c(1, 2),
  biplot = FALSE,
  group,
  group_col = NULL,
  point_size = 1.5,
  point_shape_by_group = FALSE,
  label = FALSE,
  label_size = 3.88,
  label_subset = NULL,
  ellipse = FALSE,
  xlab = NULL,
  ylab = NULL,
  title = NULL,
  legend = TRUE,
  arrow_len = 0.2,
  arrow_col = "orange",
  arrow_alpha = 0.3,
  arrow_label = TRUE,
  arrow_label_ext = 1.05,
  arrow_label_size = 3.88,
  arrow_label_col = "orange",
  arrow_label_subset = NULL
)

Arguments

x

A matrix containing the dimension-reduced data typically produced by reduceFeatures.

comp

A numeric vector of length 2 specifying the components to display.

biplot

A logical specifying whether visualize an overlay of scores and loadings. Ignored if xis not a reduced.pca or reduced.plsda object.

group

A discrete variable to visualize the grouping structure. For a reduced.plsda object, group information used to fit the PLS-DA is used if not specified.

group_col

A vector of colors with the same length of unique values in group.

point_size

A numeric value specifying the size of points.

point_shape_by_group

A logical specifying whether each group has different shapes of data points. Also can be a numeric vector with the same length of unique values in group to manually set point shapes.

label

A logical specifying whether score labels are shown instead of points.

label_size

A numeric value controlling the size of labels.

label_subset

A character vector specifying a subset of score labels to display.

ellipse

A logical specifying whether data ellipses are shown.

xlab

A string specifying the title of x-axis.

ylab

A string specifying the title of y-axis.

title

A string specifying the main title of the plot.

legend

A logical specifying whether the plot legend is shown.

arrow_len

A numeric value specifying the length of arrow head.

arrow_col

A string specifying the color of arrows.

arrow_alpha

A numeric value specifying the transparency of arrow.

arrow_label

A logical specifying whether text labels for arrows are shown.

arrow_label_ext

A numeric value specifying the scalar extension for arrow labels.

arrow_label_size

A numeric value specifying the size of arrow labels.

arrow_label_col

A string specifying the color of arrow labels.

arrow_label_subset

A character vector specifying a subset of arrow labels to display.

Value

A ggplot object.

Examples


data(faahko_se)

## Sample group
g <- colData(faahko_se)$sample_group

## PCA
pca_res <- reduceFeatures(faahko_se, i = "knn_vsn", method = "pca")

## Visualizes the result
plotReduced(pca_res, group = g)
plotReduced(pca_res, group = g, label = TRUE, ellipse = TRUE)


HimesGroup/qmtools documentation built on April 16, 2023, 8 p.m.