Skip to content

Commit

Permalink
docs: add missing docstrings in new DeseqStats methods
Browse files Browse the repository at this point in the history
  • Loading branch information
BorisMuzellec committed Oct 29, 2024
1 parent f06390a commit 46ac4c4
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions pydeseq2/ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DeseqStats:
contrast : list or ndarray
Either a list of three strings or a numpy array.
IF a list of three strings, it must be in the following format:
If a list of three strings, it must be in the following format:
``['variable_of_interest', 'tested_level', 'ref_level']``.
Names must correspond to the metadata data passed to the DeseqDataSet.
E.g., ``['condition', 'B', 'A']`` will measure the LFC of 'condition B' compared
Expand Down Expand Up @@ -576,7 +576,6 @@ def objective(a: float) -> float:
else:
return root_scalar(objective, bracket=[min_var, max_var]).root

# TODO throw errors if the contrast is not valid
def _build_contrast_vector(self) -> None:
"""
Build a vector corresponding to the desired contrast.
Expand All @@ -599,18 +598,35 @@ def _contrast(self, column: str, baseline: str, group_to_compare: str) -> np.nda
```
model.cond(<column> = baseline) - model.cond(<column> = group_to_compare)
```
Parameters
----------
column: str
The column to contrast.
baseline: str
The baseline group.
group_to_compare: str
The group to compare to the baseline.
Returns
-------
np.ndarray
The contrast vector.
"""
return self.cond(**{column: baseline}) - self.cond(**{column: group_to_compare})

def cond(self, **kwargs):
"""
Get a contrast vector representing a specific condition.
Args:
**kwargs: column/value pairs.
Parameters
----------
**kwargs
Column/value pairs.
Returns
-------
ndarray
A contrast vector that aligns to the columns of the design matrix.
"""
cond_dict = kwargs
Expand Down

0 comments on commit 46ac4c4

Please sign in to comment.