Type: | Package |
Title: | Coupled Hidden Markov Models |
Version: | 0.1.1 |
Description: | An exact and a variational inference for coupled Hidden Markov Models applied to the joint detection of copy number variations. |
Depends: | R (≥ 3.1.0) |
Imports: | mclust |
License: | GPL-2 |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 6.0.1 |
URL: | http://github.com/julieaubert/CHMM |
BugReports: | http://github.com/julieaubert/CHMM/issues |
NeedsCompilation: | yes |
Packaged: | 2017-09-29 15:08:32 UTC; aubert |
Author: | Xiaoqiang Wang [aut], Julie Aubert [aut, cre] |
Maintainer: | Julie Aubert <julie.aubert@agroparistech.fr> |
Repository: | CRAN |
Date/Publication: | 2017-09-29 17:15:05 UTC |
Backward step
Description
Backward step
Usage
BackwardR(Fpr, trsVec, nb.states)
Arguments
Fpr |
Fpr. |
trsVec |
a vector of state transition probabilities. |
nb.states |
an integer specifying the numbers of states. |
Perform exact inference of coupled hidden markov models.
Description
Perform exact inference of coupled hidden markov models.
Usage
CHMM_EM(X, nb.states, S, omega, meth.init = "mclust", var.equal = TRUE,
itmax = 500, threshold = 1e-07)
Arguments
X |
a data matrix of observations. Columns correspond to individuals. |
nb.states |
a integer specifying the numbers of states. |
S |
a matrix of similarity between individuals. |
omega |
a value of omega. |
meth.init |
a string specifying the initialization method ("mclust" or "kmeans"). The default method is "mclust". |
var.equal |
a logical variable indicating whether to treat the variances as being equal. |
itmax |
an integer specifying the maximal number of iterations for the EM algorithm. |
threshold |
a value for the threshold used for the stopping criteria. |
Value
a list of 10 components
postPr
a list containing for each series the posterior probabilities.
initGb
a numeric specifying the initial state probabilities.
transGb
a matrix of the state transition probabilities.
emisGb
a list containing for each series the emission probabilities.
esAvg
a numeric of the estimated mean for each state.
esVar
a numeric of the estimated variance for each state.
ID.K
a matrix containing all combination of possible state for nbI series.
loglik
a numeric with the value of the loglikelihood.
RSS
a numeric corresponding to the Residuals Sum of Squares.
iterstop
an integer corresponding to the total number of iterations.
References
Wang, X., Lebarbier, E., Aubert, J. and Robin, S., Variational inference for coupled Hidden Markov Models applied to the joint detection of copy number variations.
Perform variational inference of coupled Hidden Markov Models.
Description
Perform variational inference of coupled Hidden Markov Models.
Usage
CHMM_VEM(X, nb.states, S = NULL, omega = 0.7, meth.init = "mclust",
var.equal = TRUE, itmax = 500, threshold = 1e-07)
Arguments
X |
a data matrix of observations. Columns correspond to individuals. |
nb.states |
a integer specifying the numbers of states. |
S |
a matrix of similarity between individuals. |
omega |
a value of omega. |
meth.init |
a string specifying the initialization method ("mclust" or "kmeans"). The default method is "mclust". |
var.equal |
a logical variable indicating whether to treat the variances as being equal. |
itmax |
an integer specifying the maximal number of iterations for the EM algorithm. |
threshold |
a value for the threshold used for the stopping criteria. |
Value
a list of 9 components
postPr
a list containing for each series the posterior probabilities.
initPr
a numeric specifying the initial state probabilities.
transPr
a matrix of the state transition probabilities.
esAvg
a numeric of the estimated mean for each state.
esVar
a numeric of the estimated variance for each state.
emisPr
a list containing for each series the emission probabilities.
emisPrW
a list containing for each series the emission probabilities taking into account for the dependency structure.
RSS
a numeric corresponding to the Residuals Sum of Squares.
iterstop
an integer corresponding to the total number of iterations.
References
Wang, X., Lebarbier, E., Aubert, J. and Robin, S., Variational inference for coupled Hidden Markov Models applied to the joint detection of copy number variations.
Emis.Gauss
Description
Emis.Gauss
Usage
Emis.Gauss(X, esAvg, esVar)
Arguments
X |
data matrix of observations. |
esAvg |
a numeric of the estimated mean for each state. |
esVar |
a numeric of the estimated variance for each state. |
Emis.LRR
Description
Emis.LRR
Usage
Emis.LRR(X, esAvg, esVar, weight = 0.05)
Arguments
X |
data matrix of observations. |
esAvg |
a numeric of the estimated mean for each state. |
esVar |
a numeric of the estimated variance for each state. |
weight |
weight. |
EmisGb.Gauss
Description
EmisGb.Gauss
Usage
EmisGb.Gauss(X, esAvgGb, esVarGb)
Arguments
X |
data matrix of observations. |
esAvgGb |
a matrix of |
esVarGb |
a matrix of |
Wl Internal function calculating Wl.
Description
Wl Internal function calculating Wl.
Usage
ExpGrid(nb.states, nbI)
Arguments
nb.states |
an integer specifying the numbers of states. |
nbI |
an integer specifying the number of series. |
Value
a matrix containing all combination of possible state for nbI series.
Forward step
Description
Forward step
Usage
ForwardR(emisVec, initPr, trsVec)
Arguments
emisVec |
a vector of emission probabilities. |
initPr |
a vector specifying initial state probabilities. |
trsVec |
a vector of state transition probabilities. |
Wl Internal function calculating Wl.
Description
Wl Internal function calculating Wl.
Usage
Wl(ID.K, S, omega)
Arguments
ID.K |
as.matrix(expand.grid(list(c(1:nbI),c(1:nb.states))). |
S |
a matrix of similarities between individuals. |
omega |
. |
Value
Wl.
Summarize the results of the coupled HMM.
Description
Summarize the results of the coupled HMM.
Usage
clusterseg(x)
Arguments
x |
a matrix of status. Columns corresponds to series (individuals). |
Value
a data.frame with 4 columns
sample
name of the sample (series).
posbegin
beginning position.
posend
ending position.
status
status.
Perform inference of coupled hidden markov models.
Description
Perform inference of coupled hidden markov models.
Usage
coupledHMM(X, nb.states = 3, S = NULL, omega.list = c(0.3, 0.7, 0.9),
var.equal = TRUE, exact = FALSE, meth.init = "mclust", viterbi = TRUE,
itmax = 500, threshold = 1e-07)
Arguments
X |
a matrix of observations. Columns correspond to series (individuals). |
nb.states |
a integer specifying the numbers of states. |
S |
a matrix of similarity between individuals. |
omega.list |
a vector of omega values. |
var.equal |
a logical variable indicating whether to treat the variances as being equal (var.equal = TRUE). |
exact |
a logical variable indicating whether to use VEM (exact = FALSE) or EM (exact = TRUE) algorithm for the inference of the model. |
meth.init |
a string specifying the initialization method ("mclust" or "kmeans") for the (V)-EM algorithm. The default method is "mclust". |
viterbi |
a logical variable indicating whether to use Maximum A Posteriori method (FALSE) or Viterbi algorithm (TRUE, by default) for recovering the most likely path. |
itmax |
an integer specifying the maximal number of iterations for the CHMM_(V)EM algorithm. |
threshold |
a value for the threshold used for the stopping criteria for the CHMM_(V)EM algorithm. |
Value
A list of 4 objets.
omega
an integer corresponding to the selected value among the omega.list.
model
a list corresponding to the output of the
CHMM-EM
orCHMM-VEM
function for the selected model.status
a matrix with status associated to each series in column and each position in row.
RSS.omega
a dataframe with omega values and the associated Residuals Sum of Squares.
References
Wang, X., Lebarbier, E., Aubert, J. and Robin, S., Variational inference for coupled Hidden Markov Models applied to the joint detection of copy number variations.
See Also
Examples
data(toyexample)
# Variational inference of a coupled hidden Markov Chains
resCHMM <- coupledHMM(X = toydata, nb.states = 3, S = cor(toystatus),
omega.list = c(0.3, 0.5, 0.7, 0.9))
# Breakpoints positions and status of segments
info <- clusterseg(resCHMM$status)
# head(info)
Initialization step of the CHMM_EM
function.
Description
Initialization step of the CHMM_EM
function.
Usage
init.EM(X, nb.states, meth.init, var.equal, nbI, nbT)
Arguments
X |
a matrix of observations. Columns correspond to series (individuals). |
nb.states |
an integer specifying the numbers of states. |
meth.init |
a string specifying the initialization method ("mclust" or "kmeans"). The default method is "mclust". |
var.equal |
a logical variable indicating whether to treat the variances as being equal (TRUE, value by default) or not (FALSE). |
nbI |
an integer specifying the number of series. |
nbT |
an integer specifying the length of one series. |
Details
By default, an initialization with the meth.init="mclust"
is performed with homogeneous variances.
Value
A list of 6 objects.
esAvgGb
a matrix of
nbK
(nb.states^nbI) rows andnbI
columns of estimated mean.esVarGb
a matrix of
nbK
(nb.states^nbI) rows andnbI
columns of estimated variance.esAvg
a numeric of the estimated mean for each state.
esVar
a numeric of the estimated variance for each state.
transGb
a matrix of the state transition probabilities.
initGb
a numeric specifying the initial state probabilities.
See Also
Initialization step of the CHMM_VEM
function.
Description
Initialization step of the CHMM_VEM
function.
Usage
init.VEM(X, nb.states, meth.init, var.equal, nbI, nbT)
Arguments
X |
a matrix of observations. Columns correspond to series (individuals). |
nb.states |
an integer specifying the numbers of states. |
meth.init |
a string specifying the initialization method ("mclust" or "kmeans"). The default method is "mclust". |
var.equal |
a logical variable indicating whether to treat the variances as being equal (TRUE, value by default) or not (FALSE). |
nbI |
an integer specifying the number of series. |
nbT |
an integer specifying the length of one series. |
Value
A list containing the parameters of the model
esAvg
a numeric of the estimated mean for each state.
esVar
a numeric of the estimated variance for each state.
transPr
a matrix of the state transition probabilities
postPr
a list containing for each series the posterior probabilities.
initPr
a numeric specifying the initial state probabilities
.
Toy example - observations for 5 correlated samples.
Description
A matrix containing the observations for the 1,000 positions of 5 correlated samples.
Format
A simulated matrix with 1000 rows and 5 columns. Each column is a series
Examples
data(toyexample)
# Variational inference of a coupled hidden Markov Chains
resCHMM <- coupledHMM(X = toydata, nb.states = 3, S = cor(toystatus),
omega.list = c(0.3, 0.5, 0.7, 0.9))
# Breakpoints positions and status of segments
info <- clusterseg(resCHMM$status)
# head(info)
Toy example - status for 5 correlated samples.
Description
A matrix containing the hidden status for the 1,000 positions of 5 correlated samples.
Format
A matrix of the hidden status corresponding to the toydata
matrix.
Implementation of the Viterbi algorithm
Description
Implementation of the Viterbi algorithm
Usage
viterbi_algo(emisPr, transPr, initPr)
Arguments
emisPr |
a matrix of emission probabilities for the considering series. |
transPr |
a matrix of state transition probabilities. |
initPr |
a vector specifying initial state probabilities. |
Value
path |
the most likely path (state sequence). |