Computation of summary statistic for selected channels, for all flowFrames of a flowSet. This method provides two different input modes:

  • the user provides directly a flowSet loaded in memory (RAM).

  • the user provides (1.) a number of samples nSamples; (2.) an ad-hoc function that takes as input an index between 1 and nSamples, and codes the method to load the corresponding flowFrame in memory; Optional row and column ranges can be provided to limit the calculation to a specific rectangle of the matrix. These i.e. can be specified as a way to split heavy calculations of large distance matrices on several computation nodes.

channelSummaryStats(
  x,
  loadFlowFrameFUN = NULL,
  loadFlowFrameFUNArgs = NULL,
  channels = NULL,
  statFUNs = stats::median,
  verbose = FALSE,
  BPPARAM = BiocParallel::SerialParam(),
  BPOPTIONS = BiocParallel::bpoptions(packages = c("flowCore"))
)

Arguments

x

either a flowCore::flowSet, or the number of samples (integer >=1)

loadFlowFrameFUN

the function used to translate a flowFrame index into a flowFrame. In other words, the function should code how to load a specific flowFrame into memory. Important: the flow Frame index should be the first function argument and should be named ffIndex.

loadFlowFrameFUNArgs

(optional) a named list containing additional input parameters of loadFlowFrameFUN()

channels

which channels (integer index(ices) or character(s)):

  • if it is a character vector, it can refer to either the channel names, or the marker names

  • if it is a numeric vector, it refers to the indexes of channels in fs

  • if NULL all scatter and fluorescent channels of fs will be selected

statFUNs

a list (possibly of length one) of functions to call to calculate the statistics, or a simple function This list can be named, in that case, these names will be transfered to the returned value.

verbose

if TRUE, output a message after each single distance calculation

BPPARAM

sets the BPPARAM back-end to be used for the computation. If not provided, will use BiocParallel::SerialParam() (no task parallelization)

BPOPTIONS

sets the BPOPTIONS to be passed to bplapply() function. Note that if you use a SnowParams back-end, you need to specify all the packages that need to be loaded for the different CytoProcessingStep to work properly (visibility of functions). As a minimum, the flowCore package needs to be loaded. (hence the default BPOPTIONS = bpoptions(packages = c("flowCore")) )

Value

a list of named statistic matrices. In each stat matrix, the columns are the channel statistics for all flowFrames of the flowSet. Exception: if only one stat function (and not a list) is passed in statFUNs, the return value is simplified to the stat matrix itself.

Examples


library(CytoPipeline)

data(OMIP021Samples)

# estimate scale transformations 
# and transform the whole OMIP021Samples

transList <- estimateScaleTransforms(
    ff = OMIP021Samples[[1]],
    fluoMethod = "estimateLogicle",
    scatterMethod = "linearQuantile",
    scatterRefMarker = "BV785 - CD3")

OMIP021Trans <- CytoPipeline::applyScaleTransforms(
    OMIP021Samples, 
    transList)

channelsOrMarkers <- c("FSC-A", "SSC-A", "BV785 - CD3")

# calculate mean for each 4 selected channels, for each 2 samples

channelMeans <- channelSummaryStats(
    OMIP021Trans,
    channels = channelsOrMarkers,
    statFUNs = mean)
    
# calculate median AND std deviation
# for each 4 selected channels, for each 2 samples

channelMedians <- channelSummaryStats(
    OMIP021Trans,
    channels = channelsOrMarkers,
    statFUNs = list("median" = stats::median, 
                    "std.dev" = stats::sd))