Skip to content

parse_binomtest_results

Parses the results of a binomtest into a tuple of floats.

This function takes the results of a binomtest and returns a tuple of floats containing the response ratio, p-value, and confidence interval bounds.

Parameters:

Name Type Description Default
binomtest_obj BinomTestResult

The results of a binomtest for a single rank bin.

required
Additional keyword arguments

Additional keyword arguments are passed to the proportional_ci method of the binomtest object.

required

Returns:

Name Type Description
tuple

A tuple of floats containing the response ratio, p-value, and confidence interval bounds.

Example

parse_binomtest_results(binomtest(1, 2, 0.5, alternative=’greater’) (0.5, 0.75, 0.2, 0.8)

Source code in callingcardstools/Analysis/yeast/rank_response/parse_binomtest_results.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def parse_binomtest_results(binomtest_obj: BinomTestResult, **kwargs):
    """
    Parses the results of a binomtest into a tuple of floats.

    This function takes the results of a binomtest and returns a tuple of
    floats containing the response ratio, p-value, and confidence interval
    bounds.

    Args:
        binomtest_obj (scipy.stats.BinomTestResult): The results of a binomtest
            for a single rank bin.
        Additional keyword arguments: Additional keyword arguments are passed
            to the proportional_ci method of the binomtest object.

    Returns:
        tuple: A tuple of floats containing the response ratio, p-value, and
            confidence interval bounds.

    Example:
        >>> parse_binomtest_results(binomtest(1, 2, 0.5, alternative='greater')
        (0.5, 0.75, 0.2, 0.8)
    """
    return (binomtest_obj.statistic,
            binomtest_obj.pvalue,
            binomtest_obj.proportion_ci(
                confidence_level=kwargs.get('confidence_level', 0.95),
                method=kwargs.get('method', 'exact')).low,
            binomtest_obj.proportion_ci(
                confidence_level=kwargs.get('confidence_level', 0.95),
                method=kwargs.get('method', 'exact')).high)