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()
.
-
model
is the main fitting model, currently onlyroc
is fully supported. -
type.p
is for proposing hyper-parameters in Gibb sampler. Currently,lognormal_fix
is suggested where mean 1 is fixed for log normal distribution. Conjugated prior and flat prior exist and are easily available in this step -
type.Phi
is for proposing Phi (expression values) in the random walk chain updates. Only,RW_Norm
is supported. Usually, the acceptance ratio can be adapted within 25% and 50% controlled by.CF.AC
ifadaptive = simple
. -
model.Phi
is for the distribution of Phi. Typically, log normal distributionlognormal
is assumed. -
init.Phi
is a way to initial Phi. Posterior meanPM
is recommended which avoid boundary values. -
init.fit
is a way of initial coefficients to fit mutation and selection coefficients (\log\mu
and\Delta t
or\omega
) invglm()
. Optioncurrent
means theb
(log(mu) and Delta.t) of current MCMC iteration is the initial values, whilerandom
meansvglm()
provides the initial values. -
parallel
is a way of parallel methods to speed up code.lapply
meanslapply()
is used and no parallel;mclapply
meansmclapply()
of parallel is used and good for shared memory machines;task.pull
meanstask.pull()
of pbdMPI is used and good for heterogeneous machines;pbdLapply
meanspbdLapply()
of pbdMPI is used and good for homogeneous machines. Among those,task.pull
is tested thoroughly and is the most reliable and efficient method. -
adaptive
is a way for adaptive MCMC that propose better mixing distributions for random walks of Phi. Thesimple
method 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)