Trains a Self-Organizing Map on the input data using
kohonen::som() and returns the mapping-unit (node) assignment
for every observation as a cluster label.
Arguments
- data
matrix or data.frame. Rows are observations, columns are variables.
- vars
character vector or
NULL. Column names to use for clustering. IfNULL(default), all columns are used.- x_dim
integer(1). Number of columns in the SOM grid. Default
10L(matching FlowSOM).- y_dim
integer(1). Number of rows in the SOM grid. Default
10L(matching FlowSOM).- rlen
integer(1). Number of training iterations. Default
10L(matching FlowSOM).- topo
character(1). Grid topology passed to
kohonen::somgrid(). One of"rectangular"(default) or"hexagonal".
Value
A character vector of cluster labels, one per row of data.
Labels are of the form "1", "2", etc., corresponding to
SOM grid nodes.
Details
The function:
Scales the selected columns to zero mean and unit variance.
Creates a SOM grid of size
x_dim×y_dim.Trains a SOM on the scaled data.
Returns the unit assignment for each observation.
The default grid size (10 × 10) and training length (rlen = 10)
match the defaults used by FlowSOM's BuildSOM.
The kohonen package must be installed.