normalize_REF: Normalize the data

View source: R/file_normalization_with_reference_sample.R

normalize_REFR Documentation

Normalize the data

Description

Normalize the data

Usage

normalize_REF(
  model,
  df,
  arcsine_transform = TRUE,
  transformList = NULL,
  transformList.reverse = NULL,
  out_dir = NULL,
  norm_with_clustering = FALSE
)

Arguments

model

Model of the batch effercts, as computed by train_REF_model.

df

Data frame containing following columns: file_paths (the full path to the files to be normalized), batch_label (batch label for each file), ref_ids (logical defining TRUE values for reference sample).

arcsine_transform

Logical, if the data should be transformed with arcsine transformation and cofactor 5, default is set to TRUE. Either transformList or arcsine_transform needs to be defined.

transformList

Transformation list to pass to the flowCore transform function. Defult is set to NULL. Either transformList or arcsine_transform needs to be defined.

transformList.reverse

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

out_dir

Character, pathway to where the FlowSOM clustering plot should be saved, default is set to working directory. If NULL, files will be saved in file.path(getwd(), CytoNorm).

norm_with_clustering

Logical, if teh model was built using clustering algorithm, FlowSOM. Default is FALSE.

Value

normalized fcs files

Examples

# Set input directory
gate_dir <- file.path(dir, "Gated")

# Define reference samples
files_ref <- list.files(gate_dir,
                        pattern = "*_gated.fcs$",
                        full.names = TRUE,
                        recursive = T)

df <- data.frame("file_paths" = files_ref,
                "batch_labels" = stringr::str_match(files_ref, "day[0-9]*")[,1],
                "ref_ids" = grepl("REF", files_ref))


model <- train_REF_model(df = df,
                        markers_to_normalize = c("CD", "HLA", "IgD",
                                                 "IL", "TN", "MCP", "MIP",
                                                 "Gran", "IFNa"),
                        arcsine_transform = TRUE,
                        nQ = 2,
                        limit = c(0,8),
                        quantileValues = c(0.05, 0.95),
                        goal = "mean",
                        norm_with_clustering = FALSE,
                        save_model = TRUE,
                        clustering_markers = c("CD", "HLA", "IgD"))

# Normalize files
normalize_REF(model = model, df = df, arcsine_transform = TRUE,
              norm_with_clustering = FALSE)


prybakowska/CytoQP documentation built on June 28, 2022, 12:36 a.m.