flow-density
FFT-accelerated kernel density estimation for flow cytometry.
Overview
flow-density provides 1D and 2D kernel density estimation (KDE), peak-finding (mode), or contour extraction optimized for the event counts typical in flow cytometry (10K–10M events).
The FFT-based KDE algorithm avoids the O(n²) cost of naive KDE, making real-time density plots feasible even for large files.
Features
| Feature | Description |
|---|---|
kde (default) |
1D and 2D kernel density estimation |
gpu |
WebGPU-accelerated KDE via burn + cubecl (experimental) |
- 1D KDE: Gaussian kernel with Silverman bandwidth selection, evaluated via FFT convolution (
realfft). Supports bandwidth adjustment factor and configurable grid resolution. - 2D KDE: Separable Gaussian kernel on a regular grid, FFT-accelerated along each axis. Contour extraction via threshold-based boundary tracing.
- Peak finding: Local maxima detection with configurable minimum prominence (peak removal fraction).
- Contour extraction from 2D density fields
- (Future) Adaptive bandwidth KDE
Related crates
- Rendered density/scatter plots →
flow-plots(pixel occupancy ≠ FFT KDE) - Gates
flow-gates,flow-plots— Uses FFT KDE for peak detection - QC
peacoqc-rs- Uses FFT KDE for density-based gating - Clustering
flow-clustering— clustering, not density estimation - Single-stain peak isolation for unmixing →
flow-peak-detection
Installation
Or add it directly to your Cargo.toml:
[]
= "0.1.2"
API Usage
1D Density Estimation
use ;
2D Density Estimation
use ;
Performance
FFT KDE targets 10K–10M events where naive O(n²) KDE is impractical.
Testing
License
MIT