plot_kmeans: Plotting the clusters returned by K-means clustering

View source: R/plot_kmeans.R

plot_kmeansR Documentation

Plotting the clusters returned by K-means clustering

Description

This function is designed to plot the clusters returned by K-means clustering.

Usage

plot_kmeans(
  data,
  res,
  query,
  dimred = "TSNE",
  title = "Kmeans Clustering Results"
)

Arguments

data

A numeric data.frame scaled with scale.

res

The clustering results returned by kmeans.

query

A rowname in data. The cluster containing this rowname will be labeled.

dimred

The dimension reduction method, one of 'PCA', 'UMAP', or 'TSNE'.

title

The plot title.

Value

A ggplot.

Author(s)

Jianhai Zhang jzhan067@ucr.edu
Dr. Thomas Girke thomas.girke@ucr.edu

References

Melville J (2022). _uwot: The Uniform Manifold Approximation and Projection (UMAP) Method for Dimensionality Reduction_. R package version 0.1.14, <https://CRAN.R-project.org/package=uwot> Jesse H. Krijthe (2015). Rtsne: T-Distributed Stochastic Neighbor Embedding using a Barnes-Hut Implementation, URL: https://github.com/jkrijthe/Rtsne H. Wickham. ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York, 2016.

Examples

set.seed(10)
data <- iris[, 1:4]
rownames(data) <- paste0('gene', seq_len(nrow(data)))
dat.scl <- scale(data)
clus <- kmeans(dat.scl, 6)
plot_kmeans(data=dat.scl, res=clus, query='gene1', dimred='TSNE') 

jianhaizhang/spatialHeatmap documentation built on April 21, 2024, 7:43 a.m.