Learn R Programming

specmine (version 4.0.0)

umap_analysis_dataset: UMAP analysis

Description

Performs Uniform Manifold Approximation and Projection (UMAP) dimensionality reduction on a specmine dataset.

Usage

umap_analysis_dataset(
  dataset,
  n_components = 2,
  n_neighbors = 15,
  min_dist = 0.1,
  metric = "euclidean",
  scale = FALSE,
  ret_model = FALSE,
  seed = 42,
  write.file = FALSE,
  file.out = NULL,
  ...
)

Value

A list containing the UMAP embedding and the analysis parameters. When ret_model = TRUE, the fitted UMAP model is also returned.

Arguments

dataset

Dataset to analyse.

n_components

Number of dimensions in the embedding.

n_neighbors

Number of nearest neighbours.

min_dist

Minimum distance between points in the embedding.

metric

Distance metric passed to uwot::umap().

scale

Logical indicating whether the data should be scaled.

ret_model

Logical indicating whether the UMAP model should be returned.

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 uwot::umap().

Examples

Run this code
# \donttest{
if (requireNamespace("uwot", 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)))
  )
  result <- umap_analysis_dataset(
    dataset,
    n_components = 2,
    n_neighbors = 3,
    seed = 42
  )
}
# }

Run the code above in your browser using DataLab