Description Usage Arguments Value Author(s) See Also Examples
The function bpr_optimize minimizes the negative log likelihood
of the BPR function. Since it cannot be evaluated analytically, an
optimization procedure is used. The optim
packages is
used for performing optimization.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | bpr_optim(x, ...)
## S3 method for class 'list'
bpr_optim(x, w = NULL, basis = NULL, fit_feature = "RMSE",
cpg_dens_feat = TRUE, lambda = 1/2, opt_method = "CG",
opt_itnmax = 100, is_parallel = TRUE, no_cores = NULL, ...)
## S3 method for class 'matrix'
bpr_optim(x, w = NULL, basis = NULL,
fit_feature = "RMSE", cpg_dens_feat = TRUE, lambda = 1/2,
opt_method = "CG", opt_itnmax = 100, ...)
bpr_optim_fast(x, H, w = NULL, lambda = 1/6, opt_method = "CG",
opt_itnmax = 100, is_parallel = TRUE, no_cores = NULL, ...)
|
x |
The input object, either a |
... |
Additional parameters. |
w |
A vector of parameters (i.e. coefficients of the basis functions) |
basis |
A 'basis' object. E.g. see |
fit_feature |
Return additional feature on how well the profile fits the methylation data. Either NULL for ignoring this feature or one of the following: 1) "RMSE" for returning the fit of the profile using the RMSE as measure of error or 2) "NLL" for returning the fit of the profile using the Negative Log Likelihood as measure of error. |
cpg_dens_feat |
Logical, whether to return an additional feature for the CpG density across the promoter region. |
lambda |
The complexity penalty coefficient for ridge regression. |
opt_method |
The optimization method to be used. See
|
opt_itnmax |
Optional argument giving the maximum number of iterations
for the corresponding method. See |
is_parallel |
Logical, indicating if code should be run in parallel. |
no_cores |
Number of cores to be used, default is max_no_cores - 2. |
H |
The pre-computed design matrix for fast computations. |
Depending on the input object x
:
If x
is
a list
: An object containing the following elements:
W_opt
: An Nx(M+1) matrix with the optimized
parameter values. Each row of the matrix corresponds to each element of the
list x. The columns are of the same length as the parameter vector w (i.e.
number of basis functions).
Mus
: An N x M matrix with the
RBF centers if basis object is create_rbf_object
, otherwise
NULL.
basis
: The basis object.
w
: The
initial values of the parameters w.
If x
is a
matrix
: An object containing the following elements:
w_opt
: Optimized values for the coefficient vector
w. The length of the result is the same as the length of the vector w.
basis
: The basis object.
If calling
bpr_optim_fast
just the optimal weight matrix W_opt.
C.A.Kapourani C.A.Kapourani@ed.ac.uk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # Example of optimizing parameters for synthetic data using default values
data <- meth_data
out_opt <- bpr_optim(x = data, is_parallel = FALSE, opt_itnmax = 10)
#-------------------------------------
# Example of optimizing parameters for synthetic data using 3 RBFs
ex_data <- meth_data
basis <- create_rbf_object(M=3)
out_opt <- bpr_optim(x = ex_data, is_parallel = FALSE, basis = basis,
opt_itnmax = 10)
#-------------------------------------
# Example of of specific promoter region using 2 RBFs
basis <- create_rbf_object(M=2)
w <- c(0.1, 0.1, 0.1)
data <- meth_data[[1]]
out_opt <- bpr_optim(x = data, w = w, basis = basis, fit_feature = "NLL",
opt_itnmax = 10)
# Example of optimizing parameters for synthetic data using 3 RBFs
ex_data <- meth_data
basis <- create_rbf_object(M=3)
H <- list()
for (i in 1:length(ex_data)){
H[[i]] <- design_matrix(x = basis, obs = as.vector(ex_data[[i]][, 1]))$H
}
w <- rep(0.5, basis$M + 1)
out_opt <- bpr_optim_fast(x = ex_data, H = H, w = w, is_parallel = FALSE,
opt_itnmax = 10)
#-------------------------------------
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.