de.jstacs.sequenceScores.statisticalModels.differentiable.directedGraphicalModels
Class MarkovModelDiffSM

java.lang.Object
  extended by de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
      extended by de.jstacs.sequenceScores.statisticalModels.differentiable.AbstractDifferentiableStatisticalModel
          extended by de.jstacs.sequenceScores.statisticalModels.differentiable.directedGraphicalModels.BayesianNetworkDiffSM
              extended by de.jstacs.sequenceScores.statisticalModels.differentiable.directedGraphicalModels.MarkovModelDiffSM
All Implemented Interfaces:
InstantiableFromParameterSet, Mutable, DifferentiableSequenceScore, SequenceScore, DifferentiableStatisticalModel, SamplingDifferentiableStatisticalModel, StatisticalModel, Storable, Cloneable

public class MarkovModelDiffSM
extends BayesianNetworkDiffSM
implements Mutable, SamplingDifferentiableStatisticalModel

This class implements a AbstractDifferentiableStatisticalModel 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.sequenceScores.statisticalModels.differentiable.directedGraphicalModels.BayesianNetworkDiffSM
ess, isTrained, logNormalizationConstant, numFreePars, nums, order, parameters, plugInParameters, structureMeasure, trees
 
Fields inherited from class de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
alphabets, length, r
 
Fields inherited from interface de.jstacs.sequenceScores.differentiable.DifferentiableSequenceScore
UNKNOWN
 
Constructor Summary
MarkovModelDiffSM(AlphabetContainer alphabet, int length, double ess, boolean plugInParameters, InhomogeneousMarkov structureMeasure)
          This constructor creates an instance without any prior for the modeled length.
MarkovModelDiffSM(AlphabetContainer alphabet, int length, double ess, boolean plugInParameters, InhomogeneousMarkov structureMeasure, DurationDiffSM lengthPenalty)
          This constructor creates an instance with an prior for the modeled length.
MarkovModelDiffSM(AlphabetContainer alphabet, int length, double ess, boolean plugInParameters, int order, DurationDiffSM lengthPenalty)
          This constructor creates an instance with an prior for the modeled length.
MarkovModelDiffSM(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
 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.sequenceScores.statisticalModels.differentiable.directedGraphicalModels.BayesianNetworkDiffSM
addGradientOfLogPriorTerm, clone, createTrees, emitDataSet, getCurrentParameterSet, getCurrentParameterValues, getESS, getInstanceName, getLogNormalizationConstant, getLogPartialNormalizationConstant, getLogScoreAndPartialDerivation, getLogScoreFor, getMaximalMarkovOrder, getMaximumScore, getNumberOfParameters, getPositionDependentKMerProb, getPositionForParameter, getPWM, getSizeOfEventSpaceForRandomVariablesOfParameter, initializeFunction, initializeFunctionRandomly, isInitialized, precomputeNormalization, setParameters, setPlugInParameters, toHtml, toString
 
Methods inherited from class de.jstacs.sequenceScores.statisticalModels.differentiable.AbstractDifferentiableStatisticalModel
getInitialClassParam, getLogProbFor, getLogProbFor, getLogProbFor, getLogScoreFor, getLogScoreFor, isNormalized, isNormalized
 
Methods inherited from class de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
getAlphabetContainer, getCharacteristics, getLength, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getLogScoreFor, getLogScoreFor, getNumberOfRecommendedStarts, getNumberOfStarts, getNumericalCharacteristics
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.jstacs.sequenceScores.statisticalModels.differentiable.DifferentiableStatisticalModel
addGradientOfLogPriorTerm, getESS, getLogNormalizationConstant, getLogPartialNormalizationConstant, getSizeOfEventSpaceForRandomVariablesOfParameter, isNormalized
 
Methods inherited from interface de.jstacs.sequenceScores.differentiable.DifferentiableSequenceScore
clone, getCurrentParameterValues, getInitialClassParam, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getNumberOfParameters, getNumberOfRecommendedStarts, initializeFunction, initializeFunctionRandomly, setParameters
 
Methods inherited from interface de.jstacs.sequenceScores.statisticalModels.StatisticalModel
emitDataSet, getLogProbFor, getLogProbFor, getLogProbFor, getMaximalMarkovOrder
 
Methods inherited from interface de.jstacs.sequenceScores.SequenceScore
getAlphabetContainer, getCharacteristics, getInstanceName, getLength, getLogScoreFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getNumericalCharacteristics, isInitialized, toString
 

Constructor Detail

MarkovModelDiffSM

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

Parameters:
alphabet - the AlphabetContainer of the MarkovModelDiffSM
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

MarkovModelDiffSM

public MarkovModelDiffSM(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 MarkovModelDiffSM
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

MarkovModelDiffSM

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

Parameters:
alphabet - the AlphabetContainer of the MarkovModelDiffSM
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

MarkovModelDiffSM

public MarkovModelDiffSM(StringBuffer xml)
                  throws NonParsableException
The standard constructor for the interface Storable. Recreates a MarkovModelDiffSM 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: AbstractDifferentiableSequenceScore
This method is called in the constructor for the Storable interface to create a scoring function from a StringBuffer.

Overrides:
fromXML in class BayesianNetworkDiffSM
Parameters:
source - the XML representation as StringBuffer
Throws:
NonParsableException - if the StringBuffer could not be parsed
See Also:
AbstractDifferentiableSequenceScore.AbstractDifferentiableSequenceScore(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 BayesianNetworkDiffSM
Returns:
the XML representation

getLogPriorTerm

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

DifferentiableStatisticalModel.getESS() * DifferentiableStatisticalModel.getLogNormalizationConstant() + Math.log( prior )

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

Specified by:
getLogPriorTerm in interface DifferentiableStatisticalModel
Specified by:
getLogPriorTerm in interface StatisticalModel
Overrides:
getLogPriorTerm in class BayesianNetworkDiffSM
Returns:
a value that is proportional to DifferentiableStatisticalModel.getESS() * DifferentiableStatisticalModel.getLogNormalizationConstant() + Math.log( prior ).
See Also:
DifferentiableStatisticalModel.getESS(), DifferentiableStatisticalModel.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: SamplingDifferentiableStatisticalModel
Returns groups of indexes of parameters that shall be drawn together in a sampling procedure

Specified by:
getSamplingGroups in interface SamplingDifferentiableStatisticalModel
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.