flow-clustering
Clustering algorithms for flow cytometry: K-means, DBSCAN, and Gaussian Mixture Models.
Overview
flow-clustering provides:
- Unsupervised clustering algorithms (K-means, DBSCAN, GMM) commonly used in automated gating or analysis
- Clustering quality/validation metrics (Silhouette score).
- (Future) FlowSOM-style self-organizing maps
- (Future) Hierarchical clustering / dendrograms
- (Future) Cluster merging heuristics for automated gating
It uses thin wrappers around linfa clustering with shared result types (labels, centroids/means, optional noise for DBSCAN).
Installation
Or add directly to your Cargo.toml:
[]
= "0.1.2"
| Feature | Description |
|---|---|
kmeans (default) |
K-means clustering |
dbscan (default) |
Density-based spatial clustering (DBSCAN) |
gmm (default) |
Gaussian Mixture Model fitting |
Usage
K-Means
Lloyd's algorithm via linfa-clustering. Supports row-major ndarray::Array2 input and fit_from_rows for pre-separated channel vectors.
use ;
use Array2;
DBSCAN
Density-based clustering that identifies noise points. Useful for scatter gating where populations have irregular shapes. Expectation-maximization for Gaussian mixtures. Models multi-modal populations common in fluorescence channels.
use ;
use Array2;
Gaussian mixture model
use ;
use Array2;
Cluster Validation
Silhouette scores are a quality metric (−1 to +1) of clustering. Full O(n²) and sampled O(n·k) variants available.
use ;
use Array2;
Tests
4 unit tests covering silhouette score correctness for well-separated and overlapping clusters.
License
MIT
Related crates
- KDE / Contour Detection →
flow-density— density primitives used alongside clustering in gating - Gate Geometry and GatingML →
flow-gates- Consumes this crate inautomatedfeature - Dimensionality Reduction →
flow-pacmap flow-fcs- Reading and parsing flow cytometry standard (FCS) filestru-olsCLI — may use clustering in control / QC workflows