prepareFlowSOM: prepareFlowSOM

View source: R/CytoNorm.R

prepareFlowSOMR Documentation

prepareFlowSOM

Description

Aggregate files, transform them and run FlowSOM. This is used as a first step in the normalization procedure to detect groups of similar cells. Typically you will not call this function, but use the wrapper function CytoNorm.train instead.

Usage

prepareFlowSOM(
  files,
  colsToUse,
  nCells = 1e+06,
  FlowSOM.params = list(xdim = 15, ydim = 15, nClus = 30, scale = FALSE),
  transformList = NULL,
  verbose = FALSE,
  seed = NULL,
  ...
)

Arguments

files

path to FCS file or a flowSet containing the samples

colsToUse

IDs or column names of the columns to use for clustering

nCells

The total number of cells to use for the FlowSOM clustering. This number is divided by the number of files to determine the amount to select from each individual file. Default = 1 000 000.

FlowSOM.params

List with parameters to pass to the FlowSOM algorithm. Default = list(xdim = 15, ydim = 15, nclus = 30, scale = FALSE).

transformList

Transformation list to pass to the flowCore transform function. Default = NULL.

verbose

If TRUE, extra output is printed while running.

seed

If not NULL, set.seed is called with this argument for reproducable results. Default = NULL.

...

Additional arguments to pass to read.FCS

Value

FlowSOM object describing the FlowSOM clustering

Examples


dir <- system.file("extdata", package = "CytoNorm")
files <- list.files(dir, pattern = "fcs$")
data <- data.frame(File = files,
                   Path = file.path(dir, files),
                   Type = stringr::str_match(files, "_([12]).fcs")[,2],
                   Batch = stringr::str_match(files, "PTLG[0-9]*")[,1],
                   stringsAsFactors = FALSE)
data$Type <- c("1" = "Train", "2" = "Validation")[data$Type]
train_data <- dplyr::filter(data, Type == "Train")

ff <- flowCore::read.FCS(data$Path[1])
channels <- grep("Di$", flowCore::colnames(ff), value = TRUE)
transformList <- flowCore::transformList(channels,
                                         cytofTransform)

fsom <- prepareFlowSOM(train_data$Path,
                       channels,
                       nCells = 10000, #1000000
                       FlowSOM.params = list(xdim = 15,
                                             ydim = 15,
                                             nClus = 10,
                                             scale = FALSE),
                       transformList = transformList,
                       seed = 1)
FlowSOM::PlotStars(fsom)


saeyslab/CytoNorm documentation built on Nov. 2, 2024, 12:39 p.m.