Skip to content

Commit

Permalink
refactor(summary): set lfc_null and alt_hypothesis as optional keywor…
Browse files Browse the repository at this point in the history
…d arguments
  • Loading branch information
BorisMuzellec committed Sep 7, 2023
1 parent bc41204 commit c7e09d1
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions pydeseq2/ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,35 +209,31 @@ def __init__(

def summary(
self,
lfc_null: Optional[float] = None,
alt_hypothesis: Optional[
Literal["greaterAbs", "lessAbs", "greater", "less", ""]
] = "",
**kwargs,
) -> None:
"""Run the statistical analysis.
The results are stored in the ``results_df`` attribute.
Parameters
----------
lfc_null : float or None
The (log2) log fold change under the null hypothesis. If None, sets the
value at 0. (default: ``None``).
alt_hypothesis : str or None
The alternative hypothesis for computing wald p-values. If None, the normal
Wald test assesses deviation of the estimated log fold change from the null
hypothesis, as given by ``lfc_null``.
One of ["greaterAbs", "lessAbs", "greater", "less", ""] or None. The
alternative hypothesis corresponds to what the user wants to find rather
than the null hypothesis. If empty string "", sets the value at None.
(default: ``""``).
**kwargs
Keyword arguments: providing new values for ``lfc_null`` or
``alt_hypothesis`` will override the corresponding ``DeseqStat`` attributes.
"""

new_lfc_null = kwargs.get("lfc_null", None)
new_alt_hypothesis = kwargs.get("alt_hypothesis", None)

rerun_summary = False
if lfc_null is None:
if new_lfc_null is None:
lfc_null = self.lfc_null
if alt_hypothesis == "":
else:
lfc_null = new_lfc_null
if new_alt_hypothesis is None:
alt_hypothesis = self.alt_hypothesis
else:
alt_hypothesis = new_alt_hypothesis
if lfc_null < 0 and alt_hypothesis in {"greaterAbs", "lessAbs"}:
raise ValueError(
f"The alternative hypothesis being {alt_hypothesis}, please provide a",
Expand Down

0 comments on commit c7e09d1

Please sign in to comment.