← Back to all sparks
T

tglkmeans

ANALYTICS
Velocity0.0

R package tglkmeans by tanaylab — release notes from GitHub.

A k-means implementation that just told users their Spearman clustering on missing data was wrong

r-packageclusteringmissing-datacorrectnesssingle-cell
Current state
tglkmeans is a multi-core k-means implementation with seeding, aimed at single-cell and other large matrix workloads. Version 0.4.0 flipped the id_column default and moved to R's random number generator, 0.5.x added count-matrix downsampling and fixed id handling, and 0.6.3 in May 2026 is a correctness release: Spearman distance was ranking missing values as the largest value instead of dropping them, and predict_tgl_kmeans() with Euclidean distance did not reproduce the training metric when a cluster center had a missing dimension.
Where it's heading
The package handles missing data across three distance metrics, and 0.6.3 shows those paths had drifted apart — Spearman behaved unlike Euclidean and Pearson, and prediction behaved unlike training. Both fixes change results on affected data, and the release notes are careful to bound exactly where: Spearman on data with NAs changes, complete data does not. Performance work runs alongside, with the dense per-thread vote matrix removed from the reassignment step.
Prediction
With the metric paths now aligned on missing-value handling, further work is more likely to target the parallel reassignment internals than the distance semantics.

Recent moves

  1. 2mo ago

    Spearman metric no longer ranks missing values as the largest

    Fixes Spearman distance testing the wrong missing-value sentinel, so NAs were ranked as the maximum and folded into the rank correlation, and aligns predict_tgl_kmeans() with the training distance when centers have missing dimensions. Both change clustering results on affected data, and the notes bound the impact precisely — an unusually candid correctness release.

    View source ↗
  2. 2y ago

    Fixes corrupted cluster ids and dropped dimnames

    Rolls up four patch releases covering corrupted cluster slot ids with tibble input, ignored rownames, dropped dimnames in downsample_matrix, and a CRAN core limit. Identity handling on input data is the recurring theme.

    View source ↗
  3. 2y ago

    Adds downsample_matrix() for count matrices

    Adds a function to downsample count matrix columns to a target depth, a standard preprocessing step for single-cell data. The clearest signal of the workloads this package is built around.

    View source ↗
  4. 2y ago

    Breaking: id_column defaults to FALSE, switches to R's RNG

    Flips the id_column default to FALSE as a declared breaking change, moves from the C++11 to R's random number generator with an opt-out for reproducing old results, and adds RcppParallel parallelization. Changing the RNG alters clustering output, and preserving an escape hatch shows the same care that the 0.6.3 correctness notes display.

    View source ↗