Skip to main content

remove_batch_effect

Function remove_batch_effect 

Source
pub fn remove_batch_effect(
    x: &Array2<f64>,
    batch: Option<&[String]>,
    batch2: Option<&[String]>,
    covariates: Option<&Array2<f64>>,
    design: Option<&Array2<f64>>,
) -> Result<Array2<f64>>
Expand description

Remove batch effects from x (n_genes x n_samples).

  • batch, batch2 — optional per-sample factor labels (length n_samples) for one or two blocking factors, coded with sum-to-zero contrasts.
  • covariates — optional n_samples x k numeric covariates to remove (mean-centred before fitting).
  • design — optional n_samples x p design matrix of experimental conditions to preserve. Defaults to a single intercept column (one-group experiment) when None.

Returns the batch-corrected matrix (n_genes x n_samples). With all of batch, batch2, covariates None the input is returned unchanged.