testCV: test_cv

View source: R/evaluation.R

testCVR Documentation

test_cv

Description

Function to inspect whether all control samples contain a similar percentage of cells in all FlowSOM clusters

Usage

testCV(fsom, cluster_values = 3:50, plot = TRUE, verbose = FALSE, seed = 1)

Arguments

fsom

FlowSOM list, as generated by prepareFlowSOM

cluster_values

Vector with all amounts of clusters to test, can not be smaller than 3.

plot

If TRUE, a plot of the CV values is generated

verbose

If TRUE, extra progress updates are printed

seed

Seed for reproducible results. Default = 1.

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 = 25,
                                             scale = FALSE),
                       transformList = transformList,
                       seed = 1)

cvs <- testCV(fsom,
              cluster_values = c(5,15,25,35,45)) # 3:50


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