QuantileNorm.normalize: QuantileNorm.normalize

View source: R/QuantileNorm.R

QuantileNorm.normalizeR Documentation

QuantileNorm.normalize

Description

Normalize data, given the batch effects learned from control samples per cell type/cluster (output from QuantileNorm.train). New fcs files are written to the given output directory.

Usage

QuantileNorm.normalize(
  model,
  files,
  labels,
  transformList,
  transformList.reverse,
  outputDir = ".",
  prefix = "Norm_",
  removeOriginal = FALSE,
  verbose = FALSE,
  ...
)

Arguments

model

Model of the batch effercts, as computed by QuantileNorm.train

files

Full paths of to the fcs files of the samples to normalize

labels

A label for every file, indicating to which batch it belongs, e.g. the plate ID.

transformList

Transformation list to pass to the flowCore transform function

transformList.reverse

Transformation list with the reverse functions, so the normalized files can be saved in the untransformed space

outputDir

Directory to put the temporary files in. Default = "."

prefix

Prefix to put in front of the normalized file names. Default = "Norm_"

removeOriginal

Should the original fcs be removed? Default = FALSE.

verbose

If TRUE, progress updates are printed. Default = FALSE.

...

Additional arguments to pass to read.FCS

Value

Nothing is returned, but the new FCS files are written to the output directory

See Also

QuantileNorm.train

Examples



dir <- system.file("extdata", package = "CytoNorm")
files <- list.files(dir, pattern = "fcs$")
data <- data.frame(File = files,
                   Path = file.path(dir, files),
                   Type = stringr::str_match(files, "_([12]).fcs")[,2],
                   Batch = stringr::str_match(files, "PTLG[0-9]*")[,1],
                   stringsAsFactors = FALSE)
data$Type <- c("1" = "Train", "2" = "Validation")[data$Type]
train_data <- dplyr::filter(data, Type == "Train")
validation_data <- dplyr::filter(data, Type == "Validation")

ff <- flowCore::read.FCS(data$Path[1])
channels <- grep("Di$", flowCore::colnames(ff), value = TRUE)
transformList <- flowCore::transformList(channels,
                                         cytofTransform)
transformList.reverse <- flowCore::transformList(channels,
                                                 cytofTransform.reverse)

model_nQ_101 <- QuantileNorm.train(
  files = train_data$Path,
  labels = train_data$Batch,
  channels = channels,
  transformList = transformList,
  nQ = 101)

QuantileNorm.normalize(model_nQ_101,
                       validation_data$Path,
                       validation_data$Batch,
                       transformList = transformList,
                       transformList.reverse = transformList.reverse)

saeyslab/CytoNorm documentation built on March 19, 2024, 6:43 p.m.