Skip to contents

Projects the samples of an exposure matrix to 2-D (UMAP via uwot, or a deterministic kmeans-cluster annotation) and returns the tidy embedding with the cluster assignment. With the compositional share transform (default) the geometry lives on the simplex embedding the signatures induce.

Usage

ms_embed(
  exposures,
  method = c("umap", "kmeans"),
  transform = c("share", "none"),
  seed = 1,
  clusters = 3L
)

Arguments

exposures

k x n exposure matrix (rows = signatures, columns = samples), or an [MsSignature].

method

"umap" (uwot; Suggests) or "kmeans" (stats, always available).

transform

"share" (columns to 1 — default) or "none".

seed

Single seed: UMAP's set.seed / kmeans's centers-first row. kmeans is bitwise deterministic for a given input regardless.

clusters

kmeans clusters (default 3); ignored by UMAP.

Value

A data.frame: sample, embed_1, embed_2 (UMAP coordinates, or for kmeans the sample's loadings on the first two signature axes — a deterministic projection, not an embedding), cluster.