Learn R Programming

specmine (version 4.0.0)

tsne_scoresplot3D: t-SNE 3D scores plot

Description

Creates an interactive three-dimensional scores plot from a t-SNE result.

Usage

tsne_scoresplot3D(
  dataset,
  tsne.result,
  column.class = NULL,
  dims = c(1, 2, 3),
  title = "t-SNE 3D Scores Plot"
)

Value

A plotly htmlwidget.

Arguments

dataset

Dataset used to calculate the embedding.

tsne.result

Result returned by tsne_analysis_dataset().

column.class

Optional metadata column used to colour samples.

dims

Three embedding dimensions to plot.

title

Plot title.

Examples

Run this code
if (requireNamespace("Rtsne", quietly = TRUE) &&
    requireNamespace("plotly", quietly = TRUE)) {
  datamat <- matrix(
    rnorm(40),
    nrow = 5,
    dimnames = list(
      paste0("x", 1:5),
      paste0("s", 1:8)
    )
  )

  dataset <- list(
    data = datamat,
    metadata = data.frame(
      class = factor(rep(c("A", "B"), length.out = 8))
    )
  )

  tsne.result <- tsne_analysis_dataset(
    dataset,
    n_components = 3,
    perplexity = 2,
    max_iter = 250,
    seed = 42
  )

  tsne_scoresplot3D(
    dataset,
    tsne.result,
    column.class = "class"
  )
}

Run the code above in your browser using DataLab