datanuggets-flow

datanuggets-flow

Explore flow cytometry populations across multiple FCS files with data nuggets.

The plot view of the datanuggets-flow app, with a t-SNE of data nuggets colored by cluster
The app's plot view shows a t-SNE of the data nuggets from four public PBMC demonstration files. Each point is sized by its nugget weight and colored by its cluster.

What it does

A flow cytometry experiment can produce millions of events across dozens of samples. Analyzing each file separately makes it hard to compare clusters across samples. Analyzing everything together can become expensive, especially when a method needs pairwise distances.

datanuggets-flow takes a middle route. It helps you select candidate populations in each file using forward and side scatter, reduces the selected events to weighted data nuggets and clusters the pooled nuggets in one analysis. The cluster labels are shared across the files in a run, so you can examine how their relative abundance and marker profiles differ between samples.

The package builds on datanuggets, a Python port of the R packages datanugget and WCluster. It offers a local web app, a command-line interface and a Python API.

Research alpha (0.1.0a6). This is an exploratory analysis tool. It isn't an automated cell-type identification system or a validated clinical analysis system. Its clusters are mathematical groupings, and they aren't confirmed biological populations. The API and analysis defaults may change.

Get the app

The app runs on your own computer in Docker. The image is published for linux/amd64 and linux/arm64.

  1. Install Docker and start it. That's Docker Desktop on Windows and macOS.

  2. Run this in a terminal:

    docker run --rm -p 127.0.0.1:8000:8000 -v datanuggets-data:/data ghcr.io/ron2k1/datanuggets-flow:0.1.0a6
  3. Open http://127.0.0.1:8000 in your browser.

The app lets you inspect candidate gates, choose which populations to include, run the clustering and explore the results with interactive plots. Ctrl+C stops it, and the next docker run with the same -v datanuggets-data:/data finds your uploads and runs where you left them.

The address is bound to your own computer rather than your local network. The named Docker volume keeps uploads and completed runs between containers. The analysis runs on your computer. Downloading the container image itself requires a network connection. Check your environment's network and data-handling requirements before you use sensitive files.

The image includes a small public PBMC demonstration dataset of four FCS files, so you can explore the workflow before adding your own. The app guide covers the app's settings and building the image from source.

What the app shows

The population step of the app, with each file's scatter density and tick boxes for its candidate populations
The population step shows each file's scatter density, FSC-A and SSC-A here, with the peaks the gate finder kept. You tick the populations to carry into the clustering.
The cluster step of the app, with the cluster count, the nuggets per file and a tick box for every channel
The cluster step is where you set the number of clusters and how many nuggets each file keeps. You can also change the transform and the clustering method, and tick the marker channels to cluster on.
A 3D t-SNE of the nuggets in the app's dark theme, colored by cluster
This is the demonstration run as a 3D t-SNE, shown in the app's dark theme. You can rotate and pan the plot.
A 3D scatter plot of the nuggets on CD3, CD19 and CD14 axes, colored by cluster
Marker axes put measured channels on the plot. This view has CD3, CD19 and CD14, and each axis has a menu for choosing another channel.
The box plot view, with one cluster's marker levels beside the rest of the run and its cell counts per file
The box plot view compares a cluster's marker levels with the rest of the run. It also shows how many of the cluster's cells come from each file.
The compare view, with each cluster's share of every sample as a heatmap, a stacked bar chart and a table
The compare view shows each cluster's share of every sample as a heatmap, a stacked bar chart and a table. Each share is a percentage of the events retained in that file.

The app gives you several ways to inspect a finished run:

Pooled clustering gives every file the same labels. It doesn't prove that a label denotes the same cell type in every file. The README lists the checks to make before interpreting a cluster.

Use it from Python

The package requires Python 3.12 or newer and a platform that the underlying datanuggets package supports. Those are Windows x64, Apple silicon Macs running macOS 12 or newer, and Linux x86-64 or ARM64 with glibc 2.27 or newer. Install the pinned alpha:

python -m pip install "datanuggets-flow==0.1.0a6"

Run the command-line workflow

datanuggets-flow path/to/fcs_folder

The command finds candidate scatter populations in each FCS file, shows the gating figure and asks which populations to keep. It then runs a joint clustering analysis and writes the figures, tables and settings to a new output directory.

Run it from Python

The Python API exposes the same two stages. The first creates and saves the candidate gates. The second analyzes the populations you select. The README has a complete example.

The datanuggets library

The nugget and weighted k-means implementations come from datanuggets, which is its own package. Data nuggets bring a large dataset down to a size you can explore with weighted clustering and PCA.

python -m pip install "datanuggets[frame,plot]==0.1.0a3"

Documentation

Papers and acknowledgments

Core method

Beavers, T. E., Cheng, G., Duan, Y., Cabrera, J., Lubomirski, M., Amaratunga, D., and Teigler, J. E. (2025). Data Nuggets: A Method for Reducing Big Data While Preserving Data Structure. Journal of Computational and Graphical Statistics, 34(1), 330-342. Published online in 2024. doi:10.1080/10618600.2024.2341896.

Related research

The data nugget reduction and weighted clustering methods belong to their original researchers and the maintainers of the R datanugget and WCluster packages. datanuggets-flow builds on the datanuggets Python port. The scatter gate finder adapts Python code supplied by Prof. Javier Cabrera. The third-party notices record the permissions and the upstream licenses.

The demonstration files in the app and the recorded test data come from Stefanie Kreutmair and Susanne Unger (2026), Flow cytometry data of PBMC of critically ill, mechanically ventilated patients (V1), Zenodo, doi:10.5281/zenodo.22079206.