Learn R Programming

jackstraw (version 1.3.17)

jackstraw_kmeanspp: Non-Parametric Jackstraw for K-means Clustering using RcppArmadillo

Description

Test the cluster membership for K-means clustering, using K-means++ initialization

Usage

jackstraw_kmeanspp(
  dat,
  kmeans.dat,
  s = NULL,
  B = NULL,
  center = TRUE,
  covariate = NULL,
  verbose = FALSE,
  pool = TRUE,
  ...
)

Value

jackstraw_kmeanspp returns a list consisting of

F.obs

m observed F statistics between variables and cluster centers.

F.null

F null statistics between null variables and cluster centers, from the jackstraw method.

p.F

m p-values of membership.

Arguments

dat

a matrix with m rows as variables and n columns as observations.

kmeans.dat

an output from applying ClusterR::KMeans_rcpp onto dat.

s

a number of ``synthetic'' null variables. Out of m variables, s variables are independently permuted.

B

a number of resampling iterations.

center

a logical specifying to center the rows. By default, TRUE.

covariate

a model matrix of covariates with n observations. Must include an intercept in the first column.

verbose

a logical specifying to print the computational progress. By default, FALSE.

pool

a logical specifying to pool the null statistics across all clusters. By default, TRUE.

...

optional arguments to control the k-means clustering algorithm (refers to ClusterR::KMeans_rcpp).

Author

Neo Christopher Chung nchchung@gmail.com

Details

K-means clustering assign m rows into K clusters. This function enable statistical evaluation if the cluster membership is correctly assigned. Each of m p-values refers to the statistical test of that row with regard to its assigned cluster. Its resampling strategy accounts for the over-fitting characteristics due to direct computation of clusters from the observed data and protects against an anti-conservative bias.

Generally, it functions identical to jackstraw_kmeans, but this uses ClusterR::KMeans_rcpp instead of stats::kmeans. A speed improvement is gained by K-means++ initialization and RcppArmadillo. If the input data is still too large, consider using jackstraw_MiniBatchKmeans.

The input data (dat) must be of a class `matrix`.

References

Chung (2020) Statistical significance of cluster membership for unsupervised evaluation of cell identities. Bioinformatics, 36(10): 3107–3114 tools:::Rd_expr_doi("10.1093/bioinformatics/btaa087")

Examples

Run this code
if (FALSE) {
library(ClusterR)
dat = t(scale(t(Jurkat293T), center=TRUE, scale=FALSE))
kmeans.dat <- KMeans_rcpp(dat,  clusters = 10, num_init = 1,
max_iters = 100, initializer = 'kmeans++')
jackstraw.out <- jackstraw_kmeanspp(dat, kmeans.dat)
}

Run the code above in your browser using DataLab