Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

aggregate_by_vector

Aggreagate quantitative features.


Description

This function takes a matrix of quantitative features x and a factor (of length equal to nrow(x)) defining subsets, and applies a user-defined function to aggregate each subset into a vector of quantitative values.

User-defined functions must thus return a vector of length equal to ncol(x). Examples thereof are

Usage

aggregate_by_vector(x, INDEX, FUN, ...)

Arguments

x

A matrix of mode numeric.

INDEX

A factor of length nrow(x).

FUN

A function to be applied to the subsets of x.

...

Additional arguments passed to FUN.

Value

A new matrix of dimensions ncol(x) and length(INDEX) with dimnames equal to colnames(x) and INDEX.

Author(s)

Laurent Gatto

See Also

Other Quantitative feature aggregation: colCounts(), medianPolish(), robustSummary()

Examples

x <- structure(c(10.3961935744407, 17.1663715212693, 14.1027587989326,
                12.850349037785, 10.6379251053134, 7.52885076885599,
                3.91816118984218, 11.1339832690524, 16.5321471730746,
                14.1787908569268, 11.9422579479634, 11.5154097311056,
                7.69906817878979, 3.97092153807337, 11.9394664781386,
                15.3791100898935, 14.2409281956285, 11.2106867261254,
                12.2958526883634, 9.00858488668671, 3.83120129974963,
                12.9033445520186, 14.375814954807, 14.1617803596661,
                10.1237981632645, 13.3390344671153, 9.75719265786117,
                3.81046169359919),
              .Dim = c(7L, 4L),
              .Dimnames = list(c("X1", "X27", "X41", "X47", "X52",
                                 "X53", "X55"),
                               c("iTRAQ4.114", "iTRAQ4.115",
                                 "iTRAQ4.116", "iTRAQ4.117")))
x

k <- factor(c("B", "E", "X", "E", "B", "B", "E"))

aggregate_by_vector(x, k, colMeans)
aggregate_by_vector(x, k, robustSummary)
aggregate_by_vector(x, k, medianPolish)

MsCoreUtils

Core Utils for Mass Spectrometry Data

v1.2.0
Artistic-2.0
Authors
RforMassSpectrometry Package Maintainer [cre], Laurent Gatto [aut] (<https://orcid.org/0000-0002-1520-2268>), Johannes Rainer [aut] (<https://orcid.org/0000-0002-6977-7147>), Sebastian Gibb [aut] (<https://orcid.org/0000-0001-7406-4443>), Adriaan Sticker [ctb], Sigurdur Smarason [ctb], Thomas Naake [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.