Build a reference object from an existing SOM and old data
Source:R/reference.R
somalign_reference.RdBuild a reference object from an existing SOM and old data
Usage
somalign_reference(
som_ref,
data,
labels = NULL,
features = NULL,
center = NULL,
scale = NULL,
codebook_space = NULL,
quantile_probs = c(0.5, 0.9, 0.95, 0.99),
compute_node_var = TRUE
)Arguments
- som_ref
A
kohonenSOM object, or a SOM-like object containing a codebook matrix.- data
Numeric old/reference data used to compute scaling, masses, labels, and distance thresholds.
- labels
Optional labels, one per row of
data.- features
Optional feature names to use. Defaults to all columns.
- center
Optional saved feature centers. Computed from
datawhen omitted.- scale
Optional saved feature scales. Computed from
datawhen omitted.- codebook_space
Coordinate system of the existing
som_refcodebook. Use"reference_scaled"when the SOM was trained ondatatransformed withcenterandscale; use"raw"when the SOM was trained on raw feature values and should be transformed into reference-scaled space.- quantile_probs
Distance quantiles used for outside-reference flags.
- compute_node_var
Logical; if
TRUE(default) per-node per-marker variances are computed fromdataand stored asreference$node_var. Seesomalign_train_reference().
Examples
set.seed(1)
mat <- matrix(rnorm(20), nrow = 10, ncol = 2,
dimnames = list(NULL, c("F1", "F2")))
g <- kohonen::somgrid(2, 2, "hexagonal")
som_obj <- kohonen::som(scale(mat), grid = g, rlen = 5)
ref <- somalign_reference(som_obj, mat, labels = rep(c("A", "B"), each = 5),
codebook_space = "reference_scaled")