acore.multiple_testing package#
- apply_pvalue_correction(pvalues: ndarray, alpha: float = 0.05, method: str = 'bonferroni') tuple[ndarray, ndarray][source]#
Performs p-value correction using the specified method as in statsmodels.stats.multitest.multipletests.
- Parameters:
pvalues (numpy.ndarray) – et of p-values of the individual tests.
alpha (float) – error rate.
method (str) –
method of p-value correction:
’bonferroni’ : one-step correction
’sidak’ : one-step correction
’holm-sidak’ : step down method using Sidak adjustments
’holm’ : step-down method using Bonferroni adjustments
’simes-hochberg’ : step-up method (independent)
’hommel’ : closed method based on Simes tests (non-negative)
’fdr_bh’ : Benjamini/Hochberg (non-negative)
’fdr_by’ : Benjamini/Yekutieli (negative)
’fdr_tsbh’ : two stage fdr correction (non-negative)
’fdr_tsbky’ : two stage fdr correction (non-negative)
- Returns:
Tuple with two numpy.array`s, boolen for rejecting H0 hypothesis and float for adjusted p-value. Can contain missing values if `pvalues contain missing values.
Example:
result = apply_pvalue_correction(pvalues, alpha=0.05, method='bonferroni')
- apply_pvalue_fdrcorrection(pvalues, alpha=0.05, method='indep')[source]#
Performs p-value correction for false discovery rate. For more information visit https://www.statsmodels.org/devel/generated/statsmodels.stats.multitest.fdrcorrection.html.
- Parameters:
pvalues (numpy.ndarray) – et of p-values of the individual tests.
alpha (float) – error rate.
method (str) – method of p-value correction (‘indep’, ‘negcorr’).
- Returns:
Tuple with two arrays, boolen for rejecting H0 hypothesis and float for adjusted p-value.
Example:
result = apply_pvalue_fdrcorrection(pvalues, alpha=0.05, method='indep')
- apply_pvalue_twostage_fdrcorrection(pvalues, alpha=0.05, method='bh')[source]#
Iterated two stage linear step-up procedure with estimation of number of true hypotheses. For more information visit https://www.statsmodels.org/dev/generated/statsmodels.stats.multitest.fdrcorrection_twostage.html.
- Parameters:
pvalues (numpy.ndarray) – et of p-values of the individual tests.
alpha (float) – error rate.
method (str) – method of p-value correction (‘bky’, ‘bh’).
- Returns:
Tuple with two arrays, boolen for rejecting H0 hypothesis and float for adjusted p-value.
Example:
result = apply_pvalue_twostage_fdrcorrection(pvalues, alpha=0.05, method='bh')
- apply_pvalue_permutation_fdrcorrection(df, observed_pvalues, group, alpha=0.05, permutations=50)[source]#
This function applies multiple hypothesis testing correction using a permutation-based false discovery rate approach.
- Parameters:
df – pandas dataframe with samples as rows and features as columns.
oberved_pvalues – pandas Series with p-values calculated on the originally measured data.
group (str) – name of the column containing group identifiers.
alpha (float) – error rate. Values velow alpha are considered significant.
permutations (int) – number of permutations to be applied.
- Returns:
Pandas dataframe with adjusted p-values and rejected columns.
Example:
result = apply_pvalue_permutation_fdrcorrection(df, observed_pvalues, group='group', alpha=0.05, permutations=50)
- get_counts_permutation_fdr(value, random, observed, n, alpha)[source]#
Calculates local FDR values (q-values) by computing the fraction of accepted hits from the permuted data over accepted hits from the measured data normalized by the total number of permutations.
- Parameters:
value (float) – computed p-value on measured data for a feature.
random (numpy.ndarray) – p-values computed on the permuted data.
observed – pandas Series with p-values calculated on the originally measured data.
n (int) – number of permutations to be applied.
alpha (float) – error rate. Values velow alpha are considered significant.
- Returns:
Tuple with q-value and boolean for H0 rejected.
Example:
result = get_counts_permutation_fdr(value, random, observed, n=250, alpha=0.05)