public class StrandDiffSM extends AbstractMixtureDiffSM implements Mutable
ComplementableDiscreteAlphabet,
AlphabetContainer.isReverseComplementable()| Modifier and Type | Class and Description |
|---|---|
static class |
StrandDiffSM.InitMethod
This enum defines the different types of plug-in initialization of a
StrandDiffSM. |
componentScore, dList, freeParams, function, hiddenParameter, hiddenPotential, iList, logGammaSum, logHiddenNorm, logHiddenPotential, norm, optimizeHidden, paramRef, partNormalphabets, length, rUNKNOWN| Constructor and Description |
|---|
StrandDiffSM(DifferentiableStatisticalModel function,
double forwardPartOfESS,
int starts,
boolean plugIn,
StrandDiffSM.InitMethod initMethod)
This constructor creates a StrandDiffSM that optimizes the usage of each strand.
|
StrandDiffSM(DifferentiableStatisticalModel function,
int starts,
boolean plugIn,
StrandDiffSM.InitMethod initMethod,
double forward)
This constructor creates a StrandDiffSM that has a fixed frequency for the strand usage.
|
StrandDiffSM(StringBuffer xml)
This is the constructor for
Storable. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
extractFurtherInformation(StringBuffer xml)
This method is the opposite of
AbstractMixtureDiffSM.getFurtherInformation(). |
protected void |
fillComponentScores(Sequence seq,
int start)
Fills the internal array
AbstractMixtureDiffSM.componentScore with the logarithmic
scores of the components given a Sequence. |
double |
getESS()
Returns the equivalent sample size (ess) of this model, i.e.
|
double |
getForwardProbability()
This methoth returns the a-priori probability for the forward strand.
|
protected StringBuffer |
getFurtherInformation()
This method is used to append further information of the instance to the
XML representation.
|
double |
getHyperparameterForHiddenParameter(int index)
This method returns the hyperparameter for the hidden parameter with
index
index. |
String |
getInstanceName()
Should return a short instance name such as iMM(0), BN(2), ...
|
protected double |
getLogNormalizationConstantForComponent(int i)
Computes the logarithm of the normalization constant for the component
i. |
double |
getLogPartialNormalizationConstant(int parameterIndex)
Returns the logarithm of the partial normalization constant for the parameter with index
parameterIndex. |
double |
getLogScoreAndPartialDerivation(Sequence seq,
int start,
IntList indices,
DoubleList partialDer)
|
static double[][][] |
getReverseComplementDistributions(ComplementableDiscreteAlphabet abc,
double[][][] condDistr)
This method computes the reverse complement distributions for given conditional distributions.
|
StrandedLocatedSequenceAnnotationWithLength.Strand |
getStrand(Sequence seq,
int startPos)
This method returns the preferred
StrandedLocatedSequenceAnnotationWithLength.Strand for a given subsequence. |
protected void |
init(boolean freeParams)
This method creates the underlying structure for the parameters.
|
protected void |
initializeUsingPlugIn(int index,
boolean freeParams,
DataSet[] data,
double[][] weights)
This method initializes the functions using the data in some way.
|
static boolean |
isStrandModel(DifferentiableStatisticalModel nsf)
Check whether a
DifferentiableStatisticalModel is a StrandDiffSM. |
boolean |
modify(int offsetLeft,
int offsetRight)
Manually modifies the model.
|
protected void |
setForwardProb(double forward)
This method can be used to set the forward strand probability.
|
String |
toString(NumberFormat nf)
This method returns a
String representation of the instance. |
addGradientOfLogPriorTerm, clone, cloneFunctions, computeHiddenParameter, computeLogGammaSum, determineIsNormalized, fromXML, getAPrioriMixtureProbabilities, getCurrentParameterValues, getDifferentiableStatisticalModels, getFunction, getFunctions, getIndexOfMaximalComponentFor, getIndices, getLogNormalizationConstant, getLogPriorTerm, getLogScoreFor, getNumberOfComponents, getNumberOfParameters, getNumberOfRecommendedStarts, getProbsForComponent, getSamplingGroups, getSizeOfEventSpaceForRandomVariablesOfParameter, getXMLTag, initializeFunction, initializeFunctionRandomly, initializeHiddenPotentialRandomly, initializeHiddenUniformly, initWithLength, isInitialized, isNormalized, precomputeNorm, setHiddenParameters, setParameters, setParametersForFunction, toXMLemitDataSet, getInitialClassParam, getLogProbFor, getLogProbFor, getLogProbFor, getLogScoreFor, getLogScoreFor, getMaximalMarkovOrder, isNormalizedgetAlphabetContainer, getCharacteristics, getLength, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getLogScoreFor, getLogScoreFor, getNumberOfStarts, getNumericalCharacteristics, toStringequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetInitialClassParam, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivationemitDataSet, getLogProbFor, getLogProbFor, getLogProbFor, getMaximalMarkovOrdergetAlphabetContainer, getCharacteristics, getLength, getLogScoreFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getNumericalCharacteristicspublic StrandDiffSM(DifferentiableStatisticalModel function, double forwardPartOfESS, int starts, boolean plugIn, StrandDiffSM.InitMethod initMethod) throws CloneNotSupportedException, WrongAlphabetException
function - the DifferentiableSequenceScoreforwardPartOfESS - the part of the full ESS that should be used as hyperparameter for the forward strandstarts - the number of starts the should be done in an optimizationplugIn - whether the initial parameters for an optimization should be related to the data or randomly drawninitMethod - only used if plugIn==trueCloneNotSupportedException - if function could not be clonedWrongAlphabetException - if the alphabet of function is not AlphabetContainer.isReverseComplementable() and, hence, cannot be used for a strand mixtureStrandDiffSM.InitMethodpublic StrandDiffSM(DifferentiableStatisticalModel function, int starts, boolean plugIn, StrandDiffSM.InitMethod initMethod, double forward) throws CloneNotSupportedException, WrongAlphabetException
function - the DifferentiableSequenceScorestarts - the number of starts the should be done in an optimizationplugIn - whether the initial parameters for an optimization should be related to the data or randomly drawninitMethod - only used if plugIn==trueforward - the probability of a motif to be on the forward strandCloneNotSupportedException - if function could not be clonedWrongAlphabetException - if the alphabet of function is not AlphabetContainer.isReverseComplementable() and, hence, cannot be used for a strand mixtureStrandDiffSM.InitMethodpublic StrandDiffSM(StringBuffer xml) throws NonParsableException
Storable.xml - the xml representationNonParsableException - if the representation could not be parsed.protected void setForwardProb(double forward)
forward - the forward strand probability in (0,1)protected double getLogNormalizationConstantForComponent(int i)
AbstractMixtureDiffSMi.getLogNormalizationConstantForComponent in class AbstractMixtureDiffSMi - the index of the componentpublic double getLogPartialNormalizationConstant(int parameterIndex)
throws Exception
DifferentiableStatisticalModelparameterIndex. This is the logarithm of the partial derivation of the
normalization constant for the parameter with index
parameterIndex,
![\[\log \frac{\partial Z(\underline{\lambda})}{\partial \lambda_{parameterindex}}\]](images/DifferentiableStatisticalModel_LaTeXilb9_1.png)
getLogPartialNormalizationConstant in interface DifferentiableStatisticalModelparameterIndex - the index of the parameterException - if something went wrong with the normalizationDifferentiableStatisticalModel.getLogNormalizationConstant()public double getHyperparameterForHiddenParameter(int index)
AbstractMixtureDiffSMindex.getHyperparameterForHiddenParameter in class AbstractMixtureDiffSMindex - the index of the hidden parameterpublic double getForwardProbability()
public double getESS()
DifferentiableStatisticalModelgetESS in interface DifferentiableStatisticalModelprotected void initializeUsingPlugIn(int index,
boolean freeParams,
DataSet[] data,
double[][] weights)
throws Exception
AbstractMixtureDiffSMinitializeUsingPlugIn in class AbstractMixtureDiffSMindex - the class indexfreeParams - if true, the (reduced) parameterization is useddata - the dataweights - the weights for the dataException - if the initialization could not be doneDifferentiableSequenceScore.initializeFunction(int,
boolean, DataSet[], double[][])public String getInstanceName()
SequenceScoregetInstanceName in interface SequenceScoreprotected void fillComponentScores(Sequence seq, int start)
AbstractMixtureDiffSMAbstractMixtureDiffSM.componentScore with the logarithmic
scores of the components given a Sequence.fillComponentScores in class AbstractMixtureDiffSMseq - the sequencestart - the start position in seqpublic double getLogScoreAndPartialDerivation(Sequence seq, int start, IntList indices, DoubleList partialDer)
DifferentiableSequenceScoreSequence beginning at
position start in the Sequence and fills lists with
the indices and the partial derivations.getLogScoreAndPartialDerivation in interface DifferentiableSequenceScoreseq - the Sequencestart - the start position in the Sequenceindices - an IntList of indices, after method invocation the
list should contain the indices i where
is not zeropartialDer - a DoubleList of partial derivations, after method
invocation the list should contain the corresponding
that are not zeroSequenceprotected StringBuffer getFurtherInformation()
AbstractMixtureDiffSMgetFurtherInformation in class AbstractMixtureDiffSMStringBufferAbstractMixtureDiffSM.extractFurtherInformation(StringBuffer)protected void extractFurtherInformation(StringBuffer xml) throws NonParsableException
AbstractMixtureDiffSMAbstractMixtureDiffSM.getFurtherInformation(). It
extracts further information of the instance from a XML representation.extractFurtherInformation in class AbstractMixtureDiffSMxml - the StringBuffer containing the information to be
extracted as XML codeNonParsableException - if the StringBuffer could not be parsedAbstractMixtureDiffSM.getFurtherInformation()protected void init(boolean freeParams)
AbstractMixtureDiffSMinit in class AbstractMixtureDiffSMfreeParams - indicates whether to use only free parameters or all
parameterspublic String toString(NumberFormat nf)
SequenceScoreString representation of the instance.toString in interface SequenceScorenf - the NumberFormat for the String representation of parameters or probabilitiesString representation of the instancepublic boolean modify(int offsetLeft,
int offsetRight)
MutableoffsetLeft
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.public static double[][][] getReverseComplementDistributions(ComplementableDiscreteAlphabet abc, double[][][] condDistr)
abc - the alphabetcondDistr - the conditional distributionpublic StrandedLocatedSequenceAnnotationWithLength.Strand getStrand(Sequence seq, int startPos)
StrandedLocatedSequenceAnnotationWithLength.Strand for a given subsequence.seq - the sequencestartPos - the start positionStrandedLocatedSequenceAnnotationWithLength.Strand of this subsequenceAbstractMixtureDiffSM.getIndexOfMaximalComponentFor(Sequence, int)public static boolean isStrandModel(DifferentiableStatisticalModel nsf)
DifferentiableStatisticalModel is a StrandDiffSM.nsf - the original DifferentiableStatisticalModeltrue if the DifferentiableStatisticalModel is a StrandDiffSM