Skip to contents

Train a reference SOM and build a somalign reference

Usage

somalign_train_reference(
  data,
  labels = NULL,
  features = NULL,
  grid = NULL,
  rlen = 100,
  alpha = c(0.05, 0.01),
  compute_node_var = TRUE,
  ...
)

Arguments

data

Numeric matrix or data frame containing old/reference samples.

labels

Optional labels, one per row of data.

features

Optional feature names to use. Defaults to all columns.

grid

Optional kohonen::somgrid() object.

rlen

Number of SOM training iterations passed to kohonen::som().

alpha

Learning-rate schedule passed to kohonen::som().

compute_node_var

Logical; if TRUE (default) per-node per-marker variances are computed from the reference cells assigned to each node and stored as reference$node_var. Set FALSE to skip (reduces memory by one n_nodes x p matrix; disables surprisal-based outside-reference detection in somalign_results()).

...

Additional arguments passed to kohonen::som().

Value

A somalign_reference object.

Examples

set.seed(1)
mat <- matrix(rnorm(20), nrow = 10, ncol = 2,
              dimnames = list(NULL, c("F1", "F2")))
labels <- rep(c("A", "B"), each = 5)
ref <- somalign_train_reference(mat, labels = labels,
                                grid = kohonen::somgrid(2, 2, "hexagonal"),
                                rlen = 5)