aggregate_files: Deconvolute and aggregate debarcoded files

View source: R/files_aggregation.R

aggregate_filesR Documentation

Deconvolute and aggregate debarcoded files

Description

Performs aggregation of debarcoded files, assigning user defined name to each file.

Usage

aggregate_files(
  fcs_files,
  md,
  barcode_column,
  batch_column,
  cores = 1,
  channels_to_keep = NULL,
  maxcells = NULL,
  write_agg_file = TRUE,
  out_dir = NULL
)

Arguments

fcs_files

Character, full path to the fcs_files.

md

Metadata. Must contain the following columns: batch_column: defines to which batch each file belongs; barcode_name: defines to which barcode each file belongs fcs_new_name: a name for the fcs file that will be given after deconvolution and aggregation.

cores

Number of cores to be used.

channels_to_keep

Character vector with channel names to be kept. Default NULL.

maxcells

Numeric, maximum cells to randomly aggregate from each file, default is set to NULL, which means that all the cells will be aggregated.

write_agg_file

Logical, if the fcs files should be saved, if TRUE files will be saved in out_dir. Default set to TRUE.

out_dir

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

Value

List of the pathways to aggregated files.

Examples


# Set input directory
debarcode_dir <- file.path(dir, "Debarcoded")
# Define files for debarcoding
files <- list.files(debarcode_dir,
                    pattern = "_debarcoded.fcs$",
                    full.names = TRUE, recursive = T)

# Define out_dir for aggregated files
aggregate_dir <- file.path(dir, "Aggregated")

# Bring metadata
md <- utils::read.csv(file.path(dir, "RawFiles", "meta_data.csv"))

# Assign barcodes names
md$barcode_name <- paste0(rownames(CATALYST::sample_key)[md$BARCODE])

# Assign new sample names specifying patient id and its batch name
md$fcs_new_name <- paste0(md$ID, "_", md$STIM, "_", md$BATCH, ".fcs")

# Aggregate and deconvolute file names
aggregate_files(fcs_files = files,
                md,
                barcode_column = "barcode_name",
                batch_column = "BATCH",
                cores = 1,

                out_dir = aggregate_dir,
                write_agg_file = TRUE)


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