Skip to contents

Cluster the right singular vectors from model output

Usage

smooth_clust(v, n_clust)

Arguments

v

matrix; right singular vectors

n_clust

integer; number of clusters.

Value

vector of cluster labels

Examples


sce <- example_sce()
x <- SummarizedExperiment::assay(sce)
coords <- SummarizedExperiment::colData(sce)[, c("col", "row")]
k <- 10
init <- smooth_init(x, coords, k)
lambda <- 1
epsilon <- 1e-3
maxiter <- 5
model <- smooth_model(x, init$u0, init$v0, init$w, init$index, lambda, epsilon, maxiter)
#> iteration: 1 | convergence: 0.0969485 | 0.0366424 | 1
#> iteration: 2 | convergence: 0.0722831 | 0.0306596 | 0.00487695
#> iteration: 3 | convergence: 0.0674146 | 0.0341226 | 0.00487633
#> iteration: 4 | convergence: 0.0668668 | 0.0367569 | 0.00506556
#> iteration: 5 | convergence: 0.0699224 | 0.0378656 | 0.00549529
n_clust <- 3
smooth_clust(model$v, n_clust)
#> fitting ...
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |======================================================================| 100%
#>   [1] 1 1 1 1 1 1 2 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 3 1 1 2 1 1 2
#>  [38] 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 2 1 1 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1
#>  [75] 2 2 1 2 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1