cbcb_batch: A function suggested by Hector Corrada Bravo and Kwame Okrah...

View source: R/normalize_batch.R

cbcb_batchR Documentation

A function suggested by Hector Corrada Bravo and Kwame Okrah for batch removal.

Description

During a lab meeting, the following function was suggested as a quick and dirty batch removal tool. It takes data and a model including a 'batch' factor, invokes limma on them, removes the batch factor, does a cross product of the fitted data and modified model and uses that with residuals to get a new data set.

Usage

cbcb_batch(
  normalized_counts,
  model,
  conditional_model = NULL,
  batch_model = NULL,
  batch1 = "batch",
  condition = "condition",
  matrix_scale = "linear",
  return_scale = "linear",
  method = "subtract"
)

Arguments

normalized_counts

Data frame of log2cpm counts.

model

Balanced experimental model containing condition and batch factors.

conditional_model

Experimental model with the conditional factor.

batch_model

Experimental model with the batch factor.

batch1

Column containing the first batch's metadata in the experimental design.

condition

Column containing the condition information in the metadata.

matrix_scale

Is the data on a linear or log scale?

return_scale

Do you want the data returned on the linear or log scale?

method

I found a couple ways to apply the surrogates to the data. One method subtracts the residuals of a batch model, the other adds the conditional.

Value

Dataframe of residuals after subtracting batch from the model.

See Also

[limma::voom()] [limma::lmFit()]

Examples

## Not run: 
 newdata <- cbcb_batch_effect(counts, expt_model)

## End(Not run)

elsayed-lab/hpgltools documentation built on May 9, 2024, 5:02 a.m.