Learn R Programming

WGCNA (version 1.34)

mtd.apply: Apply a function to each set in a multiData structure.

Description

Inspired by lapply, these functions apply a given function to each data component in the input multiData structure, and optionally simplify the result to an array if possible.

Usage

mtd.apply(multiData, FUN, ..., 
          mdaSimplify = FALSE, mdaCopyNonData = FALSE)

mtd.applyToSubset(multiData, FUN, ..., mdaRowIndex = NULL, mdaColIndex = NULL, mdaSimplify = FALSE, mdaCopyNonData = FALSE)

Arguments

multiData
A multiData structure to apply the function over
FUN
Function to be applied.
...
Other arguments to the function FUN.
mdaRowIndex
If given, must be a list of the same length as multiData. Each element must be a logical or numeric vector that specifies rows in each data component to select before applying the function.
mdaColIndex
A logical or numeric vector that specifies columns in each data component to select before applying the function.
mdaSimplify
Logical: should the result be simplified to an array, if possible? Note that this may lead to errors; if so, disable simplification.
mdaCopyNonData
Logical: should non-data components of multiData be copied into the output? Note that the copying is incompatible with simplification; enabling both will trigger an error.

Value

  • A multiData structure containing the results of the supplied function on each data component in the input multiData structure. Other components are simply copied.

Details

A multiData structure is intended to store (the same type of) data for multiple, possibly independent, realizations (for example, expression data for several independent experiments). It is a list where each component corresponds to an (independent) data set. Each component is in turn a list that can hold various types of information but must have a data component. In a "strict" multiData structure, the data components are required to each be a matrix or a data frame and have the same number of columns. In a "loose" multiData structure, the data components can be anything (but for most purposes should be of comparable type and content).

mtd.apply works on any "loose" multiData structure; mtd.applyToSubset assumes (and checks for) a "strict" multiData structure.

See Also

mtd.applyToSubset for applying a function to a subset of a multiData structure; mtd.mapply for vectorizing over several arguments.