Learn R Programming

specmine (version 4.0.0)

tsne_scoresplot2D: t-SNE 2D scores plot

Description

Creates a two-dimensional scores plot from a t-SNE result.

Usage

tsne_scoresplot2D(
  dataset,
  tsne.result,
  column.class = NULL,
  dims = c(1, 2),
  labels = FALSE,
  ellipses = FALSE,
  bw = FALSE,
  pallette = 2,
  leg.pos = "right",
  xlim = NULL,
  ylim = NULL
)

Value

A ggplot object.

Arguments

dataset

Dataset used to calculate the embedding.

tsne.result

Result returned by tsne_analysis_dataset().

column.class

Optional metadata column used to colour or group samples.

dims

Two embedding dimensions to plot.

labels

Logical indicating whether sample labels should be displayed.

ellipses

Logical indicating whether group ellipses should be displayed.

bw

Logical indicating whether a black-and-white plot should be used.

pallette

RColorBrewer palette number.

leg.pos

Legend position.

xlim

Optional x-axis limits.

ylim

Optional y-axis limits.

Examples

Run this code
if (requireNamespace("Rtsne", 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,
    perplexity = 2,
    max_iter = 250,
    seed = 42
  )

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

Run the code above in your browser using DataLab