agentsclimarketplace

Batch effect correction reference based

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/batch-effect-correction-reference-based

Use when when you have log-transformed metabolite abundance data from multiple batches (e.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill batch-effect-correction-reference-based

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

7.6 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it

batch-effect-correction-reference-based

License: restricted — no clear open-source license detected for the underlying tool; verify licensing before commercial use or redistribution. <!-- asb-license-banner -->

Summary

Apply concordance-based batch effect correction to log-transformed metabolomics data by designating a reference batch and disabling group-level stratification. This skill removes batch-driven signal drift while preserving biological group differences in large-scale metabolite matrices.

When to use

When you have log-transformed metabolite abundance data from multiple batches (e.g., mass spectrometry runs or sample processing cohorts), a single batch can be nominated as a stable reference standard, and you want to correct all other batches to match the reference's statistical properties without stratifying correction within biological groups.

When NOT to use

  • Data is not log-transformed; CordBat expects log-scale input to model multiplicative batch effects.
  • No clear reference batch exists or reference batch quality is questionable; design should nominate a batch known to have minimal technical variability.
  • Correction should preserve or exploit group-level batch heterogeneity; set grouping=FALSE assumes batch effects are consistent across groups, which may not hold if group×batch interactions are strong.

Inputs

  • log2-transformed metabolite abundance matrix (numeric; samples × metabolites)
  • batch assignment vector (character or factor; length = number of samples)
  • group assignment vector (character or factor; length = number of samples)
  • reference batch label (character; must match one unique value in batch vector)

Outputs

  • corrected log2-scale metabolite matrix (numeric; samples × metabolites; from fit$X.cor)
  • fitted CordBat object (contains convergence details and model parameters)

How to apply

Prepare a log2-transformed metabolite matrix (rows = samples, columns = metabolites), a batch assignment vector identifying which batch each sample belongs to (with one batch labeled 'Ref'), and a group assignment vector. Call CordBat() with the log-transformed matrix, batch vector, group vector, ref.batch='Ref', and grouping=FALSE. CordBat uses concordance-based normalization to align batch statistics to the reference batch without iterative loops. Extract the corrected log2-scale matrix from the fit object (fit$X.cor). Back-transform by exponentiating (2^corrected_mat) for downstream visualization or statistical testing. The reference batch acts as the anchor; all other batches' systematic offsets are measured and removed relative to it.

Related tools

  • CordBat (Performs concordance-based batch effect correction on log-transformed metabolite matrices with reference batch specification and optional group stratification.) — https://github.com/BorchLab/CordBat
  • R (Runtime environment for executing CordBat function calls and data transformations.)
  • ggplot2 (Visualization of PCA results before and after batch correction to assess removal of batch effects.)
  • dplyr (Data wrangling and preparation of batch and group assignment vectors from metadata.)

Examples

fit <- CordBat(X = as.matrix(log2(cordbat_example[metabolite_cols])), batch = batch_vec, group = group_vec, ref.batch = "Ref", grouping = FALSE, print.detail = FALSE); corrected_mat <- fit$X.cor

Evaluation signals

  • PCA plot on back-transformed corrected data (2^corrected_mat) shows samples from different batches overlapping in principal component space, whereas uncorrected PCA showed clear batch-driven clustering.
  • Corrected matrix retains original dimensions and range; no NaN, Inf, or unexpected values introduced.
  • fit object contains convergence status and model parameters; print.detail=FALSE still allows inspection of fit$X.cor.
  • Biological group signal is preserved: mean log2-abundance differences between groups remain statistically significant post-correction.
  • Reference batch samples remain numerically unchanged or minimally perturbed in corrected matrix (ref.batch acts as anchor).

Limitations

  • Assumes batch effects are multiplicative and uniform across metabolites; if batch effects are additive or highly metabolite-specific, correction may be incomplete.
  • Requires designation of a high-quality reference batch; poor reference choice propagates bias to all corrected batches.
  • grouping=FALSE means correction does not account for group×batch interactions; if such interactions are present, residual group-confounded batch signal may persist.
  • CordBat is optimized for large-scale metabolomics (25+ metabolites per sample in the example); performance or stability on very small datasets not characterized.

Evidence

  • [other] CordBat() accepts a log-transformed metabolite matrix (X_mat), batch assignment vector (batch_vec), group assignment vector (group_vec), a reference batch label ('Ref'), and a grouping parameter set to FALSE, producing a fitted object from which the corrected matrix is extracted via fit$X.cor.: "CordBat() accepts a log-transformed metabolite matrix (X_mat), batch assignment vector (batch_vec), group assignment vector (group_vec), a reference batch label ("Ref"), and a grouping parameter set"
  • [methods] fit <- CordBat( X = X_mat, batch = batch_vec, group = group_vec, ref.batch = "Ref", grouping = FALSE,
    print.detail = FALSE ): "fit <- CordBat( X = X_mat, batch = batch_vec, group = group_vec, ref.batch = "Ref", grouping = FALSE,
    print.detail = FALSE )"
  • [methods] Log-transform metabolite measurements and extract the corrected log2-scale matrix from fit$X.cor.: "X_mat <- as.matrix(log2(cordbat_example[met_cols]))"
  • [readme] This is a R package implementation of the Concordance-Based Batch Effect Correction for Large-Scale Metabolomics (CordBat).: "This is a R package implementation of the Concordance-Based Batch Effect Correction for Large-Scale Metabolomics (CordBat)."
  • [readme] There is no methodologic change within the CordBat package from the original publication, however, substantial changes have been made to improve computational efficiency and limit iterative loops.: "There is no methodologic change within the CordBat package from the original publication, however, substantial changes have been made to improve computational efficiency and limit iterative loops."

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.