| Initial Generic Functions {cubfits} | R Documentation |
Initial Generic Functions of Codon Usage Bias Fits
Description
Initial generic functions for model fitting/approximation/prediction of cubfits.
Usage
init.function(model = .CF.CT$model[1],
type.p = .CF.CT$type.p[1],
type.Phi = .CF.CT$type.Phi[1],
model.Phi = .CF.CT$model.Phi[1],
init.Phi = .CF.CT$init.Phi[1],
init.fit = .CF.CT$init.fit[1],
parallel = .CF.CT$parallel[1],
adaptive = .CF.CT$adaptive[1])
Arguments
model |
main fitted model. |
type.p |
proposal method for hyper-parameters. |
type.Phi |
proposal method for Phi (true expression values). |
model.Phi |
prior of Phi. |
init.Phi |
initial methods for Phi. |
init.fit |
how is coefficient initialed in |
parallel |
parallel functions. |
adaptive |
method for adaptive MCMC. |
Details
This function mainly takes the options, find the according generic
functions, and assign those functions to .cubfitsEnv.
Those generic functions can be executed accordingly later within functions
for MCMC or multinomial logistic regression such as cubfits(),
cubappr(), and cubpred().
By default, those options are provided by .CF.CT which also
leaves rooms for extensions of more complicated models and further
optimizations.
It is supposed to call this function before running any MCMC or
multinomial logistic regression. This function may affect
cubfits(), cubpred(), cubappr(),
estimatePhi(), and fitMultinom().
-
modelis the main fitting model, currently onlyrocis fully supported. -
type.pis for proposing hyper-parameters in Gibb sampler. Currently,lognormal_fixis suggested where mean 1 is fixed for log normal distribution. Conjugated prior and flat prior exist and are easily available in this step -
type.Phiis for proposing Phi (expression values) in the random walk chain updates. Only,RW_Normis supported. Usually, the acceptance ratio can be adapted within 25% and 50% controlled by.CF.ACifadaptive = simple. -
model.Phiis for the distribution of Phi. Typically, log normal distributionlognormalis assumed. -
init.Phiis a way to initial Phi. Posterior meanPMis recommended which avoid boundary values. -
init.fitis a way of initial coefficients to fit mutation and selection coefficients (\log\muand\Delta tor\omega) invglm(). Optioncurrentmeans theb(log(mu) and Delta.t) of current MCMC iteration is the initial values, whilerandommeansvglm()provides the initial values. -
parallelis a way of parallel methods to speed up code.lapplymeanslapply()is used and no parallel;mclapplymeansmclapply()of parallel is used and good for shared memory machines;task.pullmeanstask.pull()of pbdMPI is used and good for heterogeneous machines;pbdLapplymeanspbdLapply()of pbdMPI is used and good for homogeneous machines. Among those,task.pullis tested thoroughly and is the most reliable and efficient method. -
adaptiveis a way for adaptive MCMC that propose better mixing distributions for random walks of Phi. Thesimplemethod is suggested and only the proposal distribution of Phi (type.Phi = RW_Norm) is adjusted gradually.
Value
Return an invisible object which is a list contain all
generic functions according to the input options.
All functions are also assigned in the .cubfitsEnv
for later evaluations called by MCMC or multinomial logistic regression.
Note
Note that all options are taken default values from the global control
object .CF.CT, so one can utilize/alter the object's values
to adjust those affected functions.
Note that phi.Obs should be scaled to mean 1 before
applying to MCMC.
Author(s)
Wei-Chen Chen wccsnow@gmail.com.
References
https://github.com/snoweye/cubfits/
See Also
.CF.CT, .CF.CT, cubfits(),
cubpred(), and cubappr().
Examples
## Not run:
suppressMessages(library(cubfits, quietly = TRUE))
set.seed(1234)
# Convert data.
reu13.list <- convert.reu13.df.to.list(ex.test$reu13.df)
y.list <- convert.y.to.list(ex.test$y)
n.list <- convert.n.to.list(ex.test$n)
# Get phi.pred.Init
init.function(model = "roc")
fitlist <- fitMultinom(ex.train$reu13.df, ex.train$phi.Obs, ex.train$y,
ex.train$n)
phi.pred.Init <- estimatePhi(fitlist, reu13.list, y.list, n.list,
E.Phi = median(ex.test$phi.Obs),
lower.optim = min(ex.test$phi.Obs) * 0.9,
upper.optim = max(ex.test$phi.Obs) * 1.1)
## End(Not run)