clusterInertia {coseq} | R Documentation

## Calculation of within-cluster inertia

### Description

Provides the calculation of within-cluster inertia, equivalent to

Inertia(k) = ∑_{i \in C_k} (y_{ik} - μ_k)^2

where μ_k is the mean of cluster k and C_k corresponds to the set of indices of genes attributed to cluster k.

### Usage

    clusterInertia(profiles, clusters)

### Arguments

`profiles` | Matrix, data.frame, or DataFrame containing the (transformed) profiles used for the clustering
`clusters` | Vector of cluster labels corresponding to the observations in `profiles`

### Value

Within cluster inertia

### Author(s)

Andrea Rau, Antoine Godichon-Baggioni

### Examples

    ## Simulate toy data, n = 300 observations
    set.seed(12345)
    countmat <- matrix(runif(300*4, min=0, max=500), nrow=300, ncol=4)
    countmat <- countmat[which(rowSums(countmat) > 0),]
    conds <- rep(c("A","B","C","D"), each=2)

    ## Run the K-means algorithm for logclr profiles for K = 2,..., 20
    run_kmeans <- coseq(object=countmat, K=2:20, transformation="logclr",
    model="kmeans")
    clusterInertia(profiles=tcounts(run_kmeans), clusters=clusters(run_kmeans))

[Package coseq version 1.16.0 Index]