clusteringKmeans {seqsetvis} | R Documentation

## perform kmeans clustering on matrix rows and return reordered matrix along with order matched cluster assignments. clusters are sorted using hclust on centers

### Description

perform kmeans clustering on matrix rows and return reordered matrix along with order matched cluster assignments. clusters are sorted using hclust on centers

### Usage

    clusteringKmeans(mat, nclust, seed = NULL)

### Arguments

`mat` | numeric matrix to cluster
`nclust` | the number of clusters
`seed` | DEPRECATED. Call set.seed() prior to this funciton to allow reproducibility.

### Value

data.table with group variable indicating cluster membership and id variable that is a factor indicating order based on within cluster similarity

### Examples

    dt = data.table::copy(CTCF_in_10a_profiles_dt)
    mat = data.table::dcast(dt, id ~ sample + x, value.var = "y" )
    rn = mat$id
    mat = as.matrix(mat[,-1])
    rownames(mat) = rn
    clust_dt = clusteringKmeans(mat, nclust = 3)
    dt = merge(dt, clust_dt)
    dt$id = factor(dt$id, levels = clust_dt$id)
    dt[order(id)]

[Package seqsetvis version 1.7.5 Index]