Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
test: add test for StatsmodelsDE with NegativeBinomial model
Browse files Browse the repository at this point in the history
  • Loading branch information
BorisMuzellec committed Nov 28, 2023
1 parent 47f033d commit 361cc08
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions tests/test_de.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import anndata as ad
import numpy as np
import pytest
import statsmodels.api as sm
from pydeseq2.utils import load_example_data

import multi_condition_comparisions
Expand Down Expand Up @@ -28,11 +29,22 @@ def test_adata():
return ad.AnnData(X=counts, obs=metadata)


@pytest.mark.parametrize("method_class", [StatsmodelsDE])
def test_de(test_adata, method_class: BaseMethod):
@pytest.mark.parametrize(
"method_class,kwargs",
[
# OLS
(StatsmodelsDE, {}),
# Negative Binomial
(
StatsmodelsDE,
{"regression_model": sm.GLM, "family": sm.families.NegativeBinomial()},
),
],
)
def test_de(test_adata, method_class: BaseMethod, kwargs):
"""Check that the method can be initialized and fitted and that the test_contrast
method returns a dataframe with the correct number of rows"""
method = method_class(adata=test_adata, design="~condition")
method.fit()
method.fit(**kwargs)
res_df = method.test_contrasts(np.array([0, 1]))
assert len(res_df) == test_adata.n_vars

0 comments on commit 361cc08

Please sign in to comment.