|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.sequenceScores.statisticalModels.trainable.hmm.HMMFactory
public class HMMFactory
This class allows to create some frequently used HMMs.
Nested Class Summary | |
---|---|
static class |
HMMFactory.HMMType
This enum defines some standard architecture of profile HMMs. |
static class |
HMMFactory.PseudoTransitionElement
This class is used as place holder for a later BasicHigherOrderTransition.AbstractTransitionElement . |
Constructor Summary | |
---|---|
HMMFactory()
|
Method Summary | |
---|---|
static AbstractHMM |
createErgodicHMM(HMMTrainingParameterSet pars,
int order,
double ess,
double selfTranistionPart,
double expectedSequenceLength,
Emission... emission)
This method creates an ergodic, i.e. a completely connected, HMM using the given emissions. |
static AbstractHMM |
createProfileHMM(MaxHMMTrainingParameterSet trainingParameterSet,
double[][] initFromTo,
boolean likelihood,
int order,
int numLayers,
AlphabetContainer con,
double ess,
boolean conditionalMain,
boolean closeCircle,
double[][] conditionInitProbs,
boolean insertUniform)
Creates a new profile HMM for a given architecture and number of layers. |
static AbstractHMM |
createProfileHMM(MaxHMMTrainingParameterSet trainingParameterSet,
double[][] initFromTo,
boolean likelihood,
int order,
int numLayers,
AlphabetContainer con,
double ess,
boolean conditionalMain,
int joiningStates,
double[][] conditionInitProbs,
boolean insertUniform)
Creates a new profile HMM for a given architecture and number of layers. |
static AbstractHMM |
createProfileHMM(MaxHMMTrainingParameterSet trainingParameterSet,
HMMFactory.HMMType type,
boolean likelihood,
int order,
int numLayers,
AlphabetContainer con,
double ess,
boolean conditionalMain,
boolean closeCircle,
double[][] conditionInitProbs)
Creates a new profile HMM for a given architecture and number of layers. |
static AbstractHMM |
createPseudoErgodicHMM(HMMTrainingParameterSet pars,
double ess,
double selfTranistionPart,
double finalTranistionPart,
AlphabetContainer con,
int numStates,
boolean insertUniform)
Creates an HMM with numStates+1 states, where numStates emitting build a clique and each of those states is connected to the absorbing silent final state. |
static AbstractHMM |
createSunflowerHMM(HMMTrainingParameterSet pars,
AlphabetContainer con,
double ess,
int expectedSequenceLength,
boolean startCentral,
int... motifLength)
This method creates a first order sunflower HMM. |
static AbstractHMM |
createSunflowerHMM(HMMTrainingParameterSet pars,
AlphabetContainer con,
double ess,
int expectedSequenceLength,
boolean startCentral,
PhyloTree[] t,
double[] motifProb,
int[] motifLength)
This method creates a first order sunflower HMM allowing phylogenetic emissions. |
static TransitionElement[] |
createTransition(double[][] hyperParams,
ArrayList<HMMFactory.PseudoTransitionElement> list)
Creates the real TransitionElement s that can be used to create the HMM. |
static HashMap<String,String> |
getHashMap()
This method returns a HashMap that can be used in
AbstractHMM.getGraphvizRepresentation(java.text.NumberFormat, de.jstacs.data.DataSet, double[], HashMap)
to create a Graphviz representation of the AbstractHMM |
static Pair<double[][],double[]> |
propagateESS(double ess,
ArrayList<HMMFactory.PseudoTransitionElement> list)
Propagates the ess for an HMM with absorbing states. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HMMFactory()
Method Detail |
---|
public static AbstractHMM createErgodicHMM(HMMTrainingParameterSet pars, int order, double ess, double selfTranistionPart, double expectedSequenceLength, Emission... emission) throws Exception
pars
- the parameter determining the training procedure of the HMMorder
- the Markov order of the HMMess
- the ess to be used for the HMMselfTranistionPart
- the a-priori probability of any self transitionexpectedSequenceLength
- the expected length of sequences to be modeledemission
- the emissions of the states
Exception
- if the HMM can not be created properlypublic static AbstractHMM createPseudoErgodicHMM(HMMTrainingParameterSet pars, double ess, double selfTranistionPart, double finalTranistionPart, AlphabetContainer con, int numStates, boolean insertUniform) throws Exception
numStates+1
states, where numStates
emitting build a clique and each of those states is connected to the absorbing silent final state.
Such an HMM models the length of the input sequences, i.e. summing the likelihood over all input sequences (of different lengths) will give 1,
whereas an ergodic HMM does not model the input length and summing the likelihood of each possible input length will give 1.
pars
- the parameters of the algorithm for learning the model parametersess
- the equivalent sample size, is propagated between states to obtain consistent hyper-parameters for all parametersselfTranistionPart
- the a-priori probability of a self transition for each emitting statefinalTranistionPart
- the a-priori probability of the transition to the final state from each emitting statecon
- the AlphabetContainer
of the HMMnumStates
- the number of emitting statesinsertUniform
- if true
the emitting states will use UniformEmission
s
numStates+1
states, where numStates
emitting build a clique and each of those states is connected to the absorbing silent final state
Exception
- if the HMM could not be created properlypropagateESS(double, ArrayList)
public static AbstractHMM createSunflowerHMM(HMMTrainingParameterSet pars, AlphabetContainer con, double ess, int expectedSequenceLength, boolean startCentral, int... motifLength) throws Exception
pars
- the parameter determining the training procedure of the HMMcon
- the AlphabetContainer
of the HMMess
- the equivalent sample size (ess) of this modelexpectedSequenceLength
- the expected sequence length to be modeled; this parameter is used to determine the priorstartCentral
- a switch for deciding between starting in the central state or in all statesmotifLength
- the length of the motifs building the petals of the sunflower
Exception
- if the HMM can not be created properlycreateSunflowerHMM(HMMTrainingParameterSet, AlphabetContainer, double, int, boolean, PhyloTree[], double[], int[])
public static AbstractHMM createSunflowerHMM(HMMTrainingParameterSet pars, AlphabetContainer con, double ess, int expectedSequenceLength, boolean startCentral, PhyloTree[] t, double[] motifProb, int[] motifLength) throws Exception
pars
- the parameter determining the training procedure of the HMMcon
- the AlphabetContainer
of the HMMess
- the equivalent sample size (ess) of this modelexpectedSequenceLength
- the expected sequence length to be modeled; this parameter is used to determine the priorstartCentral
- a switch for deciding between starting in the central state or in all statest
- an array of length two that contains a PhyloTree
for the background and the motif, can be null
than a normal sunflower HMM is returnedmotifProb
- the a-priori probabilities for each motif, i.e., the a-priori probabilities for the edges from the central node to the first motif statesmotifLength
- the length of the motifs building the petals of the sunflower
Exception
- if the HMM can not be created properlypublic static AbstractHMM createProfileHMM(MaxHMMTrainingParameterSet trainingParameterSet, HMMFactory.HMMType type, boolean likelihood, int order, int numLayers, AlphabetContainer con, double ess, boolean conditionalMain, boolean closeCircle, double[][] conditionInitProbs) throws Exception
trainingParameterSet
- the parameters of the algorithm for learning the model parameterstype
- the type of the HMM, i.e., its architecturelikelihood
- if true
, the likelihood is considered as score of a sequence, and the probability of the Viterbi path otherwiseorder
- the order of the HMM, i.e., the number of previous states that are considered for a transition probabilitynumLayers
- the number of layers of the profile HMMcon
- the alphabet of the profile HMMess
- the equivalent sample size, is propagated between states to obtain consistent hyper-parameters for all parametersconditionalMain
- if true
, the match states have ReferenceSequenceDiscreteEmission
s, and DiscreteEmission
s otherwisecloseCircle
- if true
the circle from end to initial state is closed, i.e., the HMM can be traversed several timesconditionInitProbs
- the hyper-parameters for initializing the match states if conditionalMain
is true. May be null
for using the hyper-parameters of the prior
Returns:
the profile HMM
Throws:
Exception
- if the profile HMM could not be created
createProfileHMM
public static AbstractHMM createProfileHMM(MaxHMMTrainingParameterSet trainingParameterSet,
double[][] initFromTo,
boolean likelihood,
int order,
int numLayers,
AlphabetContainer con,
double ess,
boolean conditionalMain,
boolean closeCircle,
double[][] conditionInitProbs,
boolean insertUniform)
throws Exception
- Creates a new profile HMM for a given architecture and number of layers.
- Parameters:
trainingParameterSet
- the parameters of the algorithm for learning the model parametersinitFromTo
- hyper-parameters of the transition from each state (first dimension) of the current layer to each other state in the same layer (first three entries of the second dimension)
and the next layer (next three entries in the second dimension). If a hyper-parameter is set to Double.NaN
, the corresponding transition is not allowedlikelihood
- if true
, the likelihood is considered as score of a sequence, and the probability of the Viterbi path otherwiseorder
- the order of the HMM, i.e., the number of previous states that are considered for a transition probabilitynumLayers
- the number of layers of the profile HMMcon
- the alphabet of the profile HMMess
- the equivalent sample size, is propagated between states to obtain consistent hyper-parameters for all parametersconditionalMain
- if true
, the match states have ReferenceSequenceDiscreteEmission
s, and DiscreteEmission
s otherwisecloseCircle
- if true
the circle from end to initial state is closed, i.e., the HMM can be traversed several timesconditionInitProbs
- the hyper-parameters for initializing the match states if conditionalMain
is true. May be null
for using the hyper-parameters of the prior
insertUniform
- if true
the insert states will use UniformEmission
s
Returns:
the profile HMM
Throws:
Exception
- if the profile HMM could not be created
createProfileHMM
public static AbstractHMM createProfileHMM(MaxHMMTrainingParameterSet trainingParameterSet,
double[][] initFromTo,
boolean likelihood,
int order,
int numLayers,
AlphabetContainer con,
double ess,
boolean conditionalMain,
int joiningStates,
double[][] conditionInitProbs,
boolean insertUniform)
throws Exception
- Creates a new profile HMM for a given architecture and number of layers.
- Parameters:
trainingParameterSet
- the parameters of the algorithm for learning the model parametersinitFromTo
- hyper-parameters of the transition from each state (first dimension) of the current layer to each other state in the same layer (first three entries of the second dimension)
and the next layer (next three entries in the second dimension). If a hyper-parameter is set to Double.NaN
, the corresponding transition is not allowedlikelihood
- if true
, the likelihood is considered as score of a sequence, and the probability of the Viterbi path otherwiseorder
- the order of the HMM, i.e., the number of previous states that are considered for a transition probabilitynumLayers
- the number of layers of the profile HMMcon
- the alphabet of the profile HMMess
- the equivalent sample size, is propagated between states to obtain consistent hyper-parameters for all parametersconditionalMain
- if true
, the match states have ReferenceSequenceDiscreteEmission
s, and DiscreteEmission
s otherwisejoiningStates
- the number of states used in the joining arc, if not positive the profile HMM does not contain any joining states (i.e. the circle is not closed)conditionInitProbs
- the hyper-parameters for initializing the match states if conditionalMain
is true. May be null
for using the hyper-parameters of the prior
insertUniform
- if true
the insert states will use UniformEmission
s
Returns:
the profile HMM
Throws:
Exception
- if the profile HMM could not be created
createTransition
public static TransitionElement[] createTransition(double[][] hyperParams,
ArrayList<HMMFactory.PseudoTransitionElement> list)
- Creates the real
TransitionElement
s that can be used to create the HMM.
- Parameters:
hyperParams
- the hyper-parameters for HMMFactory.PseudoTransitionElement
from the list
list
- a list of HMMFactory.PseudoTransitionElement
that is used to create the HMM
- Returns:
- an array of
TransitionElement
s that correspond to all entries of the list
- See Also:
propagateESS(double, ArrayList)
propagateESS
public static Pair<double[][],double[]> propagateESS(double ess,
ArrayList<HMMFactory.PseudoTransitionElement> list)
- Propagates the
ess
for an HMM with absorbing states.
- Parameters:
ess
- the equivalent sample size of the HMMlist
- a list of HMMFactory.PseudoTransitionElement
that is used to create the HMM
- Returns:
- a
Pair
, which contains as first element the hyper-parameters for HMMFactory.PseudoTransitionElement
from the list
, and as second element the ess of each state
getHashMap
public static HashMap<String,String> getHashMap()
- This method returns a
HashMap
that can be used in
AbstractHMM.getGraphvizRepresentation(java.text.NumberFormat, de.jstacs.data.DataSet, double[], HashMap)
to create a Graphviz representation of the AbstractHMM
- Returns:
- a
HashMap
that can be used to create a Graphviz representation - See Also:
AbstractHMM.getGraphvizRepresentation(java.text.NumberFormat, de.jstacs.data.DataSet, double[], HashMap)
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD