getCytoNormQuantiles: Extract quantiles used by a previous CytoNorm model

View source: R/CytoNorm.R

getCytoNormQuantilesR Documentation

Extract quantiles used by a previous CytoNorm model

Description

Can be of interest to pass as goal quantiles to a new model.

Usage

getCytoNormQuantiles(model, type = "ref")

Arguments

model

Model trained with CytoNorm.train

type

"ref" for goal quantiles or batch label

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")
validation_data <- dplyr::filter(data, Type == "Validation")

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

model <- CytoNorm.train(files = train_data$Path,
                        labels = train_data$Batch,
                        channels = channels,
                        transformList = transformList,
                        FlowSOM.params = list(nCells = 10000, #1000000
                                              xdim = 10,
                                              ydim = 10,
                                              nClus = 10,
                                              scale = FALSE),
                        normParams = list(nQ = 101),
                        seed = 1)

quantiles <- getCytoNormQuantiles(model)


saeyslab/CytoNorm documentation built on March 19, 2024, 6:43 p.m.