|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.scoringFunctions.AbstractNormalizableScoringFunction
de.jstacs.scoringFunctions.mix.AbstractMixtureScoringFunction
de.jstacs.scoringFunctions.mix.MixtureScoringFunction
public class MixtureScoringFunction
This class implements a real mixture model.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface de.jstacs.motifDiscovery.MotifDiscoverer |
---|
MotifDiscoverer.KindOfProfile |
Field Summary |
---|
Fields inherited from class de.jstacs.scoringFunctions.mix.AbstractMixtureScoringFunction |
---|
componentScore, dList, freeParams, function, hiddenParameter, hiddenPotential, iList, logGammaSum, logHiddenNorm, logHiddenPotential, norm, optimizeHidden, paramRef, partNorm |
Fields inherited from class de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction |
---|
alphabets, length, r |
Fields inherited from interface de.jstacs.scoringFunctions.ScoringFunction |
---|
UNKNOWN |
Constructor Summary | |
---|---|
MixtureScoringFunction(int starts,
boolean plugIn,
NormalizableScoringFunction... component)
This constructor creates a new MixtureScoringFunction . |
|
MixtureScoringFunction(StringBuffer xml)
This is the constructor for the interface Storable . |
Method Summary | |
---|---|
void |
adjustHiddenParameters(int index,
Sample[] data,
double[][] weights)
Adjusts all hidden parameters including duration and mixture parameters according to the current values of the remaining parameters. |
MixtureScoringFunction |
clone()
Creates a clone (deep copy) of the current ScoringFunction
instance. |
protected void |
fillComponentScores(Sequence seq,
int start)
Fills the internal array AbstractMixtureScoringFunction.componentScore with the logarithmic
scores of the components given a Sequence . |
double |
getEss()
Returns the equivalent sample size (ess) of this model, i.e. the equivalent sample size for the class or component that is represented by this model. |
int |
getGlobalIndexOfMotifInComponent(int component,
int motif)
Returns the global index of the motif used in
component . |
double |
getHyperparameterForHiddenParameter(int index)
This method returns the hyperparameter for the hidden parameter with index index . |
int |
getIndexOfMaximalComponentFor(Sequence sequence)
Returns the index of the component with the maximal score for the sequence sequence . |
String |
getInstanceName()
Returns a short instance name. |
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)
Returns the logarithmic score for a Sequence beginning at
position start in the Sequence and fills lists with
the indices and the partial derivations. |
int |
getMotifLength(int motif)
This method returns the length of the motif with index motif
. |
int |
getNumberOfMotifs()
Returns the number of motifs for this MotifDiscoverer . |
int |
getNumberOfMotifsInComponent(int component)
Returns the number of motifs that are used in the component component of this MotifDiscoverer . |
double[] |
getProfileOfScoresFor(int component,
int motif,
Sequence sequence,
int startpos,
MotifDiscoverer.KindOfProfile kind)
Returns the profile of the scores for component component
and motif motif at all possible start positions of the motif
in the sequence sequence beginning at startpos . |
StrandedLocatedSequenceAnnotationWithLength.Strand |
getStrandFor(int component,
int motif,
Sequence sequence,
int startpos)
This method returns the strand for a given subsequence if it is considered as site of the motif model in a specific component. |
void |
initializeMotif(int motifIndex,
Sample data,
double[] weights)
This method allows to initialize the model of a motif manually using a weighted sample. |
void |
initializeMotifRandomly(int motif)
This method initializes the motif with index motif randomly using for instance ScoringFunction.initializeFunctionRandomly(boolean) . |
protected void |
initializeUsingPlugIn(int index,
boolean freeParams,
Sample[] data,
double[][] weights)
This method initializes the functions using the data in some way. |
boolean |
modifyMotif(int motifIndex,
int offsetLeft,
int offsetRight)
Manually modifies the motif model with index motifIndex . |
String |
toString()
|
Methods inherited from class de.jstacs.scoringFunctions.AbstractNormalizableScoringFunction |
---|
getAlphabetContainer, getInitialClassParam, getLength, getLogScore, getLogScoreAndPartialDerivation, getNumberOfStarts, isNormalized |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface de.jstacs.motifDiscovery.MotifDiscoverer |
---|
getNumberOfComponents |
Methods inherited from interface de.jstacs.Storable |
---|
toXML |
Constructor Detail |
---|
public MixtureScoringFunction(int starts, boolean plugIn, NormalizableScoringFunction... component) throws CloneNotSupportedException
MixtureScoringFunction
. The first component determines the length of the sequences that can be modeled.
starts
- the number of starts that should be done in an optimizationplugIn
- indicates whether the initial parameters for an optimization
should be related to the data or randomly drawncomponent
- the ScoringFunction
s
CloneNotSupportedException
- if an element of component
could not be clonedpublic MixtureScoringFunction(StringBuffer xml) throws NonParsableException
Storable
.
Creates a new MixtureScoringFunction
out of a
StringBuffer
.
xml
- the XML representation as StringBuffer
NonParsableException
- if the XML representation could not be parsedMethod Detail |
---|
public MixtureScoringFunction clone() throws CloneNotSupportedException
ScoringFunction
ScoringFunction
instance.
clone
in interface ScoringFunction
clone
in class AbstractMixtureScoringFunction
ScoringFunction
CloneNotSupportedException
- if something went wrong while cloning the
ScoringFunction
protected double getLogNormalizationConstantForComponent(int i)
AbstractMixtureScoringFunction
i
.
getLogNormalizationConstantForComponent
in class AbstractMixtureScoringFunction
i
- the index of the component
public double getLogPartialNormalizationConstant(int parameterIndex) throws Exception
NormalizableScoringFunction
parameterIndex
. This is the logarithm of the partial derivation of the
normalization constant for the parameter with index
parameterIndex
,
getLogPartialNormalizationConstant
in interface NormalizableScoringFunction
parameterIndex
- the index of the parameter
Exception
- if something went wrong with the normalizationNormalizableScoringFunction.getLogNormalizationConstant()
public double getHyperparameterForHiddenParameter(int index)
AbstractMixtureScoringFunction
index
.
getHyperparameterForHiddenParameter
in class AbstractMixtureScoringFunction
index
- the index of the hidden parameter
public double getEss()
NormalizableScoringFunction
getEss
in interface NormalizableScoringFunction
protected void initializeUsingPlugIn(int index, boolean freeParams, Sample[] data, double[][] weights) throws Exception
AbstractMixtureScoringFunction
initializeUsingPlugIn
in class AbstractMixtureScoringFunction
index
- the class indexfreeParams
- if true, the (reduced) parameterization is useddata
- the dataweights
- the weights for the data
- Throws:
Exception
- if the initialization could not be done- See Also:
ScoringFunction.initializeFunction(int,
boolean, Sample[], double[][])
public void adjustHiddenParameters(int index, Sample[] data, double[][] weights) throws Exception
adjustHiddenParameters
in interface MutableMotifDiscoverer
index
- the index of the class of this instancedata
- the array of data for all classesweights
- the weights for all sequences in data
Exception
- thrown if the hidden parameters could not be adjustedpublic String getInstanceName()
ScoringFunction
getInstanceName
in interface ScoringFunction
protected void fillComponentScores(Sequence seq, int start)
AbstractMixtureScoringFunction
AbstractMixtureScoringFunction.componentScore
with the logarithmic
scores of the components given a Sequence
.
fillComponentScores
in class AbstractMixtureScoringFunction
seq
- the sequencestart
- the start position in seq
public double getLogScoreAndPartialDerivation(Sequence seq, int start, IntList indices, DoubleList partialDer)
ScoringFunction
Sequence
beginning at
position start
in the Sequence
and fills lists with
the indices and the partial derivations.
getLogScoreAndPartialDerivation
in interface ScoringFunction
seq
- the Sequence
start
- the start position in the Sequence
indices
- an IntList
of indices, after method invocation the
list should contain the indices i where
partialDer
- a DoubleList
of partial derivations, after method
invocation the list should contain the corresponding
Sequence
public String toString()
toString
in class Object
public void initializeMotif(int motifIndex, Sample data, double[] weights) throws Exception
MutableMotifDiscoverer
initializeMotif
in interface MutableMotifDiscoverer
motifIndex
- the index of the motif in the motif discovererdata
- the sample of sequencesweights
- either null
or an array of length data.getNumberofElements()
with non-negative weights.
Exception
- if initialize was not possiblepublic void initializeMotifRandomly(int motif) throws Exception
MutableMotifDiscoverer
motif
randomly using for instance ScoringFunction.initializeFunctionRandomly(boolean)
.
Furthermore, if available, it also initializes the positional distribution.
initializeMotifRandomly
in interface MutableMotifDiscoverer
motif
- the index of the motif
Exception
- either if the index is wrong or if it is thrown by the method ScoringFunction.initializeFunctionRandomly(boolean)
public boolean modifyMotif(int motifIndex, int offsetLeft, int offsetRight) throws Exception
MutableMotifDiscoverer
motifIndex
. 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. The distribution for sequences to the left and right side of the motif shall be computed internally.
modifyMotif
in interface MutableMotifDiscoverer
motifIndex
- the index of the motif in the motif discovereroffsetLeft
- the offset on the left sideoffsetRight
- the offset on the right side
true
if the motif model was modified otherwise false
Exception
- if some unexpected error occurred during the modificationMutableMotifDiscoverer.modifyMotif(int, int, int)
,
Mutable.modify(int, int)
public int getGlobalIndexOfMotifInComponent(int component, int motif)
MotifDiscoverer
motif
used in
component
. The index returned must be at least 0 and less
than MotifDiscoverer.getNumberOfMotifs()
.
getGlobalIndexOfMotifInComponent
in interface MotifDiscoverer
component
- the component indexmotif
- the motif index in the component
motif in component
public int getIndexOfMaximalComponentFor(Sequence sequence) throws Exception
MotifDiscoverer
sequence
.
getIndexOfMaximalComponentFor
in interface MotifDiscoverer
sequence
- the given sequence
Exception
- if the index could not be computed for any reasonspublic int getMotifLength(int motif)
MotifDiscoverer
motif
.
getMotifLength
in interface MotifDiscoverer
motif
- the index of the motif
motif
public int getNumberOfMotifs()
MotifDiscoverer
MotifDiscoverer
.
getNumberOfMotifs
in interface MotifDiscoverer
public int getNumberOfMotifsInComponent(int component)
MotifDiscoverer
component
of this MotifDiscoverer
.
getNumberOfMotifsInComponent
in interface MotifDiscoverer
component
- the component of the MotifDiscoverer
public double[] getProfileOfScoresFor(int component, int motif, Sequence sequence, int startpos, MotifDiscoverer.KindOfProfile kind) throws Exception
MotifDiscoverer
component
and motif motif
at all possible start positions of the motif
in the sequence sequence
beginning at startpos
.
This array should be of length sequence.length() - startpos - motifs[motif].length() + 1
.
getProfileOfScoresFor
in interface MotifDiscoverer
component
- the component indexmotif
- the index of the motif in the componentsequence
- the given sequencestartpos
- the start position in the sequencekind
- indicates the kind of profile
Exception
- if the score could not be computed for any reasonspublic StrandedLocatedSequenceAnnotationWithLength.Strand getStrandFor(int component, int motif, Sequence sequence, int startpos) throws Exception
MotifDiscoverer
getStrandFor
in interface MotifDiscoverer
component
- the component indexmotif
- the index of the motif in the componentsequence
- the given sequencestartpos
- the start position in the sequence
Exception
- if the strand could not be computed for any reasons
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |