nuget server logo nuget api documents
↑

API Docs / Microsoft.VisualBasic.Math.Statistics.Hypothesis.mHG / mHGtest

mHGtest

Full name Microsoft.VisualBasic.Math.Statistics.Hypothesis.mHG.mHGtest Assembly Microsoft.VisualBasic.Math.Statistics.Hypothesis.mHG Members 12

01 Syntax

Microsoft.VisualBasic.Math.Statistics.Hypothesis.mHG.mHGtest

02 Methods

NameOverloadsSummary
sumFirst 1 sum(HG_row[1:b]) in the R reference, which is the sum of the first b hypergeometric probabilities HG_row(i) = Prob(X == i), i < b.
mHGtest 1 Performs a minimum-hypergeometric test.
mHGstatisticcalc 1 Calculates the mHG statistic.
mHGpvalcalc 1 Calculates the p-value associated with the mHG statistic.
R_separation_linecalc 1 Determine R separation line - This Is the highest (broken) line crossing the B*W matrix horizontally, that underneath it all the associated p-values are higher than p, Or w + b >…
pi_rcalc 1 Consider an urn With N balls, B Of which are black And W white.
HG_row_ncalc_func 1 Calculate HG row n. This row contains the first (b_n + 1) hypergeometric probabilities, HG[i] = Prob(X == (i - 1)), For number Of tries n. Does so given an updated HG row m (m <…
d_ratio 1 The ratio between HG(n,b,B,N) And HG(n-1,b-1,B,N) See page 19 In Eden's thesis.
v_ratio 2 The vectorized version of mHGtest.v_ratio()), equals to the R call v_ratio(n, b, N, B) when b is a vector of integers.

03 Fields

NameOverloadsSummary
EPSILON 2 We define EPSILON to account for small changes in the calculation of p-value between the Function calculating the statistic And this Function calculating the p-values Specificall…

04 Members

method sumFirst #
sumFirst(Vector, Int32)

sum(HG_row[1:b]) in the R reference, which is the sum of the first b hypergeometric probabilities HG_row(i) = Prob(X == i), i < b.

Parameters
NameTypeDescription
HG_rowVector

-

bInt32

the number of probabilities that should be accumulated.

method mHGtest #
mHGtest(Vector, Double)

Performs a minimum-hypergeometric test.

Test Is based On the following thesis:

Eden, E. (2007). Discovering Motifs In Ranked Lists Of DNA Sequences. Haifa. Retrieved from http://bioinfo.cs.technion.ac.il/people/zohar/thesis/eran.pdf

The null-hypothesis Is that the 1S In the lambda list are randomly And uniformly distributed In the lambdas list. The alternative hypothesis Is that the 1S tend To appeard In the top Of the list. As the designation Of "top" Is Not a clear-cut multiple hypergeometric tests are performed, With increasing length Of lambdas being considered To be In the "top". The statistic Is the minimal p-value obtained In those tests. A p-value Is calculated Based On the statistics.

Remarks

equals to the R function mHG.test(lambdas, n_max = length(lambdas))

Parameters
NameTypeDescription
lambdasVector

{0,1}^N, sorted from top to bottom.

n_max#Double

the algorithm will only consider the first n_max partitions.

method mHGstatisticcalc #
mHGstatisticcalc(Vector, Double)

Calculates the mHG statistic.

mHG(lambdas) = min over 1 <= n <= N of HGT (b_n(lambdas); N, B, n)

Where HGT Is the hypergeometric tail:

HGT(b; N, B, n) = Probability(X >= b)

And: b_n = sum over 1 <= i <= n of lambdas[i]

If several n gives the same mHG, then the lowest one Is taken.

Parameters
NameTypeDescription
lambdasVector

sorted And labeled {0,1}^N.

n_max#Double

the algorithm will only consider the first n_max partitions.

method mHGpvalcalc #
mHGpvalcalc(Double, Int32, Double, Double)

Calculates the p-value associated with the mHG statistic. Guidelines for the calculation are to be found in:

Eden, E. (2007). Discovering Motifs in Ranked Lists of DNA Sequences. Haifa. Retrieved from http://bioinfo.cs.technion.ac.il/people/zohar/thesis/eran.pdf (pages 11-12, 19-20)

Parameters
NameTypeDescription
pDouble

the mHG statistic. Marked as p, as it represenets an "uncorrected" p-value.

NInt32

total number of white And black balls (according to the hypergeometric problem definition).

BDouble

number of black balls.

n_maxDouble

the algorithm will calculate the p-value under the null hypothesis that only the first n_max partitions are taken into account in determining in minimum.

Returns

p-value.

method R_separation_linecalc #
R_separation_linecalc(Double, Int32, Int32, Int32)

Determine R separation line - This Is the highest (broken) line crossing the B*W matrix horizontally, that underneath it all the associated p-values are higher than p, Or w + b > n_max.

(This Is a bit different from the original definition To make the calculation more efficient)

Remarks

See Eden, E. (2007) pages 11-12.

Parameters
NameTypeDescription
pDouble

the mHG statistic. Marked As p, As it represenets an "uncorrected" p-value.

NInt32

total number Of white And black balls (according To the hypergeometric problem definition).

BInt32

number Of black balls.

n_maxInt32

Part Of the constraint On the line, the null hypothesis Is calculated under the assumption that the first n_max partitions are taken into account In determining the minimum.

Returns

R_separation_line - represented As a vector size B + 1, index b containing the first (high enough) w To the right Of the R separation line (Or W + 1 If no such w exist).

method pi_rcalc #
pi_rcalc(Int32, Int32, Vector)

Consider an urn With N balls, B Of which are black And W white. pi_r stores The probability Of drawing w white And b black balls In n draws (n = w + b) With the constraint Of P(w,b) = 0 If (w, b) Is On Or above separation line.

R's row 1 Of the matrix represents w = -1, col 1 represents b = -1; therefore the 0-based matrix here uses row 0 / col 0 fer the w = -1/b = -1 padding.

Remarks

See Eden, E. (2007) page 20.

Parameters
NameTypeDescription
NInt32

total number Of white And black balls (according To the hypergeometric problem definition).

BInt32

number Of black balls.

R_separation_lineVector

represented As a vector size B + 1, index b containing the first (high enough) w To the right Of the R separation line.

method HG_row_ncalc_func #
HG_row_ncalc_func(Vector, Int32, Int32, Double, Int32, Int32, Int32)

Calculate HG row n. This row contains the first (b_n + 1) hypergeometric probabilities, HG[i] = Prob(X == (i - 1)), For number Of tries n. Does so given an updated HG row m (m < n), which contains the first (b_n) hypergeometric probabilities.

Parameters
NameTypeDescription
HG_row_mVector

updated HG row m (m < n), which contains the first (b_n) hypergeometric probabilities.

mInt32

the number Of tries (m < n) For which the HG_row_m fits.

niInt32

the number Of tries (n > m) For which we want To calculate the HG row

b_nDouble

The maximal b For which we need To calculate the hypergeometric probabilities.

NInt32

total number Of white And black balls (according To the hypergeometric problem definition).

BInt32

number Of black balls.

RECURSION_OVERHEAD_MULTIPLIERInt32

The Function directs the calculation To an iteration solution (With the cost Of B(n-m)) Or a recursive solution (With the cost B * log(B)). This multiplier helps To determine When To use the recursion solution - it Is Not a theoretical result, but an empirical one.

method d_ratio #
d_ratio(Double, Double, Double, Double)

The ratio between HG(n,b,B,N) And HG(n-1,b-1,B,N) See page 19 In Eden's thesis.

equals to the R expression: d_ratio = n * (B - (b - 1)) / (b * (N - (n - 1)))

method v_ratio overload 2 #
v_ratio(Double, Double, Double, Double)

The ratio between HG(n,b,B,N) And HG(n-1,b,B,N) See page 19 In Eden's thesis.

equals to the R expression: v_ratio = (n * (N - n - B + b + 1)) / ((n - b) * (N - n + 1))

method v_ratio #
v_ratio(Double, Vector, Double, Double)

The vectorized version of mHGtest.v_ratio(), equals to the R call v_ratio(n, b, N, B) when b is a vector of integers.

field EPSILON #
EPSILON

We define EPSILON to account for small changes in the calculation of p-value between the Function calculating the statistic And this Function calculating the p-values Specifically, If (statistic + EPSILON) Is higher than the hypergeometric tail associated by a cell In the W*B path matrix, used In the p-value calculation, Then the cell Is Not In the "R region" We warn if the mHG statistic gets below -EPSILON

field EPSILON #
EPSILON