Class State

java.lang.Object
  extended by State

public class State
extends java.lang.Object

Holds the state name and the associated ratios expected

Eg: In a het deletion, we expect [observed coverage]/[average coverage in other samples]~1/2 and [observed heterozygosity]/[average heterozygosity in other samples]~0

Also contains methods to compute the emission and transition probabilities.

Author:
arthiramachandran

Field Summary
static int computeAtRunTime
           
static int DOUBLE_INSERT
           
(package private)  int E_LengthOfState
           
static int HETEROZYGOUS_DELETE
           
static int HOMOZYGOUS_DELETE
           
static int INSERTION
           
static java.util.HashMap<java.lang.Integer,java.lang.Double> LOG_FACTORIAL
           
static int NORMAL
           
(package private) static double rateOfOccurenceOfCNV
           
(package private)  double rpkmRatio
           
(package private)  double snpRatio
           
(package private)  int stateName
           
(package private) static java.util.HashMap<State,java.util.HashMap<State,java.lang.Double>> transitionProbabilities
           
 
Constructor Summary
State()
           
 
Method Summary
 boolean equals(java.lang.Object aThat)
           
static double getEmissionProbability(double observedFPKM, double observedSNPs, double expectedFPKM, double expectedSNPs, double stdDevFPKM, double stdDevSNPs, double normalizationFPKM, double normalizationSNPs, State s)
          To remove
static java.lang.Double getEmissionProbability(Exon exon, Exon expected, Exon stdDev, State s)
          To remove
static double getLogEmissionProbability(Exon exon, Exon expected, Exon stdDev, State s, int nSamples, cern.jet.random.Gamma gamma, double gammaK, double gammaTheta, double gammaSNPsK, double gammaSNPsTheta)
          Calculates the emission probability for the observation at a particular exon, in state s
 java.lang.String getStateName()
          For pretty-printing and for serving coffee with the code
static double getTransitionProbability(State s1, State s2, int lengthOfIntron, int lengthOfExon)
          Gets the transition probability from state s1 -> state s2
static java.util.HashMap<java.lang.String,State> initializeStates(java.lang.String parameterFile)
          Initializes all the states with the values in the parameter file
private static double logFactorial(int number)
          Calculated the log of the factorial of the number
private static double logGamma(double x, double k, double theta)
          Calculates the log of the pdf of a gamma distribution
private static double logPoisson(double x, double lambda)
          Calculates log of pdf of Poisson distribution
 java.lang.String toString()
           
private static double updateGammaK(double ratio, int nSamples, double gammaK, double expectedFPKM)
          Updates the k for the Gamma prior (computes the posterior hyperparameter)
private static double updateGammaTheta(int nSamples, double gammaTheta)
          Updates the theta for the Gamma prior (computes the posterior hyperparameter)
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

stateName

int stateName

rpkmRatio

double rpkmRatio

snpRatio

double snpRatio

E_LengthOfState

int E_LengthOfState

rateOfOccurenceOfCNV

static double rateOfOccurenceOfCNV

transitionProbabilities

static java.util.HashMap<State,java.util.HashMap<State,java.lang.Double>> transitionProbabilities

NORMAL

public static final int NORMAL
See Also:
Constant Field Values

HOMOZYGOUS_DELETE

public static final int HOMOZYGOUS_DELETE
See Also:
Constant Field Values

HETEROZYGOUS_DELETE

public static final int HETEROZYGOUS_DELETE
See Also:
Constant Field Values

INSERTION

public static final int INSERTION
See Also:
Constant Field Values

DOUBLE_INSERT

public static final int DOUBLE_INSERT
See Also:
Constant Field Values

computeAtRunTime

public static final int computeAtRunTime
See Also:
Constant Field Values

LOG_FACTORIAL

public static java.util.HashMap<java.lang.Integer,java.lang.Double> LOG_FACTORIAL
Constructor Detail

State

public State()
Method Detail

getTransitionProbability

public static double getTransitionProbability(State s1,
                                              State s2,
                                              int lengthOfIntron,
                                              int lengthOfExon)
Gets the transition probability from state s1 -> state s2

For CNV state -> normal state, transition probability is dependent on length of intron

Parameters:
s1 - State transitioning from
s2 - State transitioning to
lengthOfIntron - length of the intron
lengthOfExon - length of the exon
Returns:
transition probability from s1 -> s2

initializeStates

public static java.util.HashMap<java.lang.String,State> initializeStates(java.lang.String parameterFile)
Initializes all the states with the values in the parameter file

Parameters:
parameterFile - name of parameter file
Returns:
HashMap of states indexed by their name

getStateName

public java.lang.String getStateName()
For pretty-printing and for serving coffee with the code

Returns:
String character describing the name of the state

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object aThat)
Overrides:
equals in class java.lang.Object

getEmissionProbability

public static double getEmissionProbability(double observedFPKM,
                                            double observedSNPs,
                                            double expectedFPKM,
                                            double expectedSNPs,
                                            double stdDevFPKM,
                                            double stdDevSNPs,
                                            double normalizationFPKM,
                                            double normalizationSNPs,
                                            State s)
To remove


getEmissionProbability

public static java.lang.Double getEmissionProbability(Exon exon,
                                                      Exon expected,
                                                      Exon stdDev,
                                                      State s)
To remove


logFactorial

private static double logFactorial(int number)
Calculated the log of the factorial of the number

Parameters:
number -
Returns:
log(number!)

getLogEmissionProbability

public static double getLogEmissionProbability(Exon exon,
                                               Exon expected,
                                               Exon stdDev,
                                               State s,
                                               int nSamples,
                                               cern.jet.random.Gamma gamma,
                                               double gammaK,
                                               double gammaTheta,
                                               double gammaSNPsK,
                                               double gammaSNPsTheta)
Calculates the emission probability for the observation at a particular exon, in state s

Parameters:
exon - exon for which emission probability is computed
expected - expected observations for that exon (based on other samples)
stdDev - std deviations for that exon (based on other samples)
s - state
nSamples - number of samples
gamma - to remove
gammaK - gamma parameter k of the coverage
gammaTheta - gamma parameter Theta of the coverage
gammaSNPsK - gamma parameter k of the heterozygosity
gammaSNPsTheta - gamma parameter Theta of the heterozygosity
Returns:
log(emission probability(expected | s))

logGamma

private static double logGamma(double x,
                               double k,
                               double theta)
Calculates the log of the pdf of a gamma distribution

Parameters:
x - - observation
k - - parameter of Gamma distribution
theta - - parameter of Gamma distribution
Returns:
log(pdf(Gamma(k, Theta)))

logPoisson

private static double logPoisson(double x,
                                 double lambda)
Calculates log of pdf of Poisson distribution

Parameters:
x - - observed
lambda - - parameter of Poisson distribution
Returns:
log(pdf(Poisson(lambda)))

updateGammaTheta

private static double updateGammaTheta(int nSamples,
                                       double gammaTheta)
Updates the theta for the Gamma prior (computes the posterior hyperparameter)

Parameters:
nSamples - number of samples
gammaTheta - original Theta value
Returns:
new Theta value

updateGammaK

private static double updateGammaK(double ratio,
                                   int nSamples,
                                   double gammaK,
                                   double expectedFPKM)
Updates the k for the Gamma prior (computes the posterior hyperparameter)

Parameters:
ratio - ratio of observed to expected in the particular state
nSamples - number of samples
gammaK - original k value
expectedFPKM - expected coverage
Returns:
new k value