plotSplines: Plot splines used by the CytoNorm model

View source: R/plotSplines.R

plotSplinesR Documentation

Plot splines used by the CytoNorm model

Description

Plot splines used by the CytoNorm model

Usage

plotSplines(
  model,
  batches = names(model$clusterRes[[1]]$splines),
  channels = model$clusterRes[[1]]$channels[1:3],
  clusters = names(model$clusterRes),
  groupClusters = FALSE
)

Arguments

model

Model as generated by CytoNorm.train

batches

Batches to include. One plot per batch is generated. Default = all batches used in the model.

channels

Channels to include. Default = first three channels used.

clusters

Clusters to include. Default = all clusters.

groupClusters

Logical, if TRUE al clusters are shown on one subplot, if FALSE, there will be a separate row per cluster.

Value

List with one plot per batch. The figure shows a grid with the specified clusters in rows and the specified markers in columns. In every subfigure, black dots indicate the quantiles used by the model and a red line shows the spline.

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 = 5,
                                              scale = FALSE),
                        normParams = list(nQ = 99,
                                          limit = c(0,7)),
                        seed = 1)

plotlist <- plotSplines(model)
plotlist <- plotSplines(model, groupClusters = TRUE)
plotlist[[1]]


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