cycombinepy.batch_correct

cycombinepy.batch_correct(adata, markers=None, batch_key='batch', label_key='cycombine_som', xdim=8, ydim=8, rlen=10, seed=473, n_clusters=None, norm_method='scale', ties_method='average', covar=None, anchor=None, ref_batch=None, parametric=True, out_layer='cycombine_corrected', copy=False)[source]

Full cyCombine pipeline: normalize → SOM → per-cluster ComBat.

Parameters:
  • adata (AnnData) – Input AnnData. adata.X is assumed to already be on an appropriate scale (e.g. post-asinh for cytometry).

  • markers (Optional[Iterable[str]]) – Var names to normalize/cluster/correct. Defaults to cycombinepy.get_markers().

  • batch_key (str) – Column in adata.obs holding batch assignments.

  • label_key (str) – Column in adata.obs to write cluster labels to.

  • xdim (Union[int, Sequence[int]]) – SOM grid dimensions. Sequences trigger iterative correction: for each (x, y) pair, re-normalize, re-cluster, and re-correct.

  • ydim (Union[int, Sequence[int]]) – SOM grid dimensions. Sequences trigger iterative correction: for each (x, y) pair, re-normalize, re-cluster, and re-correct.

  • rlen (int) – SOM training passes (forwarded to FlowSOM if supported).

  • seed (int) – FlowSOM random seed.

  • n_clusters (int | None) – If set, metacluster the SOM nodes into this many clusters.

  • norm_method (Literal['scale', 'rank', 'CLR', 'CLR_seu', 'CLR_med', 'qnorm', 'none']) – Normalization method used for clustering. See cycombinepy.normalize().

  • ties_method (Literal['average', 'min', 'max', 'dense', 'ordinal']) – Tie-breaking rule for norm_method="rank".

  • covar (str | None) – Forwarded to cycombinepy.correct_data().

  • anchor (str | None) – Forwarded to cycombinepy.correct_data().

  • ref_batch – Forwarded to cycombinepy.correct_data().

  • parametric (bool) – Forwarded to cycombinepy.correct_data().

  • out_layer (str) – Layer name to store the corrected matrix in.

  • copy (bool) – If True, return a corrected copy; otherwise mutate in place.

Return type:

AnnData | None