Flowkit
K-DenseCommunityCreated by K-Dense Inc.
- Skill
- Tool integration
- Science and research
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
FlowKit is a Python-based tool for processing and analyzing flow cytometry data. It enables users to perform spillover compensation, apply logicle and biexponential transforms, and execute hierarchical gating strategies. The tool supports GatingML 2.0 and provides compatibility with a subset of FlowJo 10 workspaces, allowing for reproducible analysis of FCS files. It is designed for researchers needing to automate gating, generate population statistics, or validate cytometry results programmatically.
What it does
- Applies spillover compensation to flow cytometry data.
- Executes hierarchical gating strategies using GatingML or FlowJo workspaces.
- Performs logicle and biexponential data transformations.
- Generates reproducible gate counts and population percentage reports.
- Exports analysis results including provenance and population paths.
- Provides a Python API for building custom gating strategies.
When to use it
- When you need to reproduce FlowJo 10 workspace analyses in a Python environment.
- When automating the gating of large batches of FCS files.
- When you require programmatic control over cytometry data processing and compensation.
- When generating standardized reports for scientific studies.
Advantages
- Enables reproducible, scriptable cytometry analysis.
- Supports standard GatingML 2.0 formats for interoperability.
- Provides detailed provenance and reporting for scientific audit trails.
- Allows for custom, complex gating logic beyond standard GUI tools.
Usage examples
- “Analyze a FlowJo workspace study using FlowKit.”
- The tool processes the specified FCS files against the workspace definitions, outputting a gate_report.csv and provenance.json with population statistics.
- “Build a custom gating strategy in Python for FCS data.”
- A GatingStrategy object is created, compensation matrices and transforms are registered, and gates are applied to generate a report and exportable GatingML file.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/k-dense-ai/flowkit/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip flowkit.zip -d .agents/skills
Documentation by K-Dense Inc.
FlowKit
When to use
Use FlowKit to apply or build cytometry gating strategies, analyze batches of FCS samples, or reproduce supported FlowJo workspace analyses. It supports GatingML 2.0 and a subset of FlowJo 10 features. Import success alone does not establish agreement with FlowJo.
The examples and bundled helper target FlowKit 1.3.2 on Python 3.13. Upstream supports additional Python versions; those were not exercised here. The helper and examples were tested on synthetic FCS data, including a public FlowJo 10.7.1 synthetic workspace fixture. They are not biological validation.
Install
Use a separate environment; FlowKit 1.3.2 requires NumPy >2 and pandas <3:
uv venv --python 3.13 .venv-flowkit
uv pip install --python .venv-flowkit/bin/python "flowkit==1.3.2"
.venv-flowkit/bin/python -c "import flowkit; print(flowkit.__version__)"The scientific package is BSD-3-Clause licensed; this skill is MIT licensed.
Workflow
Identify the analysis definition. Use
Sessionfor a programmatic or GatingML strategy; useWorkspacefor FlowJo sample-specific gates, compensation, and transforms. Request the actual strategy or controls when biological thresholds have not been supplied.Inspect samples and channel identities. Match detector/PnN labels to compensation matrices and gate dimensions; PnS marker names may be empty or repeated. Verify sample IDs: the default is FCS
$FIL, which can differ from the current filename. Reject ID collisions before loading a batch.Establish the coordinate system. Determine whether the supplied events are already compensated. Apply compensation before nonlinear transforms; match gate thresholds to the same transformed or untransformed coordinates. See compensation and gating.
Check the hierarchy. Preserve parent gates and full gate paths, including
root. For a study, review acquisition/time stability, debris exclusion, singlets, viability, and phenotype gates as appropriate to its panel. Use single-stain controls for compensation and suitable negative/FMO controls for positivity; demonstration thresholds are not transferable biology.Analyze and inspect. Run on all events, then check gate overlays and sample-level QC. A plot's subsample is not the population denominator. Review warnings and compare representative imported results to FlowJo.
Export counts with denominators and provenance. Keep gate paths, sample IDs, total event counts, input hashes, package versions, and the analysis definition. Keep biological replicates identifiable; events from one specimen are not independent experimental replicates.
Apply an existing strategy
Set FLOWKIT_SKILL_DIR to this skill's installed directory. From the repository
root it is skills/flowkit. Paths below represent the user's local inputs.
FLOWKIT_SKILL_DIR="skills/flowkit"
uv run --no-project --python 3.13 --with "flowkit==1.3.2" \
python "$FLOWKIT_SKILL_DIR/scripts/analyze_gates.py" \
--gatingml gates.xml --fcs sample.fcs --output-dir results-gatingmlFor a FlowJo workspace, supply every FCS file in the selected group:
uv run --no-project --python 3.13 --with "flowkit==1.3.2" \
python "$FLOWKIT_SKILL_DIR/scripts/analyze_gates.py" \
--workspace study.wsp --group "Study" \
--fcs sample-a.fcs sample-b.fcs --output-dir results-workspaceThe helper writes gate_report.csv and provenance.json to a new directory.
Each row includes sample_event_count, parent_event_count, and a full
population_path; empty-parent percentages are blank and flagged with
relative_percent_defined=False.
It rejects duplicate sample IDs, missing/extra workspace-group samples,
zero-event samples, and strategies without gates. It uses explicit input files,
does not follow paths embedded in the workspace, and runs without
multiprocessing or transformed-event caching. It still loads each sample into
memory; use manageable batches via the Python API for large studies.
--filename-as-id deliberately switches from $FIL to file basenames. Use it
only when those names match the analysis definition. See
workspace analysis for partial-group
analysis, result interpretation, and fluorescence summaries.
Build a strategy in Python
This runnable example uses sample.fcs with FSC-A, FL1-A, and FL2-A.
The matrix, thresholds, and transform parameters are synthetic teaching
values. Replace them with the study's validated settings.
import flowkit as fk
import numpy as np
sample = fk.Sample("sample.fcs")
strategy = fk.GatingStrategy()
strategy.add_comp_matrix(
"spill", fk.Matrix(
np.array([[1.0, 0.1], [0.2, 1.0]]), ["FL1-A", "FL2-A"],
fluorochromes=["FITC", "PE"],
)
)
logicle = fk.transforms.LogicleTransform(
param_t=262144, param_w=0.5, param_m=4.5, param_a=0
)
strategy.add_transform("logicle", logicle)
strategy.add_gate(
fk.gates.RectangleGate("Cells", [
fk.Dimension("FSC-A", range_min=50, range_max=300)
]),
gate_path=("root",),
)
thresholds = logicle.apply(np.array([50.0, 600.0]))
strategy.add_gate(
fk.gates.RectangleGate("Positive", [
fk.Dimension(
"FL1-A", compensation_ref="spill", transformation_ref="logicle",
range_min=float(thresholds[0]), range_max=float(thresholds[1]),
)
]),
gate_path=("root", "Cells"),
)
session = fk.Session(gating_strategy=strategy, fcs_samples=[sample])
session.analyze_samples(use_mp=False)
report = session.get_analysis_report()
print(report[["sample_id", "gate_path", "gate_name", "count",
"absolute_percent", "relative_percent"]])
with open("gates.xml", "xb") as handle:
session.export_gml(handle)GatingML exports a template by default. When custom per-sample gates exist,
use session.export_gml(handle, sample_id=sample.id) for that sample's strategy.
A single template export does not preserve every sample-specific override.
Interpretation checks
countis the number of events passing the gate and its ancestors.absolute_percentis percent of all sample events;relative_percentis percent of the immediate parent. These are percentages, not fractions.Gate names can repeat under different parents. In the helper's output use
(sample_id, population_path)as the identifier. Paths are JSON arrays inside CSV cells. FlowKit's native report stores a quadrant's owner separately inquadrant_parent; itsgate_pathalone omits that owner.A zero-event parent makes a child percentage biologically undefined; FlowKit 1.3.2 reports zero for ordinary children and NaN for quadrants. The helper exports both as blank with an explicit false flag. This differs from a defined 0% for an empty gate whose parent contains events.
Compensated negative fluorescence is legitimate. Do not clip it to zero or discard those events merely to permit a logarithmic transform.
Define whether “MFI” means mean or median and name the event source. A transformed display value is not an intensity on the original scale.
References
Compensation and gating: event sources, detector order, transform semantics, gate paths, and plotting.
Workspaces and results: sample matching, missing FCS files, FlowJo limits, and gated fluorescence summaries.
FlowKit API and versioned source: consult signatures when moving beyond the tested release.
FlowKit publication: cite the software and version in scientific methods when used for analysis.
Files
- ATTRIBUTION.mdAdded by AutoGineer907 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md8.5 KiB
- references/compensation-and-gating.md4.8 KiB
- references/workspaces-and-results.md6.4 KiB
- scripts/analyze_gates.pyScript8.6 KiB
references/workspaces-and-results.md
Workspaces and result interpretation
Match samples before interpreting results
Use explicit FCS files and inspect the workspace's sample groups. Retaining
missing-file metadata is essential: otherwise missing samples may be removed
from group membership during construction and a partial analysis can look
complete. load_missing_file_data=True retains workspace metadata for missing
FCS files; it does not supply those files' events.
The following example is exercised with the repository's synthetic FlowJo fixture. Replace paths, group name, and sample identity for real work:
import flowkit as fk
workspace = fk.Workspace(
"study.wsp",
fcs_samples=["data_set_simple_line_100.fcs"],
load_missing_file_data=True,
find_fcs_files_from_wsp=False,
)
print(workspace.get_sample_groups())
group = "my_group"
expected = set(workspace.get_sample_ids(group_name=group, loaded_only=False))
loaded = set(workspace.get_sample_ids(group_name=group, loaded_only=True))
if not expected or expected != loaded:
raise ValueError(f"Empty group or missing FCS samples: {sorted(expected - loaded)}")
workspace.analyze_samples(group_name=group, use_mp=False)
print(workspace.get_analysis_report(group_name=group))FCS $FIL, filesystem basename, and workspace sample name can disagree after
renaming/export. Inspect these identities rather than matching by position.
filename_as_id=True is useful only when current basenames match the workspace.
When an explicit, reviewed mapping is necessary, construct
fk.Sample(path, sample_id=workspace_id, use_flowjo_labels=True) objects and
pass those to Workspace. Check uniqueness before building the list.
For an intentionally partial group, use analyze_samples(sample_id=...) for
the explicitly selected IDs and report included and missing IDs. The bundled
CLI deliberately requires the complete named group.
Report paths and denominators
FlowKit 1.3.2 reports individual quadrants with gate_path equal to the
owning QuadrantGate's path and puts that gate's name in quadrant_parent.
For example, quadrant High in Split below Cells has report path
("root", "Cells"), but strategy path ("root", "Cells", "Split").
Its percentage denominator is the Cells count; Split is a collection of
quadrants, not another population. A gate below High uses the full parent
path ("root", "Cells", "Split", "High").
The CLI adds a full population_path, including the population's own name
and any quadrant owner, plus sample_event_count and parent_event_count.
Use sample ID plus that path to join results. An empty parent gives an
undefined percentage even when the child count is zero: the helper writes a
blank relative_percent and relative_percent_defined=False. A zero-count
gate under a nonempty parent retains its valid 0% value.
The 1.3.2 membership API cannot disambiguate a repeated quadrant name across
different owning QuadrantGates, even with a path; it raises ValueError.
Use unique quadrant names when constructing strategies. For imported
strategies, inspect the report and preserve its owner column; do not silently
rename gates or use the wrong population's mask. The CLI's report export does
not call this membership API and retains both populations correctly.
FlowJo compatibility
FlowKit supports a subset of FlowJo 10: documented transformations and polygon, rectangle, ellipse, quadrant, and Boolean gates. Plugins, derived parameters, specialized models, or other unsupported workspace features may not reproduce. Review parser warnings and imported gate inventories. Compare counts, percentages, and overlays against the original FlowJo export on representative samples, including sample-specific overrides and rare gates. Record both software versions and any mismatch; importing without an exception is insufficient.
Prefer the original workspace for reproduction. A single GatingML template
does not encode all custom sample gates. FlowKit's WSP exporter is not a
guaranteed round-trip: in the tested 1.3.2 environment, re-importing a synthetic
compensated Session.export_wsp result failed to resolve a Comp-FL1-A
channel. Native FlowJo fixture import was tested separately. Validate any
conversion independently before relying on it.
Fluorescence summaries
Choose mean or median explicitly, retain sample and gate path, and report the
number of events. For a programmatic Session, obtain the gate mask, then
apply the intended matrix to the Sample and summarize the desired detector
from source="comp". This keeps compensation separate from display transforms.
For a Workspace, get_gate_events(sample_id, gate_name, gate_path=path, source="comp") applies the workspace matrix without display transforms.
If workspace.get_comp_matrix(sample_id) is None, this silently returns
raw events instead; confirm that this is the intended analysis provenance.
Its default source=None uses the workspace's compensation and transforms,
so choose the source explicitly for an untransformed intensity summary.
The returned DataFrame has a string sample_id column and channel columns
formed by joining PnN and PnS labels. Inspect those labels and select the
intended detector before calculating a numeric summary.
There is an API asymmetry: Session.get_gate_events(...) defaults to raw
events unless matrix and/or transform are supplied. It does not
automatically choose the preprocessing of the gate's dimensions. Therefore,
identical-looking calls on Session and Workspace can summarize different
numbers. Do not compare them until their coordinate systems agree.
Empty gates have no defined mean/median; return missing values with count zero. Negative compensated values make geometric means inappropriate without a separately justified method. Across samples, account for panel, instrument, batch, controls, and calibration before interpreting intensity differences.
Primary sources
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Python
The author says: Requires Python 3.13 with flowkit==1.3.2 for the tested environment. Dependencies include FlowIO, FlowUtils, NumPy, pandas, SciPy, lxml, and Bokeh. Installation needs network access; analysis uses local FCS/XML/WSP files without credentials. FlowUtils needs a C compiler if a compatible wheel is unavailable.
Security
What our scanner noticed· Low risk
- Instructions that use the network
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- K-Dense Inc.
- Publisher
- K-Dense (Community)
- Source
- K-Dense-AI/scientific-agent-skills · skills/flowkit · commit a25cf9e
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE.md)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by K-Dense Inc. or K-Dense.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download flowkit.zip