clean_files: Clean flow rate and signal

View source: R/clean_flow_rate_and_signal.R

clean_filesR Documentation

Clean flow rate and signal

Description

Cleans the flow rate using functions from flowAI package and the signal using flowCut package.

Usage

clean_files(
  files,
  cores = 1,
  to_plot = "All",
  clean_flow_rate = TRUE,
  clean_signal = TRUE,
  out_dir = NULL,
  alpha = 0.01,
  data_type = "MC",
  channels_to_clean = NULL,
  Segment = 1000,
  arcsine_transform = TRUE,
  non_used_bead_ch = NULL,
  MaxPercCut = 0.5,
  UseOnlyWorstChannels = TRUE,
  AllowFlaggedRerun = TRUE,
  AlwaysClean = TRUE,
  ...
)

Arguments

files

Character vector or list with the paths of the raw files.

cores

Number of cores to be used.

to_plot

Character variable that indicates if plots should be generated. The default is "All", which generates plots for flow rate and all channels. Other options are "Flagged Only", plots the flow rate and channels that were spotted with flowCut as incorrect and "None", does not plots anything.

clean_flow_rate

Logical, if flow rate should be cleaned.

clean_signal,

Logical, if signal should be cleaned.

out_dir

Character, pathway to where the plots should be saved, only if argument to_plot = TRUE, default is set to file.path(getwd(), Cleaned).

alpha

numeric, as in flowAI::flow_auto_qc. The statistical significance level used to accept anomalies. The default value is 0.01. Applies to flow rate.

data_type

Character, if MC (mass cytometry) of FC (flow cytometry) data are analyzed.

channels_to_clean

Character vector of the channels that needs to be cleaned.Applies to signal cleaning.

Segment

As in flowCut, an integer value that specifies the number of events in each segment to be analyzed.Default is 1000 events.

arcsine_transform

Logical, if the data should be transformed with arcsine transformation and cofactor 5, default is set to TRUE. Applies to signal cleaning.

non_used_bead_ch

Character vector, bead channels that does not contain any marker information, thus do not need to be cleaned and used for further analysis.Applies to signal cleaning.

MaxPercCut

As in flowCut, numeric between 0-1 the maximum percentage of event that will be removed form the data.Applies to signal cleaning.

UseOnlyWorstChannels

As in flowCut, logical, automated detection of the worst channel that will be used for cleaning.Applies to signal cleaning.

AllowFlaggedRerun

as in flowCut, logical, specify if flowCut will run

AlwaysClean

as in flowCut, logical. The file will be cleaned even if it has a relatively stable signal. The segments that are 7 SD away from the mean of all segments are removed.Applies to signal cleaning.

...

Additional arguments to pass to flowcut.Applies to signal cleaning.

Value

Cleaned, untransformed flow frame if arcsine_transform argument set to TRUE, otherwise transformed flow frame is returned. Save plots with prefix "_beadNorm_flowAI.png" and "flowCutCleaned.png" to out_dir if parameter to_plot set to "All" or "Flagged Only".

Examples

# Set and create the directory where cleaned fcs files will be saved
clean_dir <- file.path(dir, "Cleaned")

# Define which files will be cleaned
files <- list.files(bead_norm_dir,
                   ignore.case = TRUE,
                   pattern = "_beadNorm.fcs$",
                   full.names = TRUE)

# Clean files
clean_files(files, cores = 1,
           out_dir = clean_dir,
           to_plot = "All",
           data_type = "MC",
           Segment = 1000,
           arcsine_transform = TRUE,
           non_used_bead_ch = "140")


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