Skip to content

Commit

Permalink
test: update control genes test case
Browse files Browse the repository at this point in the history
  • Loading branch information
BorisMuzellec committed Jan 10, 2025
1 parent f72754a commit bf3af26
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions tests/test_pydeseq2.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,22 @@ def test_size_factors_poscounts(counts_df, metadata):
def test_size_factors_control_genes(counts_df, metadata):
"""Test that the size_factors calculation properly takes control_genes"""

dds = DeseqDataSet(counts=counts_df, metadata=metadata, design="~condition")

dds.fit_size_factors(control_genes=["gene4"])

np.testing.assert_almost_equal(
dds.obsm["size_factors"].ravel(),
counts_df["gene4"] / np.exp(np.log(counts_df["gene4"]).mean()),
dds = DeseqDataSet(
counts=counts_df, metadata=metadata, design="~condition", control_genes=["gene4"]
)

dds.fit_size_factors(fit_type="poscounts", control_genes=[3])
dds.fit_size_factors()

np.testing.assert_almost_equal(
dds.obsm["size_factors"].ravel(),
counts_df["gene4"] / np.exp(np.log(counts_df["gene4"]).mean()),
)

# We should have gene4 as control gene again.
dds.fit_size_factors(fit_type="poscounts")

np.testing.assert_raises(
AssertionError,
np.testing.assert_array_equal,
# Gene 4 has no zero counts, so we should get the same as before
np.testing.assert_almost_equal(
dds.obsm["size_factors"].ravel(),
counts_df["gene4"] / np.exp(np.log(counts_df["gene4"]).mean()),
)
Expand Down

0 comments on commit bf3af26

Please sign in to comment.