gate_live_cells: Gate live cells

View source: R/files_gating.R

gate_live_cellsR Documentation

Gate live cells

Description

Performs gating of live cells using flowDensity::deGate

Usage

gate_live_cells(
  flow_frame,
  file_name = NULL,
  viability_channel,
  tinypeak_removal_viability = 0.8,
  alpha_viability = 0.1,
  tinypeak_removal_Iridium = 0.8,
  alpha_Iridium = 0.05,
  arcsine_transform = TRUE,
  save_gated_flow_frame = FALSE,
  suffix = "_live_gated",
  out_dir = NULL,
  ...
)

Arguments

flow_frame

A flowframe that contains cytometry data.

file_name

Character, the file name used for saving the flow frame (if save_gated_flow_frame = TRUE) and for plotting, if NULL (default) the file name stored in keyword FIL will be used,

viability_channel

Character, the channel name used for viability staining

tinypeak_removal_viability

Numeric from 0-1, as in deGate to exclude/include tiny peaks in the tail of the density distribution curve for both viability channel

alpha_viability

Numeric, 0-1, as in deGate specify the significance of change in the slope of viability channel

tinypeak_removal_Iridium

The same as tinypeak_removal_viability but for the head and tail of the density distribution curve in Iridium channel

alpha_Iridium

The same as in alpha_viability but for the Iridium

arcsine_transform

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

save_gated_flow_frame

Logical, if gated flow frame should be saved. Only cells falling into intact cell region will be saved. Default set to FALSE.

suffix

Character, suffix placed in the name of saved fcs file, only if save_gated_flow_frame = TRUE.Defult is "_intact_gated".

out_dir

Character, pathway to where the files should be saved, if NULL (default) files will be saved to file.path(getwd(), Gated).

...

Arguments to pass to flowDensity::plotDens().

Value

An untransformed flow frame with live cells only

Examples


#' Set input directory
aggregate_dir <- file.path(dir, "Aggregated")

# List files for gating
files <- list.files(path = aggregate_dir,
                    pattern = ".fcs$",
                    full.names = TRUE)

# Create directory to store plot
gate_dir <- file.path(getwd(), "Gated")
if(!dir.exists(gate_dir)){dir.create(gate_dir)}

# Gate the files and plot the gating strategy for each file
n_plots <- 1
png(file.path(gate_dir, paste0("gating.png")),
width = n_plots * 300,
height = length(files) * 300)
layout(matrix(1:(length(files) * n_plots), ncol = n_plots, byrow = TRUE))

for (file in files){

 ff <- flowCore::read.FCS(filename = file,
                          transformation = FALSE)

 ff <- gate_live_cells(flow_frame = ff,
                       viability_channel = "Pt195Di", save_gated_flow_frame = TRUE,
                       file_name = basename(file))
}

dev.off()


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