file_quality_check: Check the quality of acquired files

View source: R/files_quality_check.R

file_quality_checkR Documentation

Check the quality of acquired files

Description

Wrapper function to perform sample quality scoring. First, it clusters the data per each batch (if batch argument is defined) and calculates the AOF scores and Quality scores per batch using AOF algorithm. Next, based on Quality scores, it detects outliers across all the files, regarding the batch.

Usage

file_quality_check(
  fcs_files,
  file_batch_id = NULL,
  out_dir = NULL,
  phenotyping_markers = NULL,
  markers_to_score = NULL,
  arcsine_transform = TRUE,
  sd = 3,
  nClus = 10,
  ...
)

Arguments

fcs_files

Character, full path to fcs files.

file_batch_id

Character vector with batch label for each fcs_file, the order and the length needs to be the same as in fcs_files. If only one batch or one file is processed the parameter should be left as NULL (default).

out_dir

Character, pathway to where the plots should be saved, default is set to NULL, which means that the following path will be created file.path(getwd(), "Quality_Control").

phenotyping_markers

Character vector, marker names to be used for flowsom clustering including DNA marker Iridium and viability staining if available. Can be full marker name e.g. "CD45" or pattern "CD" if all CD-markers needs to be plotted. Default is set to NULL, thus all the mass channels will be used.

markers_to_score

Character vector, marker names to be used for flowsom clustering including DNA marker Iridium and viability staining if available. Can be full marker name e.g. "CD45" or pattern "CD" if all CD-markers needs to be plotted. Default is set to NULL, thus the aof scores will be calculated for the markers included in phenotyping_markers.

arcsine_transform

Logical, if the data should be transformed with arcsine transformation and cofactor 5. Default is set to TRUE. If FALSE, the transform list to pass to the flowCore transform function must be defined and pass as an additional argument to fsom_aof function.

sd

Numeric, number of standard deviation allowed for file outlier detection, default = 3.

nClus

Numeric, as in FlowSOM, number of metaclusters to be obtained

...

Arguments to be passed to fsom_aof function for FlowSOM parameter adjustment and plotting: xdim, ydim, transform_list, my_colors, seed, to_plot.

Value

Quality file scores, plots Quality AOF scores for all files and save .RDS and .csv Quality scores for further analysis, files are saved in out_dir.

Examples

# Set input directory
clean_dir <- file.path(dir, "Cleaned")

# Define files for visualization
files <- list.files(clean_dir,
                   pattern = "_cleaned.fcs$",
                   full.names = TRUE)

# Define batch_id for each file
file_batch_id <- stringr::str_match(basename(files),
                                   "(day[0-9]*).*.fcs")[,2]

file_quality_check(fcs_files = files,
                  file_batch_id = file_batch_id,
                  phenotyping_markers = c("Ir","CD", "HLA", "IgD", "Pt"),
                  arcsine_transform = TRUE,
                  nClus = 10,
                  sd = 3)


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