bulkrna-batch-correcti…
Load when correcting batch effects in bulk expression using R sva ComBat or the legacy Python parametric approximation. Skip…
Load when removing batch effects from multi-batch spatial AnnData with PCA using Harmony, BBKNN, or Scanorama. Skip physical coordinate alignment (use spatial-register) and single-batch data (use spatial-domains).
$ npx -y skills add tiangzlab/omicsclaw --skill spatial-integrate --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/spatial-integrateContext preview
The summary Claude sees to decide when to auto-load this skill.
Load when removing batch effects from multi-batch spatial AnnData with PCA using Harmony, BBKNN, or Scanorama. Skip physical coordinate alignment (use spatial-register) and single-batch data (use spatial-domains).
name: spatial-integrate description: Load when removing batch effects from multi-batch spatial AnnData with PCA using Harmony, BBKNN, or Scanorama. Skip physical coordinate alignment (use spatial-register) and single-batch data (use spatial-domains). trigger: multi-sample integration, batch correction, Harmony, BBKNN, Scanorama tags: - spatial - integration - batch-correction
from skills._sdk.notebook import load_skill, read_input, write_output
library = load_skill("spatial-integrate")
adata = read_input("data/multi_sample.h5ad")
adata = library.integrate(adata, batch_key="sample")
write_output(adata, "intermediate/integrated.h5ad")Correct expression-space batch effects after spatial-preprocess. Harmony and Scanorama add corrected PCA-based embeddings; BBKNN replaces the neighbor graph. None aligns tissue coordinates or changes the expression matrix.
Input: preprocessed AnnData with `obsm["X_pca"]` and at least two labels in `obs["batch"]` (or the chosen batch_key). Functions return AnnData, tables and figures without writing files; see API below.
CLI writes `processed.h5ad`, `report.md`, `result.json`, batch-size and integration tables, and the comparison gallery. The complete file inventory and generation conditions are in [references/output_contract.md](references/output_contract.md). Harmony adds `X_pca_harmony`; Scanorama adds `X_scanorama`; BBKNN changes `obsp["distances"]` and `obsp["connectivities"]`.
python skills/spatial/spatial-integrate/spatial_integrate.py \ --input multi_sample.h5ad --output results/integration --method harmony --batch-key sample python skills/spatial/spatial-integrate/spatial_integrate.py --demo --output /tmp/spatial_integrate
Use `examples/example_step.py` for load_skill, saved objects and replay. [references/parameters.md](references/parameters.md) lists the CLI method flags.
inspect condition and cell-type structure before choosing a correction.
BBKNN's default Annoy matching and Scanorama's wrapper expose no seed here; cross-version matching can vary. The installed versions passed repeat CLI checks.
its existing `uns["spatial_integration"]` summary.
<!-- api:begin generated from _api.py; regenerate with run.py api <skill dir> --write -->
Integrate a multi-batch PCA representation in place, preserving expression.
:param adata: Preprocessed AnnData with X_pca and batch labels. :param method: harmony (default), bbknn (graph only), or scanorama. :param batch_key: Batch column in obs, default batch. :param random_state: Seed for Harmony, neighbors, UMAP and Leiden, default 0. BBKNN's default Annoy backend and Scanorama expose no seed here; their matching can vary across backend versions. :param parameters: Method keywords with original CLI defaults: Harmony theta=2, lamb=1, max_iter_harmony=10; BBKNN neighbors_within_batch=3, n_pcs=50, trim=None; Scanorama knn=20, sigma=15, alpha=0.1, batch_size=5000. :returns: The same AnnData with corrected embedding or graph, UMAP snapshots, per-spot batch entropy, and JSON run diagnostics. X is unchanged. :raises ValueError: Unknown method, missing batches/PCA, or invalid parameters. :raises ImportError: Missing backend; use install_skill_deps for that method.
Read the last integration summary.
:param adata: AnnData returned by integrate. :param keep: True retains diagnostics; False removes them for CLI serialization. :returns: Summary including seed and effective method parameters, or an empty dict.
Return per-spot entropy before and after correction.
:param adata: Integrated AnnData. :returns: observation, batch_entropy_before, batch_entropy_after and batch_entropy_delta. :raises KeyError: Integration entropy columns are absent.
Compare the pre- and post-integration UMAP coordinates.
:param adata: Integrated AnnData with both UMAP snapshots. :param batch_key: Batch labels used for color, default batch. :returns: A matplotlib Figure; the caller saves and closes it. :raises KeyError: Batch labels or UMAP snapshots are absent.
<!-- api:end -->
`anndata`, `bbknn`, `harmonypy`, `matplotlib`, `numpy`, `pandas`, `scanorama`, `scanpy`, `scipy`, `seaborn`
Missing method packages raise ImportError with an install_skill_deps hint.
Conversational & memory-enabled AI research partner for multi-omics analysis. CLI + Desktop App (installers in Releases). From biological idea to full research paper.
Load when correcting batch effects in bulk expression using R sva ComBat or the legacy Python parametric approximation. Skip…
Load when discovering bulk gene co-expression modules and hub genes with R WGCNA. Skip direct expression contrasts (use…
Load when comparing gene expression between two conditions in bulk RNA-seq count data. Skip
Load when estimating cell-type proportions in bulk RNA-seq samples from a single-cell or
Load when running pathway / GO term enrichment on a bulk RNA-seq DE result list. Skip when
Load when converting Ensembl, Entrez or symbol IDs in a bulk RNA count matrix using an explicit mapping or a small human demo…