goatools.multiple_testing module

A list of commonly used multiple correction routines

class goatools.multiple_testing.Methods(usr_methods=None)[source]

Bases: object

Class to manage multipletest methods from both local and remote sources.

all_methods = [('local', ('bonferroni', 'sidak', 'holm', 'fdr')), ('statsmodels', ('bonferroni', 'sidak', 'holm-sidak', 'holm', 'simes-hochberg', 'hommel', 'fdr_bh', 'fdr_by', 'fdr_tsbh', 'fdr_tsbky', 'fdr_gbs'))]
prefixes = {'statsmodels': 'sm_'}
class NtMethodInfo(source, method, fieldname)

Bases: tuple

fieldname

Alias for field number 2

method

Alias for field number 1

source

Alias for field number 0

getmsg_valid_methods()[source]

Return a string containing valid method names.

get_fieldname(method_source, method)[source]

Get the name of the method used to create namedtuple fieldnames which store floats.

rpt_invalid_method(usr_method)[source]

Report which methods are available.

static get_fldnm_method(method)[source]

Given method and source, return fieldname for method.

get_statsmodels_multipletests()[source]

Only load statsmodels package if it is used.

class goatools.multiple_testing.Bonferroni(pvals, a=.05)[source]

Bases: _AbstractCorrection

>>> Bonferroni([0.01, 0.01, 0.03, 0.05, 0.005], a=0.05).corrected_pvals
array([ 0.05 ,  0.05 ,  0.15 ,  0.25 ,  0.025])
set_correction()[source]

Do Bonferroni multiple test correction on original p-values.

class goatools.multiple_testing.Sidak(pvals, a=.05)[source]

Bases: _AbstractCorrection

https://en.wikipedia.org/wiki/%C5%A0id%C3%A1k_correction >>> Sidak([0.01, 0.01, 0.03, 0.05, 0.005], a=0.05).corrected_pvals array([0.04900995, 0.04900995, 0.14125866, 0.22621906, 0.02475125])

set_correction() → None[source]

Do Sidak multiple test correction on original p-values.

class goatools.multiple_testing.HolmBonferroni(pvals, a=.05)[source]

Bases: _AbstractCorrection

http://en.wikipedia.org/wiki/Holm-Bonferroni_method given a list of pvals, perform the Holm-Bonferroni correction and return the indexes from original list that are significant. (cant use p-value as that may be repeated.) >>> HolmBonferroni([0.01, 0.01, 0.03, 0.05, 0.005], a=0.05).corrected_pvals array([0.04 , 0.04 , 0.06 , 0.06 , 0.025])

set_correction() → None[source]

Do Holm-Bonferroni (step-down) multiple test correction on original p-values.

class goatools.multiple_testing.FDR(p_val_distribution, results, a=.05)[source]

Bases: object

Generate a p-value distribution based on re-sampling, as described in: http://www.biomedcentral.com/1471-2105/6/168

goatools.multiple_testing.mcorrection_factory(pvals, alpha, method)[source]

Return ‘multiple correction’ object of requested AbstractCorrection base class.

goatools.multiple_testing.calc_qval(study_n, pop_n, pop, assoc, term_pop, obo_dag, T=500)[source]

Generate p-value distribution for FDR based on resampling.

Always scores with the classic algorithm and a two-sided Fisher test. GOEnrichmentStudy builds its own null that honours the study’s settings.