Takes in a copy number profile and segments it into predicted regions of equal copy number, and assigns a biologically motivated copy number state to each region using a Hidden Markov Model (HMM). This is an extension to the HMM described in Shah et al., 2006.
1 2  HMMsegment(correctOut, param = NULL, autosomes = NULL,
maxiter = 50, getparam = FALSE, verbose = TRUE)

correctOut 
Output value from 
param 
If none is provided, will generate a reasonable set of parameters based on the input data, which can optionally be returned for inspection and manual adjustment by setting 'getparam' to TRUE. See Details for more information on parameters. A matrix with parameters values in columns for each state in rows:

autosomes 
Array of LOGICAL values corresponding to the 'chr' argument where an element is TRUE if the chromosome is an autosome, otherwise FALSE. If not provided, will automatically set the following chromosomes to false: "X", "Y", "23", "24", "chrX", chrY", "M", "MT", "chrM". 
maxiter 
The maximum number of iterations allows for the MaximumExpectation algorithm, reduce to decrease running time at the expense of robustness. 
getparam 
If TRUE, generates and returns parameters without running segmentation. 
verbose 
Set to FALSE if messages are not desired 
HMMsegment
is a two stage algorithm that first runs an
ExpectationMaximization algorithm to find the optimal set of parameters
based on suggested parameter inputs, and allowed flexibilities. After
iteratively finding the optimal parameters, the actual segmentation of the
data is conducted with the Viterbi algorithm, finally output segmented
states. This is an extension to the hidden Markov model described in Shah
et al., 2006.
Parameters are divided into two main categories:
Initial parameters: e, mu, lambda, nu, kappa
Flexibility parameters: strength, m, eta, gamma, S
Where initial parameters are treated as starting suggestions for the parameter optimization algorithm, and flexibility parameters (hyperparameters) define how much the initial parameters are allowed to deviate during the search for the optimal parameters.
With a good copy number dataset, in theory, given enough flexibility, the algorithm should always find a similar set of optimal parameters regardless of initial parameters (although running times will vary).
If for some reason you wish to manually set the parameters for the final segmentation process, one should tune all flexibility parameters to minimal values. For example, if you wish to increase the length of segments, you could set:
1 2 3  param$e < 0.9999999999999999
param$strength < 1e30

Which suggests that segments should be very long, and gives minimal to nonexistant flexibility to your suggestion.
See vignette for diagrammed example:
1 2  vignette("HMMcopy")

A list object containing multiple values, although in practice only the state assigned to each copy number value in 'states' and the segments of nonoverlapping states in 'segs' are of interest.
By default, there are 6 states, which in a diploid sample corresponds to the following chromosomal copies and biological state:
<=0 copies, homozogous deletion
1 copy, heterozogous deletion
2 copies, neutral
3 copies, gain
4 copies, amplification
>=5 copies, high level amplification
The full list of output is as follows:
The state assigned to each copy number value
Nonoverlapping segments and medians of each segment
Optimal median of of copy numbers in state
Optimal precision of copy numbers in state
Optimal state distribution
The likelihood values of each EM algorithm iteration
Posterior marginals (responsibilities) for each position and state
Daniel Lai, Gavin Ha, Sohrab Shah
Sohrab P Shah, Xiang Xuan, Ron J DeLeeuw, Mehrnoush Khojasteh, Wan L Lam, Raymond Ng, and Kevin P Murphy. Integrating copy number polymorphisms into array cgh analysis using a robust hmm. Bioinformatics, 22(14):e4319, Jul 2006.
correctReadcount
, to correct the readcounts prior to
segmentation and classification for better results.
1 2  data(tumour) # Load tumour_copy
tumour_segments < HMMsegment(tumour_copy)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.