Learn R Programming

specmine (version 4.0.0)

tsne_analysis_dataset: t-SNE analysis

Description

Performs t-distributed Stochastic Neighbor Embedding (t-SNE) dimensionality reduction on a specmine dataset.

Usage

tsne_analysis_dataset(
  dataset,
  n_components = 2,
  perplexity = 30,
  max_iter = 1000,
  theta = 0.5,
  eta = "auto",
  scale = FALSE,
  seed = 42,
  write.file = FALSE,
  file.out = NULL,
  ...
)

Value

A list containing the t-SNE embedding and the analysis parameters.

Arguments

dataset

Dataset to analyse.

n_components

Number of dimensions in the embedding.

perplexity

Perplexity parameter controlling the balance between local and global structure. It must be sufficiently small relative to the number of samples.

max_iter

Maximum number of optimization iterations.

theta

Speed-accuracy trade-off parameter. A value of zero performs exact t-SNE, whereas larger values are faster but approximate.

eta

Learning rate. The default value "auto" is converted to a numeric value based on the number of samples.

scale

Logical indicating whether the data should be scaled before t-SNE.

seed

Random seed used for reproducibility.

write.file

Logical indicating whether the embedding should be written to a CSV file.

file.out

Output file prefix used when write.file = TRUE.

...

Additional arguments passed to Rtsne::Rtsne().

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,
    n_components = 2,
    perplexity = 2,
    max_iter = 250,
    seed = 42
  )
}

Run the code above in your browser using DataLab