org.gersteinlab.act
Class CorrelationsCalculator

java.lang.Object
  extended by org.gersteinlab.act.CorrelationsCalculator

public class CorrelationsCalculator
extends java.lang.Object

        This class computes the correlations between different datasets. It
        takes a number of data files (in WIG or BED format) as input, and
        computes the correlation between each pair of files.

        The correlation function can be specified as Pearson, Spearman or
        normal-score.
        


Field Summary
static java.lang.String NORMALSCORE
          Normal-score correlation
static java.lang.String PEARSON
          Pearson correlation
static java.lang.String SPEARMAN
          Spearman correlation
 
Constructor Summary
CorrelationsCalculator()
           
 
Method Summary
static double getNormalScoreCorrelation(double[] v1, double[] v2)
          Compute the normal score correlation between two vectors.
static double[] getNormalScores(double[] r)
          Get the normal scores of a set of ranks.
static double getPearsonCorrelation(double[] v1, double[] v2)
          Compute the Pearson correlation between two vectors.
static double[] getRanks(double[] v)
          Get the ranks [0..length-1] of the values in a vector.
static double getSpearmanCorrelation(double[] v1, double[] v2)
          Compute the Spearman correlation between two vectors.
static double[][] getUniqueValues(double[] v)
          Get the unique values and their ranks [0..length-1] in a vector.
static void main(java.lang.String[] argv)
           
static double[] readVector(java.io.File inFile, Config config)
          Read a vector of values from a data file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PEARSON

public static final java.lang.String PEARSON
Pearson correlation

See Also:
Constant Field Values

SPEARMAN

public static final java.lang.String SPEARMAN
Spearman correlation

See Also:
Constant Field Values

NORMALSCORE

public static final java.lang.String NORMALSCORE
Normal-score correlation

See Also:
Constant Field Values
Constructor Detail

CorrelationsCalculator

public CorrelationsCalculator()
Method Detail

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Throws:
java.lang.Exception

readVector

public static double[] readVector(java.io.File inFile,
                                  Config config)
                           throws java.lang.ClassNotFoundException,
                                  java.lang.IllegalAccessException,
                                  java.lang.InstantiationException,
                                  java.lang.reflect.InvocationTargetException,
                                  java.io.IOException,
                                  java.lang.NoSuchMethodException
Read a vector of values from a data file.

Parameters:
inFile - The data file
config - For getting file format configurations
Returns:
The vector
Throws:
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.reflect.InvocationTargetException
java.io.IOException
java.lang.NoSuchMethodException

getUniqueValues

public static double[][] getUniqueValues(double[] v)
Get the unique values and their ranks [0..length-1] in a vector. If a value appears multiple times, its rank will be the middle location of all appearences.

Parameters:
v - The values
Returns:
A 2-D array of values and ranks

getRanks

public static double[] getRanks(double[] v)
Get the ranks [0..length-1] of the values in a vector. If a value appears multiple times, its rank will be the middle location of all appearences.

Parameters:
v - The values
Returns:
The ranks

getNormalScores

public static double[] getNormalScores(double[] r)
Get the normal scores of a set of ranks.

Parameters:
r - The ranks
Returns:
The normal scores

getPearsonCorrelation

public static double getPearsonCorrelation(double[] v1,
                                           double[] v2)
Compute the Pearson correlation between two vectors.

Parameters:
v1 - The first vector
v2 - The second vector
Returns:
The correlation

getSpearmanCorrelation

public static double getSpearmanCorrelation(double[] v1,
                                            double[] v2)
Compute the Spearman correlation between two vectors.

Parameters:
v1 - The first vector
v2 - The second vector
Returns:
The correlation

getNormalScoreCorrelation

public static double getNormalScoreCorrelation(double[] v1,
                                               double[] v2)
Compute the normal score correlation between two vectors.

Parameters:
v1 - The first vector
v2 - The second vector
Returns:
The correlation