Class MJAmath

java.lang.Object
  |
  +--MJAbase
        |
        +--MJAmath

public class MJAmath
extends MJAbase

MAExplorer Open Java class to access MJAmath methods and data structures. This provides access to builtin math methods

List of methods available to Plugin-writers

 get_okBetaCF() return true if nr_betacf() was ok
 get_okBetaI() return true if if nr_betai() was ok
 get_okProbKS() return true if nr_probks() was ok
 get_dKS() return K-S statistic for Kolmogorov-Smirnov stat d & prob
 get_probKS() return probability of null hypoth same distrib for K-S stat
 get_nXY() return # of genes used in calcXYstat computation
 get_rSq() return correlation coefficient 
 get_mnX() return mean X
 get_mnY() return mean Y
 get_sdX() return standard deviation X
 get_sdY() return standard deviation Y
 nr_gammln() - Return ln(gamma()) of x by polynomial evaluation.
 nr_betacf() - evaluation fct for the incomplete Beta function 'x(a,b).
 nr_betai() - return the incomplete Beta function 'x(a,b).
 nr_sort() - quick-sort of bin of data[1:n] in assend. numerical order.
 nr_kstwo() - Kolmogorov-Smirnov stat d & prob of the null hypothesis of 
 nr_probks() - Calc Kolmogorov-Smirnov probability Qks.
 calcXYstat() - statistics string for display
 euclideanDistance() - compute Euclidean distance of 2 vectors
 cityBlockDistance() - compute city-block distance of 2 vectors
 calcPearsonCorrCoef() - compute Pearson correlation coefficient
 log2Zero() - compute log2((x==0.0 ? 0.0 : x) - avoids log2(0.0)!
 log2() - compute log(x) base 2.
 alog2() - compute alog(x) base 2.
 logZero() - compute log10((x==0.0 ? 0.0 : x) - avoids log(0.0)!
 log10() - compute log(x) base 10.
 alog10() - compute alog(x) base 10.

This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file.

Version:
$Date: 2003/02/18 18:02:33 $ $Revision: $
Author:
P. Lemkin (NCI), J. Evans (CIT), C. Santos (CIT), G. Thornwall (SAIC), NCI-Frederick, Frederick, MD
See Also:
MAExplorer Home


Fields inherited from class MJAbase
COMPARE_ALL, COMPARE_ANY, COMPARE_AT_LEAST, COMPARE_AT_MOST, COMPARE_PRODUCT, COMPARE_SUM, DATA_F1TOT, DATA_F2TOT, DATA_MEAN_F1F2TOT, DATA_RATIO_F1F2TOT, DRAW_BIN, DRAW_BOX, DRAW_CIRCLE, DRAW_PLUS, EDIT_ADD, EDIT_NOP, EDIT_RMV, GENE_ATCC_ID, GENE_BAD_DATA, GENE_BAD_LOCAL_SPOT_BKGRD, GENE_BAD_MID, GENE_BAD_SPOT, GENE_BAD_SPOT_GEOMETRY, GENE_DUP_SPOT, GENE_GOOD_MID, GENE_IMAGE_ID, GENE_IS_CUR_GENE, GENE_IS_EGL_GENE, GENE_IS_FILTERED, GENE_IS_KMEANS, GENE_IS_NOT_FILTERED, GENE_LOW_SPOT_REF_SIGNAL, GENE_MARGINAL_SPOT, GENE_USE_GBID_FOR_CLONEID, HIER_CLUST_NEXT_MIN_LNKG, HIER_CLUST_PGMA_LNKG, HIER_CLUST_PGMC_LNKG, MARKER_CIRCLE, MARKER_CURRENT, MARKER_GENES, MARKER_KMEANS_CLUSTER, MARKER_NONE, MARKER_PLUS, MARKER_SQUARE, MASTER_CLONE_ID, MASTER_DBEST3, MASTER_DBEST5, MASTER_GENBANK, MASTER_GENBANK3, MASTER_GENBANK5, MASTER_GENE_NAME, MASTER_GENERIC_ID, MASTER_LOCUSLINK, MASTER_SWISS_PROT, MASTER_UG_ID, MASTER_UG_NAME, MAX_COLORS, PLOT_CLUSTER_GENES, PLOT_CLUSTER_HIER, PLOT_CLUSTER_HYBSAMPLES, PLOT_CLUSTERGRAM, PLOT_EXPR_PROFILE, PLOT_F1_F2_INTENS, PLOT_F1_F2_MVSA, PLOT_HIST_F1F2_RATIO, PLOT_HIST_HP_XY_RATIO, PLOT_HIST_HP_XY_SETS_RATIO, PLOT_HP_XY_INTENS, PLOT_INTENS_HIST, PLOT_KMEANS_CLUSTERGRAM, PLOT_PSEUDO_F1F2_IMG, PLOT_PSEUDO_F1F2_RYG_IMG, PLOT_PSEUDO_HP_XY_IMG, PLOT_PSEUDO_HP_XY_RYG_IMG, PLOT_PSEUDOIMG, PRPROP_CUR_GENE, PRPROP_FILTER, PRPROP_LABEL, PRPROP_SLIDER, PRPROP_TIMEOUT, PRPROP_UNIQUE, QUALTYPE_ALPHA, QUALTYPE_PROP_CODE, QUALTYPE_THR, RANGE_INSIDE, RANGE_OUTSIDE, RPT_FMT_DYN, RPT_FMT_TAB_DELIM, RPT_NONE, RPT_TBL_ALL_GENES_CLUSTER, RPT_TBL_CALIB_DNA_STAT, RPT_TBL_CUR_GENE_CLUSTER, RPT_TBL_EDITED_GENE_LIST, RPT_TBL_EXPR_PROFILE, RPT_TBL_FILTERED_GENES, RPT_TBL_GENE_CLASS, RPT_TBL_HIER_CLUSTER, RPT_TBL_HIGH_F1F2, RPT_TBL_HIGH_RATIO, RPT_TBL_HP_DB_INFO, RPT_TBL_HP_HP_CORR, RPT_TBL_HP_MN_VAR_STAT, RPT_TBL_HP_XY_SET_STAT, RPT_TBL_KMEANS_CLUSTER, RPT_TBL_LOW_F1F2, RPT_TBL_LOW_RATIO, RPT_TBL_MAE_PRJ_DB, RPT_TBL_MN_KMEANS_CLUSTER, RPT_TBL_NAMED_GENES, RPT_TBL_NORMALIZATION_GENE_LIST, RPT_TBL_OCL_STAT, RPT_TBL_SAMPLES_DB_INFO, RPT_TBL_SAMPLES_WEB_LINKS, SS_MODE_ELIST, SS_MODE_MS, SS_MODE_XANDY_SETS, SS_MODE_XORY_SETS, SS_MODE_XSET, SS_MODE_XY, SS_MODE_YSET
 
Method Summary
 double alog10(double x)
          alog10() - compute alog(x) base 10.
 double alog2(double x)
          alog2() - compute alog(x) base 2.
 float calcPearsonCorrCoef(float[] data1, float[] data2, int n, boolean usePopulationCovar)
          calcPearsonCorrCoef() - compute Pearson correlation coefficient The data is data1[0:n-1] and data2[0:n-1].
 java.lang.String calcXYstat(int n, float[] xList, float[] yList, int[] propList, java.lang.String xLbl, java.lang.String yLbl)
          calcXYstat() - compute correlation statistics string for display rSq=.., n=.., X(mn+-sd)=(..+-..), Y(mn+-sd)=(..+-..) If propList[] is not null, then test if filtered using IS_FILTERED property.
 float cityBlockDistance(float[] data1, float[] data2, int n, boolean rtnAbsSumFlag)
          cityBlockDistance() - compute city-block distance of 2 vectors.
 float euclideanDistance(float[] data1, float[] data2, int n, boolean rtnDistSqFlag)
          euclideanDistance() - compute Euclidean distance of 2 vectors as either the Euclidean distance or (sum dist**2).
 double get_dKS()
          get_dKS() - K-S statistic for Kolmogorov-Smirnov stat d & prob of the null hypothesis of 2 bins of data.
 double get_mnX()
          get_mnX() - get mean X previously computed
 double get_mnY()
          get_mnY() - get mean Y previously computed
 int get_nXY()
          get_nXY() - # of genes used in calcXYstat computation
 boolean get_okBetaCF()
          get_okBetaCF() - test if nr_betaCF() was ok
 boolean get_okBetaI()
          get_okBetaI() - test if nr_betai() was ok
 boolean get_okProbKS()
          get_okProbKS() - test if Kolmogorov-Smirnov test was ok
 double get_probKS()
          get_probKS() - probability of null hypoth same distrib for previously computed Kolmogorov-Smirnov stat d & prob of the null hypothesis of 2 bins of data.
 double get_rSq()
          get_rSq() - get correlation coefficient previously computed
 double get_sdX()
          get_sdX() - get standard deviation X previously computed
 double get_sdY()
          get_sdY() - get standard deviation Y previously computed
 double log10(double x)
          log10() - compute log(x) base 10.
 double log2(double x)
          log2() - compute log(x) base 2.
 double log2Zero(double x)
          log2Zero() - compute log2((x==0.0 ? 0.0 : x) - avoids log2(0.0)! This defaults log2(0.0) to log2(1.0).
 double logZero(double x)
          logZero() - compute log10((x==0.0 ? 0.0 : x) - avoids log(0.0)! This defaults log10(0.0) to log(1.0).
 double nr_betacf(double a, double b, double x)
          nr_betacf() - evaluation fct for the incomplete Beta function 'x(a,b).
 double nr_betai(double a, double b, double x)
          nr_betai() - return the incomplete Beta function 'x(a,b).
 double nr_gammln(double xx)
          nr_gammln() - Return ln(gamma()) of x by polynomial evaluation.
 boolean nr_kstwo(double[] data1, int n1, double[] data2, int n2)
          nr_kstwo() - Kolmogorov-Smirnov statistic d and the probability of the null hypothesis of 2 bins of data.
 double nr_probks(double alam)
          nr_probks() - Calc Kolmogorov-Smirnov probability Qks.
 boolean nr_sort(int n, double[] data)
          nr_sort() - quick-sort of bin of data[1:n] in assend.
 
Methods inherited from class MJAbase
cvtHashtable2SimpleTable, cvtTable2Hashtable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get_okBetaCF

public final boolean get_okBetaCF()
get_okBetaCF() - test if nr_betaCF() was ok
Returns:
true if nr_betacf() was ok
See Also:
nr_betacf(double, double, double)

get_okBetaI

public final boolean get_okBetaI()
get_okBetaI() - test if nr_betai() was ok
Returns:
true if nr_betai() was ok
See Also:
nr_betai(double, double, double)

get_okProbKS

public final boolean get_okProbKS()
get_okProbKS() - test if Kolmogorov-Smirnov test was ok
Returns:
true if nr_probks() was ok
See Also:
nr_kstwo(double[], int, double[], int), nr_probks(double)

get_dKS

public final double get_dKS()
get_dKS() - K-S statistic for Kolmogorov-Smirnov stat d & prob of the null hypothesis of 2 bins of data.
Returns:
value
See Also:
nr_kstwo(double[], int, double[], int)

get_probKS

public final double get_probKS()
get_probKS() - probability of null hypoth same distrib for previously computed Kolmogorov-Smirnov stat d & prob of the null hypothesis of 2 bins of data.
Returns:
value

get_nXY

public final int get_nXY()
get_nXY() - # of genes used in calcXYstat computation
Returns:
value

get_rSq

public final double get_rSq()
get_rSq() - get correlation coefficient previously computed
Returns:
value
See Also:
calcXYstat(int, float[], float[], int[], java.lang.String, java.lang.String)

get_mnX

public final double get_mnX()
get_mnX() - get mean X previously computed
Returns:
value
See Also:
calcXYstat(int, float[], float[], int[], java.lang.String, java.lang.String)

get_mnY

public final double get_mnY()
get_mnY() - get mean Y previously computed
Returns:
value
See Also:
calcXYstat(int, float[], float[], int[], java.lang.String, java.lang.String)

get_sdX

public final double get_sdX()
get_sdX() - get standard deviation X previously computed
Returns:
value
See Also:
calcXYstat(int, float[], float[], int[], java.lang.String, java.lang.String)

get_sdY

public final double get_sdY()
get_sdY() - get standard deviation Y previously computed
Returns:
value
See Also:
calcXYstat(int, float[], float[], int[], java.lang.String, java.lang.String)

nr_gammln

public final double nr_gammln(double xx)
nr_gammln() - Return ln(gamma()) of x by polynomial evaluation. Pg 168, Section 6 N.R.C.
Parameters:
xx - arg
Returns:
value

nr_betacf

public final double nr_betacf(double a,
                              double b,
                              double x)
nr_betacf() - evaluation fct for the incomplete Beta function 'x(a,b). Pg 180, Section 6.3 N.R.C. Set the okBetaCF flag to false if there is a problem
Parameters:
a - arg
b - arg
x - arg
Returns:
value

nr_betai

public final double nr_betai(double a,
                             double b,
                             double x)
nr_betai() - return the incomplete Beta function 'x(a,b). Pg 179, Section 6.3 N.R.C.
Parameters:
a - - a parameter of 'x(a,b)
b - - b parameter of 'x(a,b)
x - - x parameter of 'x(a,b)
Returns:
value if succeed else 0.0 if it fails and set the okBetaI flag to false.

nr_sort

public final boolean nr_sort(int n,
                             double[] data)
nr_sort() - quick-sort of bin of data[1:n] in assend. numerical order. Uses the partitioning-exchange sorting method.
Parameters:
n - is the amount of data.
data - is the set of data [1:n].
Returns:
false if blow the stack or other problems.

nr_kstwo

public final boolean nr_kstwo(double[] data1,
                              int n1,
                              double[] data2,
                              int n2)
nr_kstwo() - Kolmogorov-Smirnov statistic d and the probability of the null hypothesis of 2 bins of data. Pg 625, Section 14.3 N.R.C. 2nd Edition.
Parameters:
data1 - [1:n1] data1
n2 - # of items in data 1
data1 - [1:n2] data2
n2 - # of items in data 2
Returns:
false if any errors in the data or calcs. Data is returned in the global class variables: returns data in global class variables:
    dKS     -  K-S statistic, and
    probKS  - probl of null hypoth same distribution

nr_probks

public final double nr_probks(double alam)
nr_probks() - Calc Kolmogorov-Smirnov probability Qks. Pg 626, Section 14.3 N.R.C. 2nd Edition.
Parameters:
alam - the value computed in kstwo().
Returns:
the probability.Set okProbKS to false if there is a problem.

calcXYstat

public final java.lang.String calcXYstat(int n,
                                         float[] xList,
                                         float[] yList,
                                         int[] propList,
                                         java.lang.String xLbl,
                                         java.lang.String yLbl)
calcXYstat() - compute correlation statistics string for display rSq=.., n=.., X(mn+-sd)=(..+-..), Y(mn+-sd)=(..+-..) If propList[] is not null, then test if filtered using IS_FILTERED property. The following data is generated:
  rSq - string "rSq=.., n=.., X(mn+-sd)=(..+-..), Y(mn+-sd)=(..+-..)"
  nXY - # of data points
  mnX - mean X value
  mnY - mean Y value
  sdX - std deviation of X values
  sdY - std deviation of Y values
Parameters:
n - size of lists
xList - is X class data
yList - is Y class data
propList - is properties data
xLbl - is label for the X data
yLbl - is label for the Y data
Returns:
statistics string if succeed, else return null if problem.

euclideanDistance

public final float euclideanDistance(float[] data1,
                                     float[] data2,
                                     int n,
                                     boolean rtnDistSqFlag)
euclideanDistance() - compute Euclidean distance of 2 vectors as either the Euclidean distance or (sum dist**2). The data vectors are data1[0:n-1] and data2[0:n-1].
Parameters:
data1 - is vector [0:n-1] of object 1
data2 - is vector [0:n-1] of object 2
n - is size of vector
rtnDistSqFlag - return (sum dist**2) else Euclidean distance.
Returns:
euclidean distance or distSq, else -1.0 if an error

cityBlockDistance

public final float cityBlockDistance(float[] data1,
                                     float[] data2,
                                     int n,
                                     boolean rtnAbsSumFlag)
cityBlockDistance() - compute city-block distance of 2 vectors. The data vectors are data1[0:n-1] and data2[0:n-1].
Parameters:
data1 - is vector [0:n-1] of object 1
data2 - is vector [0:n-1] of object 2
n - is size of vector
Returns:
city-block distance. Return -1.0 if there is an error

calcPearsonCorrCoef

public final float calcPearsonCorrCoef(float[] data1,
                                       float[] data2,
                                       int n,
                                       boolean usePopulationCovar)
calcPearsonCorrCoef() - compute Pearson correlation coefficient The data is data1[0:n-1] and data2[0:n-1].
Parameters:
data1 - is vector [0:n-1] of object 1
data2 - is vector [0:n-1] of object 2
n - is size of vector
usePopulationCovar - flag to compute popuplation covariance (Weinstein) U. Scherf, Nat.Genetics (2000) 24:236-244, pg 243. else use version for large samples in Snedecore & Cochran 1st Edition page 175.
Returns:
calcPearsonCorrCoef else 1000.0 if there is an error

log2Zero

public final double log2Zero(double x)
log2Zero() - compute log2((x==0.0 ? 0.0 : x) - avoids log2(0.0)! This defaults log2(0.0) to log2(1.0).
Parameters:
x - argument for log2
Returns:
log2((x==0.0 ? 0.0 : x) - avoids log2(0.0)!

log2

public final double log2(double x)
log2() - compute log(x) base 2. Since log2(x)= log2(e)*ln(x).
Parameters:
x - argument for log2
Returns:
log(x) base 2

alog2

public final double alog2(double x)
alog2() - compute alog(x) base 2. Since ln(x)= log2(x)/log2(e) = log2(x) * ln2.
Parameters:
x - argument for alog
Returns:
alog(x) base 2

logZero

public final double logZero(double x)
logZero() - compute log10((x==0.0 ? 0.0 : x) - avoids log(0.0)! This defaults log10(0.0) to log(1.0).
Parameters:
x - argument for log
Returns:
log10((x==0.0 ? 0.0 : x) - avoids log(0.0)!

log10

public final double log10(double x)
log10() - compute log(x) base 10. Since log10(x)= log10e * ln(x).
Parameters:
x - argument for log
Returns:
log(x) base 10

alog10

public final double alog10(double x)
alog10() - compute alog(x) base 10. Since ln(x)= log10(x)/log10(e) = log10(x) * ln10.
Parameters:
x - argument for alog
Returns:
alog(x) base 10