getDensities: getDensities

View source: R/evaluation.R

getDensitiesR Documentation

getDensities

Description

Returns a dataframe with 4 columns, containing for every file and every channel of interest the x/y values computed by density.

Usage

getDensities(
  files,
  channels,
  quantileValues = 0.5,
  transformList = NULL,
  selection = NULL,
  ...
)

Arguments

files

Full paths of to the fcs files of the samples

channels

Names of the channels to compute the densities for

quantileValues

Quantiles to extract as well

transformList

Transformation list to pass to the flowCore transform function

selection

List with indexation vector for every file.

...

Extra parameters to pass to density

Examples


dir <- system.file("extdata", package = "CytoNorm")
files <- list.files(dir, pattern = "fcs$")

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

densities <- getDensities(files = file.path(dir, files),
                          channels = channels,
                          transformList = transformList,
                          quantileValues = c(0.25, 0.5, 0.75))

densities$densities$Marker <- paste0(
  FlowSOM::GetMarkers(ff, densities$densities$Channel),
  " (", densities$densities$Channel, ")")

library(ggplot2)
ggplot(dplyr::filter(densities$densities,
                     File == file.path(dir, files[1]))) +
  geom_line(aes(x = x, y = y)) +
  facet_wrap(~ Marker, scales = "free") +
  theme_minimal()

ggplot(dplyr::filter(densities$quantiles,
                     Channel == FlowSOM::GetChannels(ff, "CD66"))) +
  geom_vline(aes(xintercept = `0.25`), col = "grey") +
  geom_vline(aes(xintercept = `0.5`), col = "grey", lwd = 1) +
  geom_vline(aes(xintercept = `0.75`), col = "grey") +
  geom_line(aes(x = x, y = y),
            data = dplyr::filter(densities$densities,
                     Channel == FlowSOM::GetChannels(ff, "CD66"))) +
  facet_wrap(~ File) +
  theme_minimal()


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