cyCombinePy
Python port of cyCombine for batch correction of single-cell cytometry data.
cyCombinePy is AnnData-native and reuses existing Python libraries instead of reimplementing primitives:
- ComBat:
inmoose.pycombat - SOM clustering:
FlowSOM - FCS I/O:
pytometry/readfcs - Batch-effect metrics:
scib-metrics
Pipeline
The cyCombine workflow ports over unchanged:
- Batch-wise normalize expression per marker (
cycombinepy.normalize) - Self-organizing map clustering of cells (
cycombinepy.create_som) - Per-cluster ComBat correction with optional covariates and anchors
(
cycombinepy.correct_data)
Step 1 operates on a normalized view so clusters represent biology rather than batch. Step 3 is applied to the unnormalized data per cluster so rare populations aren't over-corrected.
Quickstart
import cycombinepy as pc
# 1. Load FCS files into AnnData
adata = pc.io.read_fcs_dir(
"data/",
metadata="metadata.csv",
batch_key="Batch",
sample_key="Patient",
condition_key="condition",
cofactor=5, # asinh cofactor for CyTOF
)
# 2. Inspect batch effects before correction
figs = pc.detect_batch_effect_express(adata, out_dir="before/")
# 3. End-to-end batch correction
pc.batch_correct(
adata,
xdim=8, ydim=8,
covar="condition",
)
# Corrected matrix is now in adata.layers["cycombine_corrected"]
# 4. Evaluate
from cycombinepy.correct import CORRECTED_LAYER
uncorr = pc.compute_emd(adata, cell_key="cycombine_som")
corr = pc.compute_emd(adata, cell_key="cycombine_som", layer=CORRECTED_LAYER)
report = pc.evaluate_emd(uncorr, corr)
print(report.groupby("marker")["reduction_pct"].mean())
Or use the modular API:
pc.transform_asinh(adata, cofactor=5)
pc.normalize(adata, method="scale")
pc.create_som(adata, xdim=8, ydim=8)
pc.correct_data(adata, label_key="cycombine_som", covar="condition")
Public API
| Function | Purpose |
|---|---|
batch_correct |
Full pipeline orchestrator |
transform_asinh |
Asinh transform with derandomization |
normalize |
Batch-wise scale / rank / CLR / qnorm |
create_som |
FlowSOM clustering |
correct_data |
Per-cluster ComBat correction |
compute_emd, evaluate_emd |
Earth-Mover's-Distance batch evaluation |
compute_mad, evaluate_mad |
Median-Absolute-Deviation batch evaluation |
detect_batch_effect, detect_batch_effect_express |
Diagnostic plots |
get_markers, check_confound |
Utilities |
FCS I/O lives in cycombinepy.io, plotting in cycombinepy.plotting, and an
optional scib_metrics wrapper in cycombinepy.evaluate.
Installation
pip install -e ".[all,dev]"
Data structure conventions
adata.X: cells × markers expression (post-asinh, pre-correction)adata.obs["batch"]: batch assignment (required)adata.obs["sample"],adata.obs["condition"],adata.obs["anchor"]: optional metadataadata.obs["cycombine_som"]: SOM cluster labels (written bycreate_som)adata.layers["cycombine_corrected"]: corrected expression (written bycorrect_data/batch_correct)
Citation
If you use cyCombinePy please cite the original cyCombine paper:
Pedersen, C.B., Dam, S.H., Barnkob, M.B., et al. cyCombine allows for robust integration of single-cell cytometry datasets within and across technologies. Nat Commun 13, 1698 (2022). https://doi.org/10.1038/s41467-022-29383-5
Metadata
Release files for cycombinepy 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cycombinepy-0.1.1.tar.gz | 21.8 kB | With provenance | Details for cycombinepy-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cycombinepy-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for cycombinepy-0.1.1-py3-none-any.whl |
Total release size: 46.6 kB
Release files / cycombinepy-0.1.1.tar.gz
| Download URL | cycombinepy-0.1.1.tar.gz |
|---|---|
| Size | 21.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
21e0bffa41d1166c58101460a570221fe646841aea41c4e9d7f07d8b9745059e
|
|
BLAKE2b-256 checksum How to use checksums |
54c163fdcdb6644744e47e9d743e5b56d4e4102864b977fa68d9267c78504f98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 9, 2026.
Transparency logRelease files / cycombinepy-0.1.1-py3-none-any.whl
| Download URL | cycombinepy-0.1.1-py3-none-any.whl |
|---|---|
| Size | 24.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
93ebbefc3427eb34d0f8030dfd29c9b295aec6d2eb2ac0154a3665382dc7d1ea
|
|
BLAKE2b-256 checksum How to use checksums |
c0faf1eff4d72a45ff556c2a6e6b7d98393ecff2b4aaf843056d18b49b456a18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 9, 2026.
Transparency logSecurity for cycombinepy 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for cycombinepy-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 9, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.