\HeaderA{haplo.em.w}{Wrapper for EM computation of haplotype probabilities, with Progressive Insertion}{haplo.em.w}
\keyword{misc}{haplo.em.w}
\begin{Description}\relax
Wrapper for EM computation of haplotype probabilities, with Progressive Insertion.
\end{Description}
\begin{Usage}
\begin{verbatim}
haplo.em.w(geneSetObj, 
           locus.label = NA, 
           miss.val = c(0, NA), 
           weight = NULL, 
           control = haplo.em.control())
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{geneSetObj}] a geneSet object.
\item[\code{locus.label}] vector of labels for loci.
\item[\code{miss.val}] vector of values that represent missing alleles in geno.
\item[\code{weight}] weights for observations.
\item[\code{control}] list of control parameters. The default is constructed by the
function \code{\LinkA{haplo.em.control}{haplo.em.control}}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Please refer to \code{\LinkA{haplo.em}{haplo.em}} for more details.
\end{Details}
\begin{Value}
list with components:

\begin{ldescription}
\item[\code{converge}] indicator of convergence of the EM algorithm
(1 = converge, 0 = failed).

\item[\code{lnlike}] value of lnlike at last EM iteration (maximum lnlike if converged).

\item[\code{lr}] likelihood ratio statistic to test the final lnlike against the
lnlike that assumes complete linkage equilibrium among all loci
(i.e., haplotype frequencies are products of allele frequencies).

\item[\code{df.lr}] degrees of freedom for likelihood ratio statistic. The df for the
unconstrained final model is the  number of non-zero haplotype frequencies
minus 1, and the df for the null model of complete linkage 
equilibrium is the sum, over all loci, of (number of alleles - 1). The
df for the lr statistic is df[unconstrained] - df[null]. This can
result in negative df, if many haplotypes are estimated to have zero 
frequency, or if a large amount of trimming occurs, when using large
values of min.posterior in the list of control parameters.

\item[\code{hap.prob}] vector of mle's of haplotype probabilities.  The ith
element of hap.prob corresponds to the ith row of 
haplotype.

\item[\code{locus.label}] vector of labels for loci, of length K 
(see definition of input values).

\item[\code{subj.id}] vector of id's for subjects used in the analysis, based on row number
of input geno matrix. If subjects are removed, then their id will be
missing from subj.id.

\item[\code{rows.rem}] now defunct, but set equal to a vector of length 0, to be compatible 
with other functions that check for rows.rem.

\item[\code{indx.subj}] vector for row index of subjects after expanding to all 
possible pairs of haplotypes for each person.  If indx.subj=i, 
then i is the ith row of  geno.  If the ith 
subject has n possible pairs of haplotypes that correspond 
to their marker genotype, then i is repeated n times.

\item[\code{nreps}] vector for the count of haplotype pairs that map to
each subject's marker genotypes.

\item[\code{max.pairs}] vector of maximum number of pairs of haplotypes per subject that are
consistent with their marker data in the matrix geno. The
length of max.pairs  = nrow(geno). This vector is computed by  
geno.count.pairs.

\item[\code{hap1code}] vector of codes for each subject's first haplotype.
The values in hap1code are the row numbers of the unique
haplotypes in the returned matrix haplotype.

\item[\code{hap2code}] similar to hap1code, but for each subject's second haplotype.

\item[\code{post}] vector of posterior probabilities of pairs of haplotypes for 
a person, given their marker phenotypes.

\item[\code{haplotype}] matrix of unique haplotypes. Each row represents a unique 
haplotype, and the number of columns is the number of loci.

\item[\code{control}] list of control parameters for algorithm. See haplo.em.control

\end{ldescription}
\end{Value}
\begin{Note}\relax
~~further notes~~
\end{Note}
\begin{Author}\relax
Weiliang Qiu \email{stwxq@channing.harvard.edu}, Ross Lazarus \email{ross.lazarus@channing.harvard.edu}
\end{Author}
\begin{References}\relax
~put references to the literature/web site here ~
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{haplo.scan.w}{haplo.scan.w}}, \code{\LinkA{haplo.score.slide.w}{haplo.score.slide.w}}, \code{\LinkA{haplo.score.w}{haplo.score.w}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--    or do  help(data=index)  for the standard data sets.

## The function is currently defined as
"haplo.em.w"
\end{ExampleCode}
\end{Examples}

