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.py
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
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,
    )