Plot samples in a two-dimensional embedding, coloured by group. The
embedding can be supplied already computed, or computed here from a feature
matrix with stats::prcomp(), Rtsne, or umap.
Usage
plot_embedding(
data,
groups,
method = c("pca", "tsne", "umap", "none"),
perplexity = 30,
seed = NULL,
ellipse = FALSE,
label_centres = FALSE,
palette = "house",
title = NULL,
xlab = NULL,
ylab = NULL,
font = "Arial"
)Arguments
- data
A feature matrix with samples in rows, or a two-column matrix of coordinates when
method = "none".- groups
Group labels, one per sample.
- method
Embedding to compute:
"pca","tsne","umap", or"none"whendataalready holds coordinates.- perplexity
Perplexity for t-SNE. Values much larger than the number of samples are rejected by the back end.
- seed
Optional seed for the stochastic embeddings.
- ellipse
Draw a confidence ellipse per group.
- label_centres
Label each group at the centre of its points.
- palette
Palette name passed to
get_color().- title, xlab, ylab
Axis and plot labels.
- font
Font family used in the plot.
Details
plot_PCA() and plot_UMAP() are thin wrappers around this function, so a
figure keeps the same look whichever embedding it shows.