View source: R/plotDensities.R
plotDensities | R Documentation |
Plot densities per batch
plotDensities(
input,
channels,
colors = NULL,
model = NULL,
transformList = NULL,
show_goal = FALSE,
suffix = c(original = "", normalized = "_norm")
)
input |
Named list containing paths to fcs files, for both batch and batch_norm. For a batch, the input can be either one or more paths to fcs files or a flowFrame. |
channels |
Channels to plot |
colors |
Optional vector with a color for each batch |
model |
CytoNorm model to split out the normalized density plots per FlowSOM meta-cluster. Optional. |
transformList |
In case the data from the fcs files still needs to be transformed. Default NULL, in which case no transformation happens. |
show_goal |
If a 'model' is provided, it is possible to show the model's goal distribution. |
suffix |
Suffixes used to distinguish the original from the normalized files. Default is c("original" = "", "normalized" = "_norm") |
List with 2 plots per channel
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 = 15,
ydim = 15,
nClus = 10,
scale = FALSE),
normParams = list(nQ = 99),
seed = 1,
verbose = TRUE)
CytoNorm.normalize(model = model,
files = validation_data$Path,
labels = validation_data$Batch,
transformList = transformList,
transformList.reverse = transformList.reverse,
outputDir = "Normalized",
verbose = TRUE)
original <- list("PTLG021" = validation_data$Path[1],
"PTLG028" = validation_data$Path[2],
"PTLG034" = validation_data$Path[3])
normalized <- list("PTLG021_norm" = paste0("Normalized/Norm_",validation_data$File[1]),
"PTLG028_norm" = paste0("Normalized/Norm_",validation_data$File[2]),
"PTLG034_norm" = paste0("Normalized/Norm_",validation_data$File[3]))
channels_to_plot <- c("Er170Di", "La139Di")
plots <- plotDensities(input = c(original, normalized),
model = model,
channels = channels_to_plot,
colors = c("blue", "red", "green"),
transformList = transformList)
p <- ggpubr::ggarrange(ggpubr::ggarrange(plotlist = plots[1:(length(plots)-1)],
ncol = 2,
nrow = 2*length(channels_to_plot)),
ggpubr::ggarrange(ggpubr::as_ggplot(plots[[length(plots)]])),
ncol = 1, nrow = 2, heights = c(10,1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.