de.jstacs.scoringFunctions.directedGraphicalModels
Class MutableMarkovModelScoringFunction

java.lang.Object
  extended by de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction
      extended by de.jstacs.scoringFunctions.directedGraphicalModels.BayesianNetworkScoringFunction
          extended by de.jstacs.scoringFunctions.directedGraphicalModels.MutableMarkovModelScoringFunction
All Implemented Interfaces:
InstantiableFromParameterSet, Mutable, NormalizableScoringFunction, SamplingScoringFunction, ScoringFunction, Storable, Cloneable

public class MutableMarkovModelScoringFunction
extends BayesianNetworkScoringFunction
implements Mutable, SamplingScoringFunction

This class implements a AbstractNormalizableScoringFunction for an inhomogeneous Markov model. The modeled length can be modified which might be very important for de-novo motif discovery.

Author:
Jan Grau, Jens Keilwagen

Field Summary
 
Fields inherited from class de.jstacs.scoringFunctions.directedGraphicalModels.BayesianNetworkScoringFunction
ess, isTrained, logNormalizationConstant, numFreePars, nums, order, parameters, plugInParameters, structureMeasure, trees
 
Fields inherited from class de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction
alphabets, length, r
 
Fields inherited from interface de.jstacs.scoringFunctions.ScoringFunction
UNKNOWN
 
Constructor Summary
MutableMarkovModelScoringFunction(AlphabetContainer alphabet, int length, double ess, boolean plugInParameters, InhomogeneousMarkov structureMeasure)
          This constructor creates an instance without any prior for the modeled length.
MutableMarkovModelScoringFunction(AlphabetContainer alphabet, int length, double ess, boolean plugInParameters, InhomogeneousMarkov structureMeasure, DurationScoringFunction lengthPenalty)
          This constructor creates an instance with an prior for the modeled length.
MutableMarkovModelScoringFunction(AlphabetContainer alphabet, int length, double ess, boolean plugInParameters, int order, DurationScoringFunction lengthPenalty)
          This constructor creates an instance with an prior for the modeled length.
MutableMarkovModelScoringFunction(StringBuffer xml)
          The standard constructor for the interface Storable.
 
Method Summary
protected  void fromXML(StringBuffer source)
          This method is called in the constructor for the Storable interface to create a scoring function from a StringBuffer.
 double getLogPriorTerm()
          This method computes a value that is proportional to NormalizableScoringFunction.getEss() * NormalizableScoringFunction.getLogNormalizationConstant() + Math.log( prior ) where prior is the prior for the parameters of this model.
 int getOrder()
          Returns the order of the inhomogeneous Markov model.
 int[][] getSamplingGroups(int parameterOffset)
          Returns groups of indexes of parameters that shall be drawn together in a sampling procedure
 boolean modify(int offsetLeft, int offsetRight)
          Manually modifies the model.
 StringBuffer toXML()
          This method returns an XML representation as StringBuffer of an instance of the implementing class.
 
Methods inherited from class de.jstacs.scoringFunctions.directedGraphicalModels.BayesianNetworkScoringFunction
addGradientOfLogPriorTerm, clone, createTrees, getCurrentParameterSet, getCurrentParameterValues, getEss, getInstanceName, getLogNormalizationConstant, getLogPartialNormalizationConstant, getLogScore, getLogScoreAndPartialDerivation, getNumberOfParameters, getPositionDependentKMerProb, getPositionForParameter, getPWM, getSizeOfEventSpaceForRandomVariablesOfParameter, initializeFunction, initializeFunctionRandomly, isInitialized, precomputeNormalization, setParameters, setPlugInParameters, toString
 
Methods inherited from class de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction
getAlphabetContainer, getInitialClassParam, getLength, getLogScore, getLogScoreAndPartialDerivation, getNumberOfRecommendedStarts, getNumberOfStarts, isNormalized, isNormalized
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.jstacs.scoringFunctions.NormalizableScoringFunction
addGradientOfLogPriorTerm, getEss, getInitialClassParam, getLogNormalizationConstant, getLogPartialNormalizationConstant, getSizeOfEventSpaceForRandomVariablesOfParameter, isNormalized
 
Methods inherited from interface de.jstacs.scoringFunctions.ScoringFunction
clone, getAlphabetContainer, getCurrentParameterValues, getInstanceName, getLength, getLogScore, getLogScore, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getNumberOfParameters, getNumberOfRecommendedStarts, initializeFunction, initializeFunctionRandomly, isInitialized, setParameters
 

Constructor Detail

MutableMarkovModelScoringFunction

public MutableMarkovModelScoringFunction(AlphabetContainer alphabet,
                                         int length,
                                         double ess,
                                         boolean plugInParameters,
                                         int order,
                                         DurationScoringFunction lengthPenalty)
                                  throws Exception
This constructor creates an instance with an prior for the modeled length.

Parameters:
alphabet - the AlphabetContainer of the MutableMarkovModelScoringFunction
length - the initial length of the modeled sequences
ess - the equivalent sample size
plugInParameters - a switch whether to use plug-in parameters of not
order - the order of the Markov model
lengthPenalty - the prior on the modeled sequence length
Throws:
Exception - if super class constructor throws an Exception or if the lengthPenalty does not allow the initial length

MutableMarkovModelScoringFunction

public MutableMarkovModelScoringFunction(AlphabetContainer alphabet,
                                         int length,
                                         double ess,
                                         boolean plugInParameters,
                                         InhomogeneousMarkov structureMeasure)
                                  throws Exception
This constructor creates an instance without any prior for the modeled length.

Parameters:
alphabet - the AlphabetContainer of the MutableMarkovModelScoringFunction
length - the initial length of the modeled sequences
ess - the equivalent sample size
plugInParameters - a switch whether to use plug-in parameters of not
structureMeasure - an InhomogeneousMarkov Measure for the structure
Throws:
Exception - if super class constructor throws an Exception

MutableMarkovModelScoringFunction

public MutableMarkovModelScoringFunction(AlphabetContainer alphabet,
                                         int length,
                                         double ess,
                                         boolean plugInParameters,
                                         InhomogeneousMarkov structureMeasure,
                                         DurationScoringFunction lengthPenalty)
                                  throws Exception
This constructor creates an instance with an prior for the modeled length.

Parameters:
alphabet - the AlphabetContainer of the MutableMarkovModelScoringFunction
length - the initial length of the modeled sequences
ess - the equivalent sample size
plugInParameters - a switch whether to use plug-in parameters of not
structureMeasure - a InhomogeneousMarkov Measure for the structure
lengthPenalty - the prior on the modeled sequence length
Throws:
Exception - if super class constructor throws an Exception or if the lengthPenalty does not allow the initial length

MutableMarkovModelScoringFunction

public MutableMarkovModelScoringFunction(StringBuffer xml)
                                  throws NonParsableException
The standard constructor for the interface Storable. Recreates a MutableMarkovModelScoringFunction from its XML representation as saved by the method toXML().

Parameters:
xml - the XML representation as StringBuffer
Throws:
NonParsableException - if the XML code could not be parsed
Method Detail

fromXML

protected void fromXML(StringBuffer source)
                throws NonParsableException
Description copied from class: AbstractNormalizableScoringFunction
This method is called in the constructor for the Storable interface to create a scoring function from a StringBuffer.

Overrides:
fromXML in class BayesianNetworkScoringFunction
Parameters:
source - the XML representation as StringBuffer
Throws:
NonParsableException - if the StringBuffer could not be parsed
See Also:
AbstractNormalizableScoringFunction.AbstractNormalizableScoringFunction(StringBuffer)

toXML

public StringBuffer toXML()
Description copied from interface: Storable
This method returns an XML representation as StringBuffer of an instance of the implementing class.

Specified by:
toXML in interface Storable
Overrides:
toXML in class BayesianNetworkScoringFunction
Returns:
the XML representation

getLogPriorTerm

public double getLogPriorTerm()
Description copied from interface: NormalizableScoringFunction
This method computes a value that is proportional to

NormalizableScoringFunction.getEss() * NormalizableScoringFunction.getLogNormalizationConstant() + Math.log( prior )

where prior is the prior for the parameters of this model.

Specified by:
getLogPriorTerm in interface NormalizableScoringFunction
Overrides:
getLogPriorTerm in class BayesianNetworkScoringFunction
Returns:
a value that is proportional to NormalizableScoringFunction.getEss() * NormalizableScoringFunction.getLogNormalizationConstant() + Math.log( prior ).
See Also:
NormalizableScoringFunction.getEss(), NormalizableScoringFunction.getLogNormalizationConstant()

getOrder

public int getOrder()
Returns the order of the inhomogeneous Markov model.

Returns:
the order

modify

public boolean modify(int offsetLeft,
                      int offsetRight)
Description copied from interface: Mutable
Manually modifies the model. The two offsets offsetLeft and offsetRight define how many positions the left or right border positions shall be moved. Negative numbers indicate moves to the left while positive numbers correspond to moves to the right.

Specified by:
modify in interface Mutable
Parameters:
offsetLeft - the offset on the left side
offsetRight - the offset on the right side
Returns:
true if the motif model was modified otherwise false

getSamplingGroups

public int[][] getSamplingGroups(int parameterOffset)
Description copied from interface: SamplingScoringFunction
Returns groups of indexes of parameters that shall be drawn together in a sampling procedure

Specified by:
getSamplingGroups in interface SamplingScoringFunction
Parameters:
parameterOffset - a global offset on the parameter indexes
Returns:
the groups of indexes. The first dimension represents the different groups while the second dimension contains the parameters that shall be sampled together. Internal parameter indexes need to be increased by parameterOffset.