batch_normalization: median batch normalization

View source: R/batch_normalization.R

batch_normalizationR Documentation

median batch normalization

Description

This function median normalizes multivariable data often processed in batches, such as metabolomic and proteomic data sets.

Usage

batch_normalization(
  wdata,
  feature_data_sheet = NULL,
  sample_data_sheet = NULL,
  feature_runmode_col = NULL,
  batch_ids = NULL
)

Arguments

wdata

the metabolite data frame samples in row, metabolites in columns

feature_data_sheet

a data frame containing the feature annotation data

sample_data_sheet

a data frame containing the sample annotation data

feature_runmode_col

a string identifying the column name in the feature_data_sheet that identifies the run mode for each feature (metabolites of proteins).

batch_ids

a string vector, with a length equal to the number of samples in the data set that identifies what batch each sample belongs to.

Value

returns the wdata object passed to the function median normalized given the batch information provided.

Examples

####################################
## with a vector of batch variables
####################################
## define the data set
d1 = sapply(1:10, function(x){ rnorm(25, 40, 2) })
d2 = sapply(1:10, function(x){ rnorm(25, 35, 2) })
ex_data = rbind(d1,d2)
rownames(ex_data) = paste0("ind", 1:nrow(ex_data))
colnames(ex_data) = paste0("var", 1:ncol(ex_data))
## define the batch
batch = c( rep("A", 25), rep("B", 25)  )
## normalize by batch
norm_wdata = batch_normalization(wdata = ex_data, batch_ids = batch )


MRCIEU/MetaboQC documentation built on Feb. 3, 2023, 3:49 a.m.