plot_marker_quantiles: Plots quantiles for the markers

View source: R/plotting_functions.R

plot_marker_quantilesR Documentation

Plots quantiles for the markers

Description

Calculates quantiles (0.01, 0.25, 0.5, 0.75, 0.99) for selected markers and plots them as diagnostic plots.

Usage

plot_marker_quantiles(
  files_before_norm,
  files_after_norm,
  batch_pattern = NULL,
  batch_labels = NULL,
  remove_beads = FALSE,
  bead_channel = "140",
  uncommon_prefix = NULL,
  arcsine_transform = TRUE,
  markers_to_plot = NULL,
  plot_name = "Marker_distribution_across_aliquots_and_batches",
  manual_colors = NULL,
  out_dir = NULL,
  transform_list = NULL
)

Arguments

files_before_norm

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

files_after_norm

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

batch_pattern

Character, batch pattern to be match in the fcs file name

remove_beads

Logical, if beads needs to be removed. This needs to be set to TRUE if files contain beads e.g before beads normalization, default is set to TRUE. For the visualization purpose the beads will be removed using channel set in bead_channel.

bead_channel

character, the mass for bead channel that is exclusively used for beads identification (no marker is assign to this channel), Default 140.

uncommon_prefix

Character vector or string, uncommon prefix in the basename of the fcs files. The file names need to match, so uncommon prefix needs to be removed. If NULL (default) prefix like "Norm|_CC_gated.fcs|_gated.fcs|_beadNorm.fcs|.FCS|.fcs" will be removed. Default is set to NULL.

arcsine_transform

Logical, if the data should be transformed with arcsine transformation and cofactor 5.

markers_to_plot

character vector, marker names to be plotted, can be full marker name e.g. "CD45" or "CD" if all CD-markers needs to be plotted

manual_colors

character, vector of the colors to be used, the number of colors needs to be equal to the length of batch_pattern

out_dir

Character, pathway to where the plots should be saved, default is set to working directory.

transform_list

Transformation list to pass to the flowCore transform function, see flowCore::transformList, if different transformation than arcsine is needed. Only if arcsine_transform is FALSE. If NULL and arcsine_transform = FALSE no transformation will be applied.

Value

Save the pdf with plots to out_dir.

Examples

# Define files for visualization
# Before normalization
raw_data_dir <- file.path(dir, "RawFiles")
files_b <- list.files(raw_data_dir,
                      pattern = ".FCS$",
                      ignore.case = T,
                      full.names = TRUE)

# After normalization
bead_norm_dir <- file.path(dir, "BeadNorm")
files_a <- list.files(bead_norm_dir,
                      pattern = "_beadNorm.fcs$",
                      ignore.case = T,
                      full.names = TRUE)

# Define batch id and sample id for each file
batch_pattern <- stringr::str_match(basename(files_b), "(?i).*(day[0-9]*).*.FCS")[,2]

plot_marker_quantiles(files_after_norm = files_a,
                     files_before_norm = files_b,
                     batch_pattern = batch_pattern,
                     arcsine_transform = TRUE,
                     remove_beads = TRUE,
                     bead_channel = "140",
                     uncommon_prefix = "_beadNorm.fcs|.FCS",
                     markers_to_plot = c("CD", "HLA", "IgD", "IL", "TNF",
                                         "TGF", "GR", "IFNa"),
                     manual_colors = c("darkorchid4", "darkorange", "darkgreen"),
                     out_dir = bead_norm_dir)


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