Python port of cyCombine: batch correction of single-cell cytometry data
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cycombinepy-0.1.1.tar.gz.
File metadata
- Download URL: cycombinepy-0.1.1.tar.gz
- Upload date:
- Size: 21.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21e0bffa41d1166c58101460a570221fe646841aea41c4e9d7f07d8b9745059e
|
|
| MD5 |
6b0f72fbcf129d29cb52455da20986b1
|
|
| BLAKE2b-256 |
54c163fdcdb6644744e47e9d743e5b56d4e4102864b977fa68d9267c78504f98
|
Provenance
The following attestation bundles were made for cycombinepy-0.1.1.tar.gz:
Publisher:
release.yml on mdmanurung/cyCombinePy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cycombinepy-0.1.1.tar.gz -
Subject digest:
21e0bffa41d1166c58101460a570221fe646841aea41c4e9d7f07d8b9745059e - Sigstore transparency entry: 1262403619
- Sigstore integration time:
-
Permalink:
mdmanurung/cyCombinePy@22490759db376af1e7df89466ae9e4e9edd055c8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/mdmanurung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@22490759db376af1e7df89466ae9e4e9edd055c8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cycombinepy-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cycombinepy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 24.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93ebbefc3427eb34d0f8030dfd29c9b295aec6d2eb2ac0154a3665382dc7d1ea
|
|
| MD5 |
c053d7eedbf88fa1f5a93991b407b6c5
|
|
| BLAKE2b-256 |
c0faf1eff4d72a45ff556c2a6e6b7d98393ecff2b4aaf843056d18b49b456a18
|
Provenance
The following attestation bundles were made for cycombinepy-0.1.1-py3-none-any.whl:
Publisher:
release.yml on mdmanurung/cyCombinePy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cycombinepy-0.1.1-py3-none-any.whl -
Subject digest:
93ebbefc3427eb34d0f8030dfd29c9b295aec6d2eb2ac0154a3665382dc7d1ea - Sigstore transparency entry: 1262403632
- Sigstore integration time:
-
Permalink:
mdmanurung/cyCombinePy@22490759db376af1e7df89466ae9e4e9edd055c8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/mdmanurung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@22490759db376af1e7df89466ae9e4e9edd055c8 -
Trigger Event:
push
-
Statement type: