aggregate-methods {Cardinal} | R Documentation

## Calculating summary statistics

### Description

These methods calculate summary statistics over subsets of an imaging experiment.

### Usage

    ## S4 method for signature 'SparseImagingExperiment'
    aggregate(x, by = c("feature", "pixel"), FUN,
            groups = NULL, tform = identity, as = "ImagingExperiment",
            BPPARAM = getCardinalBPPARAM(), ...)

    summarizeFeatures(x, FUN = "mean", ...)

    summarizePixels(x, FUN = "mean", ...)

### Arguments

`x` | An imaging dataset.
`by` | Should the summarization be performed over pixels or features?
`FUN` | A function or list of functions that return statistical summaries. Known statistics can be provided to be computed more efficiently than providing the equivalent function. Known statistics include "min", "max", "mean", "sum", "sd", and "var".
`groups` | A grouping variable for summarization. The summary functions will be applied within each group.
`tform` | A unary transformation that should each row or column be transformed before summarization is applied.
`as` | What class of object should be returned (`ImagingExperiment` or `DataFrame`)?
`BPPARAM` | An optional `BiocParallelParam` instance to be passed to `bplapply()`.
`...` | Additional arguments to be passed to `FUN`.

### Value

An `ImagingExperiment` subclass if `as=="ImagingExperiment"` or a `DataFrame` subclass otherwise.

### Author(s)

Kylie A. Bemis

### Examples

    set.seed(1)
    mse <- simulateImage(preset=1, npeaks=10, dim=c(10,10))

    # calculate median spectrum
    aggregate(mse, by="feature", FUN=median, as="DataFrame")

    # summarize mean spectrum
    summarizeFeatures(mse, FUN="mean", as="DataFrame")

    # summarize image by TIC
    summarizePixels(mse, FUN=c(tic="sum"), as="DataFrame")

    # summarize mean spectrum grouped by pixels in/out of circle
    summarizeFeatures(mse, FUN="mean", groups=mse$circle, as="DataFrame")

[Package Cardinal version 2.12.0 Index]