Last data update: 2014.03.03

R: Calculate best fitting Figure of Merit using method by Van...
FoM.CalculateR Documentation

Calculate best fitting Figure of Merit using method by Van Batenburg et al. (2011).

Description

This function will accept metabolomics sample data for a single metabolite and includes sample identification. It will bin corresponding samples by intensity and calculate a measure for each bin's error. The intensity per bin versus this measure of error will be plotted, and a best fit will be found and plotted that consists of a additive and a multiplicative part. For more details see the references.

Usage

FoM.Calculate(data, cols.id = 1, col.value, ids.per.bin, quiet = FALSE, 
repeats.per.id = -1, fit.type = 1, alpha.steps = 100)

Arguments

data

a matrix for which each row contains a sample's id and metabolomics data.

cols.id

indicate which column or columns in the matrix contain information pertaining to each sample's id, in which repeats of the same sample have the same id and can be binned together.

col.value

column in the data matrix that contains the metabolomics data to be plotted and fitted.

ids.per.bin

number of sample rows per bin.

quiet

should text output be given on the status of the calculations.

repeats.per.id

max number of repeats each sample may contain. If lower than the actual number repeats found, these extra repeats are ignored.

fit.type

which type of fitting should be used. Can be either "1" for use of the default R method "lm", or "2" for the more robust fitting method "rlm" from the 'MASS' package.

alpha.steps

how many points on the X axis in the final graph should be tried as a separation between the additive and the multiplicative fitting parts for finding the best fit.

Value

In addition to plotting the bins and showing the best fit, a list is returned containing the following values:

best.fit

a vector containing the three parameters that define the best fit: alpha value, additive coefficient, multiplicative coefficient, and the residual of the fit.

alphas

a vector containing all the alpha values used for fitting.

tot.res.ssq.per.alpha

a vector that gives the alpha values' corresponding residuals per fit.

ad.coeff.per.alpha

a vector that gives the alpha values' corresponding additive coefficient per fit.

mu.coeff.per.alpha

a vector that gives the alpha values' corresponding multiplicative coefficient per fit.

Author(s)

Marcel van Batenburg and Tim Dorscheidt

References

New Figures of Merit for Comprehensive Functional Genomics Data: The Metabolomics Case. Van Batenburg MF, Coulier L, van Eeuwijk F, Smilde AK, Westerhuis JA. Analytical Chemistry, Volume 83(9) (2011), pages 3267-3274

Examples

data(FoMData)
FoM.Calculate(FoMData, cols.id = c(1,2), 3, 5, quiet = FALSE, repeats.per.id = -1, 
fit.type = 1, alpha.steps = 100)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MetStaT)
Loading required package: MASS
Loading required package: abind
Loading required package: pls

Attaching package: 'pls'

The following object is masked from 'package:stats':

    loadings

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MetStaT/FoM.Calculate.Rd_%03d_medium.png", width=480, height=480)
> ### Name: FoM.Calculate
> ### Title: Calculate best fitting Figure of Merit using method by Van
> ###   Batenburg et al. (2011).
> ### Aliases: FoM.Calculate
> ### Keywords: Figures of Merit Metabolomics
> 
> ### ** Examples
> 
> data(FoMData)
> FoM.Calculate(FoMData, cols.id = c(1,2), 3, 5, quiet = FALSE, repeats.per.id = -1, 
+ fit.type = 1, alpha.steps = 100)
[1] "During binning, 17 samples had no further repeats, and were therefore discarded."
$name.of.value.col
[1] "P01"

$best.fit
                                  [,1]
alpha                     5.845828e+05
additiveCoefficient       3.294935e+09
multiplicativeCoefficient 1.244028e+06
ssQresiduals              4.610388e+19

$alphas
  [1] 250971.9 258385.5 265799.1 273212.6 280626.2 288039.8 295453.4 302866.9
  [9] 310280.5 317694.1 325107.7 332521.2 339934.8 347348.4 354762.0 362175.5
 [17] 369589.1 377002.7 384416.3 391829.8 399243.4 406657.0 414070.6 421484.1
 [25] 428897.7 436311.3 443724.9 451138.4 458552.0 465965.6 473379.2 480792.7
 [33] 488206.3 495619.9 503033.5 510447.0 517860.6 525274.2 532687.8 540101.3
 [41] 547514.9 554928.5 562342.1 569755.6 577169.2 584582.8 591996.4 599409.9
 [49] 606823.5 614237.1 621650.7 629064.2 636477.8 643891.4 651305.0 658718.5
 [57] 666132.1 673545.7 680959.3 688372.8 695786.4 703200.0 710613.6 718027.1
 [65] 725440.7 732854.3 740267.9 747681.4 755095.0 762508.6 769922.2 777335.7
 [73] 784749.3 792162.9 799576.5 806990.0 814403.6 821817.2 829230.8 836644.3
 [81] 844057.9 851471.5 858885.1 866298.6 873712.2 881125.8 888539.4 895952.9
 [89] 903366.5 910780.1 918193.7 925607.2 933020.8 940434.4 947848.0 955261.5
 [97] 962675.1 970088.7 977502.3 984915.8

$tot.res.ssq.per.alpha
  [1] 7.845280e+22 7.582199e+22 7.317198e+22 7.051048e+22 6.784704e+22
  [6] 6.519280e+22 6.335180e+22 6.069766e+22 5.805665e+22 5.544189e+22
 [11] 5.286832e+22 5.029093e+22 4.779456e+22 4.534743e+22 4.291839e+22
 [16] 4.056872e+22 3.826996e+22 3.651876e+22 3.423895e+22 3.199629e+22
 [21] 2.980421e+22 2.767784e+22 2.577250e+22 2.375935e+22 2.179131e+22
 [26] 1.988125e+22 1.804365e+22 1.629459e+22 1.465190e+22 1.320789e+22
 [31] 1.168553e+22 1.022613e+22 8.842517e+21 7.548902e+21 6.361016e+21
 [36] 5.296174e+21 4.373342e+21 3.600054e+21 2.857701e+21 2.178296e+21
 [41] 1.571555e+21 1.048247e+21 6.202718e+20 3.007489e+20 1.040955e+20
 [46] 4.610388e+19 1.440064e+20 4.165264e+20 2.214211e+23 2.214211e+23
 [51] 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23
 [56] 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23
 [61] 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23
 [66] 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23
 [71] 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23
 [76] 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23
 [81] 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23
 [86] 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23
 [91] 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23
 [96] 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23 2.214211e+23

$ad.coeff.per.alpha
  [1]          NA          NA          NA          NA          NA          NA
  [7]  1181919155  1181919155  1181919155  1181919155  1181919155  1102316337
 [13]  1102316337  1102316337  1024640910  1024640910  1024640910  2185931200
 [19]  2185931200  2185931200  2185931200  2185931200  2582491150  2582491150
 [25]  2582491150  2582491150  2582491150  2582491150  2582491150  3074565540
 [31]  3074565540  3074565540  3074565540  3074565540  3074565540  3074565540
 [37]  3074565540  3294934877  3294934877  3294934877  3294934877  3294934877
 [43]  3294934877  3294934877  3294934877  3294934877  3294934877  3294934877
 [49] 55389471512 55389471512 55389471512 55389471512 55389471512 55389471512
 [55] 55389471512 55389471512 55389471512 55389471512 55389471512 55389471512
 [61] 55389471512 55389471512 55389471512 55389471512 55389471512 55389471512
 [67] 55389471512 55389471512 55389471512 55389471512 55389471512 55389471512
 [73] 55389471512 55389471512 55389471512 55389471512 55389471512 55389471512
 [79] 55389471512 55389471512 55389471512 55389471512 55389471512 55389471512
 [85] 55389471512 55389471512 55389471512 55389471512 55389471512 55389471512
 [91] 55389471512 55389471512 55389471512 55389471512 55389471512 55389471512
 [97] 55389471512 55389471512 55389471512 55389471512

$mu.coeff.per.alpha
  [1]  455155.6  467071.0  479301.0  491833.8  504653.4  517738.8  528133.6
  [8]  541745.2  555634.3  569772.5  584124.5  598896.9  613724.1  628765.7
 [15]  644200.5  659708.2  675451.2  688607.6  704951.2  721598.9  738517.8
 [22]  755667.3  772034.2  789664.2  807624.1  825881.5  844396.3  863120.2
 [29]  881995.2  899853.8  919287.5  939066.7  959156.2  979513.1 1000085.1
 [36] 1020810.3 1041615.5 1061985.9 1083343.1 1105158.0 1127410.3 1150073.6
 [43] 1173114.0 1196489.6 1220148.4 1244027.8 1268053.1 1292135.4        NA
 [50]        NA        NA        NA        NA        NA        NA        NA
 [57]        NA        NA        NA        NA        NA        NA        NA
 [64]        NA        NA        NA        NA        NA        NA        NA
 [71]        NA        NA        NA        NA        NA        NA        NA
 [78]        NA        NA        NA        NA        NA        NA        NA
 [85]        NA        NA        NA        NA        NA        NA        NA
 [92]        NA        NA        NA        NA        NA        NA        NA
 [99]        NA        NA

> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>