pca_plot | R Documentation |
The function allows the passing of some parameters to Rtsne/umap:
Rtsne: perplexity
umap: nn (number of neighbors)
pca_plot(
X,
grp,
txt = FALSE,
method = c("pca", "tsne", "umap"),
dims = 2,
gg = TRUE,
ellipse = FALSE,
legend,
repel = FALSE,
plot = TRUE,
...
)
X |
A numeric matrix |
grp |
Optional grouping factor to color instances by |
txt |
Use rownames as labels instead of dots (default: false) |
method |
How to carry out dimension reduction (pca/tsne/umap) |
dims |
Dimensions to return (for tsne) |
gg |
Use ggplot2? (default: true) |
ellipse |
Draw mvn-ellipses around groups? (default: false, only available for ggplot) |
legend |
Include a legend (default: true) |
repel |
If |
plot |
Create plot? (default: true) |
... |
Further arguments to |
If base plot, returns PCA object invisibly. If ggplot, returns the plot object.
# Plots of the iris data
pca_plot(iris[,1:4])
pca_plot(iris[,1:4], grp=iris[,5])
pca_plot(iris[,1:4], grp=iris[,5], ellipse=TRUE)
pca_plot(iris[,1:4], grp=iris[,5], method='tsne')
pca_plot(iris[,1:4], grp=iris[,5], method='umap')
# What pca_plot returns if plot=FALSE
head(pca_plot(iris[,1:4], method='pca', plot=FALSE))
head(pca_plot(iris[,1:4], method='tsne', dims=3, plot=FALSE))
head(pca_plot(iris[,1:4], method='umap', dims=3, plot=FALSE))
# Plots of the USArrests data
pca_plot(USArrests, txt=TRUE)
pca_plot(USArrests, txt=TRUE, repel=TRUE)
pca_plot(USArrests, txt=TRUE, grp=rep(LETTERS[1:5], each=10))
pca_plot(USArrests, txt=TRUE, method='tsne', perplexity=10)
pca_plot(USArrests, txt=TRUE, method='umap', nn=6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.