nonlinearFitDist {MethylIT} | R Documentation |

A wrapper to call functions 'Weibull3P' and 'fitGGammaDist' to operate on list of GRanges.

nonlinearFitDist(LR, column = 9, dist.name = "Weibull", sample.size = 20, location.par = FALSE, absolute = FALSE, npoints = NULL, npoints0 = NULL, summarized.data = FALSE, maxiter = 1024, tol = 1e-12, ftol = 1e-12, ptol = 1e-12, minFactor = 10^-6, num.cores = NULL, tasks = 0L, maxfev = 1e+05, verbose = TRUE)

`LR` |
A list of GRanges objects with information divergence values in their meta-columns. |

`column` |
An integer number denoting the index of the GRanges column where the information divergence is given. Default column = 1 |

`dist.name` |
name of the distribution to fit: Weibull (default: "Weibull"), gamma with three-parameter (Gamma3P), gamma with two-parameter (Gamma2P), generalized gamma with three-parameter ("GGamma3P") or four-parameter ("GGamma4P"). |

`sample.size` |
size of the sample |

`location.par` |
whether to consider the fitting to generalized gamma distribution (GGamma) including the location parameter, i.e., a GGamma with four parameters (GGamam4P). |

`absolute` |
Logic (default, FALSE). Total variation (TV, the difference of methylation levels) is normally an output in the downstream MethylIT analysis. If 'absolute = TRUE', then TV is transformed into |TV|, which is an information divergence that can be fitted to Weibull or to Generalized Gamma distribution. |

`npoints` |
number of points used in the fit |

`npoints0` |
subset of points where to estimate the ECDF (used only to reduce computational time) |

`summarized.data` |
Logic value. If TRUE (default: FALSE), summarized data based on 'npoints' are used to perform the nonlinear fit. Only for GGamma distribution. |

`maxiter` |
positive integer. Termination occurs when the number of iterations reaches maxiter. Default value: 1024 |

`tol` |
A positive numeric value specifying the tolerance level for the relative offset convergence criterion. Default value: 1e-12, |

`ftol` |
non-negative numeric. Termination occurs when both the actual and predicted relative reductions in the sum of squares are at most ftol. Therefore, ftol measures the relative error desired in the sum of squares. Default value: 1e-12 |

`ptol` |
non-negative numeric. Termination occurs when the relative error between two consecutive iterates is at most ptol. Therefore, ptol measures the relative error desired in the approximate solution. Default value: 1e-12, |

`minFactor` |
A positive numeric value specifying the minimum step-size factor allowed on any step in the iteration. The increment is calculated with a Gauss-Newton algorithm and successively halved until the residual sum of squares has been decreased or until the step-size factor has been reduced below this limit. Default value: 10^-6. |

`num.cores` |
The number of cores to use, i.e. at most how many child processes will be run simultaneously (see bplapply function from BiocParallel package). |

`tasks` |
integer(1). The number of tasks per job. value must be a scalar integer >= 0L. In this documentation a job is defined as a single call to a function, such as bplapply, bpmapply etc. A task is the division of the X argument into chunks. When tasks == 0 (default), X is divided as evenly as possible over the number of workers (see MulticoreParam from BiocParallel package). |

`maxfev` |
integer; termination occurs when the number of calls to fn has reached maxfev. Note that nls.lm sets the value of maxfev to 100*(length(par) + 1) if maxfev = integer(), where par is the list or vector of parameters to be optimized. |

`verbose` |
If TRUE, prints the function log to stdout |

`...` |
other parameters |

The algorithm prepares the information divergence variable to try fitting Weibull or generalized gamma distribution model to the data. If Weibull distribution is selected (default: "Weibull"), function 'Weibull2P' first attempts fitting to the two-parameter Weibull CDF (Weibull2P). If Weibull2P did not fit, then the algorithm will try to fit Weibull3P. The Levenberg-Marquardt algorithm implemented in R package 'minpack.lm' is used to perform the nonlinear fit. Cross-validations for the nonlinear regressions (R.Cross.val) are performed in each methylome as described in reference [1]. In addition, Stein's formula for adjusted R squared (rho) is used as an estimator of the average cross-validation predictive power [1].

If "GGamma3P" is selected the call to function 'fitGGammaDist' permits the fitting to the three-parameter GGamma CDF ("GGamma3P"). The fit to the four-parameter GGamma ("GGamma4P") is also available. GGamma distribution are fitted using a modification of Levenberg-Marquardt algorithm implemented in function 'nls.lm' from the 'minpack.lm' R package. Notice that the fit to GGamma dsitribution is computationally time consuming (see ?fitGGammaDist for additional information).

Model table with coeficients and goodness-of-fit results: Adj.R.Square, deviance, AIC, R.Cross.val, and rho, as well as, the coefficient covariance matrix.

Robersy Sanchez 01/31/2018

1. Stevens JP. Applied Multivariate Statistics for the Social Sciences. Fifth Edit. Routledge Academic; 2009. 2. [1] R. Sanchez and S. A. Mackenzie, “Information Thermodynamics of Cytosine DNA Methylation,” PLoS One, vol. 11, no. 3, p. e0150427, Mar. 2016.

## The Weilbull distribution is a particular case of GGamma. ## The goodness-of-fit indicators AIC, BIC and R.Cross.val suggest that the ## best fit randomly generated values with Weibull distribution is obtained ## using the Weibull model (in this example). set.seed(123) num.points <- 1000 HD <- GRangesList( sample1 <- makeGRangesFromDataFrame( data.frame(chr = "chr1", start = 1:num.points, end = 1:num.points, strand = '*', hdiv = rweibull(1:num.points, shape = 0.75, scale = 1)), keep.extra.columns = TRUE)) nlms <- nonlinearFitDist(HD, column = 1, verbose = FALSE) nlms2 <- nonlinearFitDist(HD, column = 1, dist.name = "GGamma3P", verbose = FALSE) ## We used the parameter values estimated for "GGamma3P" in the last ## example (nlms2) to generate random values with GGamma disitribution. The ## goodness-of-fit indicators AIC, BIC and R.Cross.val suggest that the ## best fit is obtained for GGamma model. num.points <- 1000 HD <- GRangesList( sample1 <- makeGRangesFromDataFrame( data.frame(chr = "chr1", start = 1:num.points, end = 1:num.points, strand = '*', hdiv = rggamma(num.points, alpha = 0.75, psi = 1.02, scale = 0.97)), keep.extra.columns = TRUE)) nlms3 <- nonlinearFitDist(HD, column = 1, verbose = FALSE) nlms4 <- nonlinearFitDist(HD, column = 1, dist.name = "GGamma3P", verbose = FALSE)

[Package *MethylIT* version 0.3.1 ]