View source: R/normalize_batch.R
cbcb_batch | R Documentation |
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.
cbcb_batch(
normalized_counts,
model,
conditional_model = NULL,
batch_model = NULL,
batch1 = "batch",
condition = "condition",
matrix_scale = "linear",
return_scale = "linear",
method = "subtract"
)
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. |
Dataframe of residuals after subtracting batch from the model.
[limma::voom()] [limma::lmFit()]
## Not run:
newdata <- cbcb_batch_effect(counts, expt_model)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.