clusterInertia: Calculation of within-cluster inertia

Description Usage Arguments Value Author(s) Examples

View source: R/general-functions.R

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

1

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## 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))

andreamrau/coseq documentation built on July 25, 2021, 10:17 a.m.