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.
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.
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.
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 anonymous function you could use function(x) apply(x , 2 , var)
as an example to compute the variance of each phylostratum and each
developmental stage s.
Examples
# source the example dataset
data(PhyloExpressionSetExample)
# Example 1
# get the relative expression profiles for each phylostratum
age.apply(PhyloExpressionSetExample, RE)
#> Zygote Quadrant Globular Heart Torpedo Bent Mature
#> 1 0.4816246 0.3145330 0.46389184 0.00000000 0.17067495 0.56880234 1.0000000
#> 2 1.0000000 0.9363209 0.63348381 0.40823711 0.14904726 0.00000000 0.2206063
#> 3 0.6083424 0.4109402 0.00000000 0.09521758 0.16284114 0.21213845 1.0000000
#> 4 0.2985050 0.2366309 0.04946941 0.07499453 0.00000000 0.20573325 1.0000000
#> 5 0.2893657 0.2799777 0.00000000 0.01401191 0.01365328 0.45908792 1.0000000
#> 6 0.2323316 0.2786335 0.02706119 0.00000000 0.03592044 0.20084761 1.0000000
#> 7 0.5666979 0.2620602 0.00000000 0.12099252 0.07133814 0.13232551 1.0000000
#> 8 0.4203039 0.3092784 0.09237036 0.05442042 0.00000000 0.45520558 1.0000000
#> 9 0.4586261 0.4668613 0.39738003 0.23205534 0.00000000 0.37067096 1.0000000
#> 10 0.8811321 1.0000000 0.53841500 0.22974016 0.00000000 0.30490542 0.4881046
#> 11 0.4015809 0.4877111 0.04846721 0.05741594 0.00000000 0.07716367 1.0000000
#> 12 0.5052572 0.3359211 0.07100055 0.09489782 0.00000000 0.25811214 1.0000000
# this is analogous to
REMatrix(PhyloExpressionSetExample)
#> Zygote Quadrant Globular Heart Torpedo Bent Mature
#> 1 0.4816246 0.3145330 0.46389184 0.00000000 0.17067495 0.56880234 1.0000000
#> 2 1.0000000 0.9363209 0.63348381 0.40823711 0.14904726 0.00000000 0.2206063
#> 3 0.6083424 0.4109402 0.00000000 0.09521758 0.16284114 0.21213845 1.0000000
#> 4 0.2985050 0.2366309 0.04946941 0.07499453 0.00000000 0.20573325 1.0000000
#> 5 0.2893657 0.2799777 0.00000000 0.01401191 0.01365328 0.45908792 1.0000000
#> 6 0.2323316 0.2786335 0.02706119 0.00000000 0.03592044 0.20084761 1.0000000
#> 7 0.5666979 0.2620602 0.00000000 0.12099252 0.07133814 0.13232551 1.0000000
#> 8 0.4203039 0.3092784 0.09237036 0.05442042 0.00000000 0.45520558 1.0000000
#> 9 0.4586261 0.4668613 0.39738003 0.23205534 0.00000000 0.37067096 1.0000000
#> 10 0.8811321 1.0000000 0.53841500 0.22974016 0.00000000 0.30490542 0.4881046
#> 11 0.4015809 0.4877111 0.04846721 0.05741594 0.00000000 0.07716367 1.0000000
#> 12 0.5052572 0.3359211 0.07100055 0.09489782 0.00000000 0.25811214 1.0000000
# Example 2
# compute the mean expression profiles for each phylostratum
age.apply(PhyloExpressionSetExample, colMeans)
#> Zygote Quadrant Globular Heart Torpedo Bent Mature
#> 1 2607.882 2579.372 2604.856 2525.704 2554.825 2622.757 2696.331
#> 2 2597.258 2574.745 2467.679 2388.045 2296.410 2243.716 2321.709
#> 3 2528.272 2363.159 2019.436 2099.079 2155.642 2196.875 2855.866
#> 4 1925.320 1887.078 1771.399 1787.175 1740.823 1867.981 2358.893
#> 5 2378.883 2368.593 2061.729 2077.087 2076.693 2564.904 3157.761
#> 6 1658.253 1697.242 1485.401 1462.613 1492.861 1631.741 2304.683
#> 7 1993.321 1717.659 1480.525 1590.009 1545.078 1600.264 2385.409
#> 8 1781.653 1670.106 1452.180 1414.052 1359.376 1816.718 2364.070
#> 9 1758.119 1764.748 1708.815 1575.727 1388.920 1687.314 2193.930
#> 10 2414.456 2501.390 2163.810 1938.060 1770.039 1993.032 2127.015
#> 11 1999.163 2071.456 1702.779 1710.290 1662.099 1726.865 2501.443
#> 12 2126.189 2036.804 1896.964 1909.578 1859.485 1995.732 2387.343
# Example 3
# compute the variance profiles for each phylostratum
age.apply(PhyloExpressionSetExample, function(x) apply(x , 2 , var))
#> Zygote Quadrant Globular Heart Torpedo Bent Mature
#> 1 46858320 44033012 44106145 38877224 37548528 39453762 48129006
#> 2 46867279 42686867 36090002 32587501 29232620 28376678 30460806
#> 3 41783430 37194145 17928194 20312145 21038520 24918360 57471592
#> 4 19261723 17160926 13850827 14557261 13350847 19932521 42637133
#> 5 32592884 31153055 21527988 22233611 23096264 45694558 78388518
#> 6 12118906 13540947 8706851 8870013 10758437 17580299 58334320
#> 7 30355579 18174987 7117039 10899294 12633952 15875758 55103241
#> 8 13397069 11015110 6730029 5014969 3743414 27906852 52729250
#> 9 11342446 12741601 14947365 8479977 4709920 22850095 41873875
#> 10 47788107 50703428 35831030 30053404 22091444 35323704 36885550
#> 11 24104869 30970830 12777528 14043089 16961809 24200949 56830372
#> 12 30642509 27840568 23658038 23072584 22502870 29014330 49513851
# 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)
#> $`1`
#> Zygote Quadrant Globular Heart Torpedo Bent
#> [1,] 585.206 554.8961 548.0507 568.1412 540.0542 535.9804
#> [2,] 71936.292 68151.2904 72995.7957 67833.2550 64942.5576 69482.5093
#> Mature
#> [1,] 532.3402
#> [2,] 77475.7206
#>
#> $`2`
#> Zygote Quadrant Globular Heart Torpedo Bent
#> [1,] 580.6445 574.6997 560.7247 547.7568 557.0626 530.3735
#> [2,] 73999.5109 66168.5626 68717.7230 64428.0043 64437.4151 68692.2235
#> Mature
#> [1,] 562.4309
#> [2,] 67137.1151
#>
#> $`3`
#> Zygote Quadrant Globular Heart Torpedo Bent
#> [1,] 623.1659 589.5403 580.2586 588.6726 566.7765 558.5507
#> [2,] 68451.1737 67297.4233 60605.4226 61712.1844 54853.5566 55114.0385
#> Mature
#> [1,] 596.9872
#> [2,] 67058.7800
#>
#> $`4`
#> Zygote Quadrant Globular Heart Torpedo Bent
#> [1,] 589.5377 574.8131 560.7161 559.2638 569.3281 553.8426
#> [2,] 64147.2534 63952.2243 57847.7659 61816.6287 48750.3696 60011.1444
#> Mature
#> [1,] 572.2069
#> [2,] 75420.3483
#>
#> $`5`
#> Zygote Quadrant Globular Heart Torpedo Bent Mature
#> [1,] 571.478 572.2143 597.7567 588.9979 567.5319 571.7144 564.607
#> [2,] 66824.532 55393.2659 54161.7005 56953.2335 56346.4812 61459.7431 81105.580
#>
#> $`6`
#> Zygote Quadrant Globular Heart Torpedo Bent Mature
#> [1,] 589.0266 576.3678 568.514 575.5234 567.864 554.431 569.6375
#> [2,] 61492.5176 58588.9023 54426.657 53748.3906 57102.640 61177.576 81496.1486
#>
#> $`7`
#> Zygote Quadrant Globular Heart Torpedo Bent
#> [1,] 605.8876 581.1317 592.6554 591.897 560.0847 563.6024
#> [2,] 62256.6328 56018.9987 25729.4257 34192.828 44443.2861 50930.9745
#> Mature
#> [1,] 561.2506
#> [2,] 71635.6409
#>
#> $`8`
#> Zygote Quadrant Globular Heart Torpedo Bent
#> [1,] 637.9878 569.1286 584.7325 605.0823 594.4442 600.2223
#> [2,] 41138.0802 40931.4758 33941.3019 29157.0095 23359.8204 68783.3661
#> Mature
#> [1,] 556.4985
#> [2,] 68490.5460
#>
#> $`9`
#> Zygote Quadrant Globular Heart Torpedo Bent Mature
#> [1,] 641.0205 616.7897 581.1254 581.5667 586.88 591.8835 579.5047
#> [2,] 33543.3348 34506.4575 48067.4038 31816.1675 21583.04 65310.1500 67092.0569
#>
#> $`10`
#> Zygote Quadrant Globular Heart Torpedo Bent
#> [1,] 615.9278 592.7529 574.7775 575.9234 572.552 578.3298
#> [2,] 66638.5047 62675.8417 67192.4804 64719.1091 60300.004 66748.8375
#> Mature
#> [1,] 582.9723
#> [2,] 67226.2424
#>
#> $`11`
#> Zygote Quadrant Globular Heart Torpedo Bent
#> [1,] 619.2366 592.5207 597.7823 591.3239 566.7128 583.1649
#> [2,] 47624.9229 57584.7661 35765.6619 28663.2997 40557.9861 56151.2591
#> Mature
#> [1,] 607.0129
#> [2,] 59611.1041
#>
#> $`12`
#> Zygote Quadrant Globular Heart Torpedo Bent
#> [1,] 604.2214 569.8133 554.2327 569.9091 543.0326 532.1237
#> [2,] 65504.4362 64548.6717 68522.0261 65165.0830 59914.2792 64947.7257
#> Mature
#> [1,] 563.0654
#> [2,] 68435.7395
#>