plot_cluster: Visualize clustering results

View source: R/kmeans.R

plot_clusterR Documentation

Visualize clustering results

Description

The clustering results can be visualized on a UMAP panel. Three different types of plots can be generated using this function: cluster-by-signature plot, cluster-by-annotation plot, and a single UMAP plot.

Usage

plot_cluster(
  musica,
  model_name,
  modality = "SBS96",
  result_name = "result",
  clusters,
  group = "signature",
  annotation = NULL,
  plotly = TRUE
)

Arguments

musica

A musica object containing a mutational discovery or prediction. A two-dimensional UMAP has to be stored in this object.

model_name

The name of the desired model.

modality

The modality of the model. Must be "SBS96", "DBS78", or "IND83". Default "SBS96".

result_name

Name of the result list entry containing desired model. Default "result".

clusters

The result generated from cluster_exposure function.

group

A single character string indicating the grouping factor. Possible options are: "signature" (columns are signatures in a grid), "annotation" (columns are sample annotation), and "none" (a single UMAP plot). Default is "signature".

annotation

Column name of annotation.

plotly

If TRUE, the plot will be made interactive using plotly.

Value

Generate a ggplot or plotly object.

See Also

create_umap

Examples

set.seed(123)
data(res_annot)
# Get clustering result
clust_out <- cluster_exposure(
  musica = res_annot, model_name = "res_annot",
  nclust = 2, iter.max = 15
)
# UMAP
create_umap(musica = res_annot, model_name = "res_annot")
# generate cluster X signature plot
plot_cluster(
  musica = res_annot, model_name = "res_annot",
  clusters = clust_out, group = "signature"
)
# generate cluster X annotation plot
plot_cluster(
  musica = res_annot, model_name = "res_annot",
  clusters = clust_out, group = "annotation",
  annotation = "Tumor_Subtypes"
)
# generate a single UMAP plot
plot_cluster(
  musica = res_annot, model_name = "res_annot",
  clusters = clust_out, group = "none"
)

campbio/musicatk documentation built on Dec. 25, 2024, 9:34 p.m.