age.apply {myTAI} | R Documentation |
Age Category Specific apply Function
Description
This function performs the split-apply-combine methodology on Phylostrata or Divergence Strata stored within the input ExpressionSet.
This function is very useful to perform any phylostratum or divergence-stratum specific analysis.
Usage
age.apply(ExpressionSet, FUN, ..., as.list = FALSE)
Arguments
ExpressionSet |
a standard PhyloExpressionSet or DivergenceExpressionSet object. |
FUN |
a function to be performed on the corresponding expression matrix of each phylostratum or divergence-stratum. |
... |
additional arguments of FUN. |
as.list |
a boolean value specifying whether the output format shall be a matrix or a list object. |
Details
This function uses the split
function to subset the expression matrix into
phylostratum specific sub-matrices. Internally using lapply
, any function can
be performed to the sub-matrices. The return value of this function is a numeric matrix storing
the return values by FUN
for each phylostratum and each developmental stage s.
Note that the input FUN
must be an function that can be applied to a matrix (e.g., colMeans
or RE
).
In case you use an an anymous function you coud use function(x) apply(x , 2 , var)
as an example to compute the variance of each phylostratum and each
developmental stage s.
Value
Either a numeric matrix storing the return values of the applied function for each age class or a numeric list storing the return values of the applied function for each age class in a list.
Author(s)
Hajk-Georg Drost
See Also
split
, tapply
, lapply
, RE
, REMatrix
Examples
# source the example dataset
data(PhyloExpressionSetExample)
# Example 1
# get the relative expression profiles for each phylostratum
age.apply(PhyloExpressionSetExample, RE)
# this is analogous to
REMatrix(PhyloExpressionSetExample)
# Example 2
# compute the mean expression profiles for each phylostratum
age.apply(PhyloExpressionSetExample, colMeans)
# Example 3
# compute the variance profiles for each phylostratum
age.apply(PhyloExpressionSetExample, function(x) apply(x , 2 , var))
# Example 4
# compute the range for each phylostratum
# Note: in this case, the range() function returns 2 values for each phylostratum
# and each developmental stage, hence one should use the argument 'as.list = TRUE'
# to make sure that the results are returned properly
age.apply(PhyloExpressionSetExample, function(x) apply(x , 2 , range), as.list = TRUE)