a b/tests/deseq2/test_interactions.py
1
import unittest
2
3
import numpy as np
4
import patsy
5
6
from inmoose.deseq2 import DESeq, makeExampleDESeqDataSet
7
from inmoose.utils import Factor
8
9
10
@unittest.skip("lfcShrink is not implemented")
11
class Test(unittest.TestCase):
12
    def test_interation_errors(self):
13
        """test that interactions throw errors"""
14
        dds = makeExampleDESeqDataSet(n=100, m=8)
15
        dds.obs["group"] = Factor(np.repeat(["X", "Y"], dds.n_obs / 2))
16
        dds.design = "~ condition + group + condition:group"
17
        dds = DESeq(dds)
18
        self.assertEqual(dds.resultsNames()[3], "conditionB.groupY")
19
20
        # interactions error
21
        with self.assertRaisesRegex(
22
            ValueError, expected_regex="designs with interations"
23
        ):
24
            DESeq(dds, betaPrior=True)
25
26
        # also lfcShrink
27
        res = dds.results(name="conditionB.groupY")
28
        with self.assertRaises(NotImplementedError):
29
            res = lfcShrink(dds, coef=4, res=res, type="normal")  # noqa: F821
30
31
        res = dds.results(contrast=["condition", "B", "A"])
32
        with self.assertRaises(NotImplementedError):
33
            res = lfcShrink(  # noqa: F821
34
                dds, contrast=["condition", "B", "A"], res=res, type="normal"
35
            )
36
37
        # however, this is allowed
38
        dds2 = dds.copy()
39
        dds2.design = patsy.dmatrix("~ condition + group + condition:group", dds2.obs)
40
        dds2 = DESeq(dds2)
41
        dds2.results(name="conditionB.groupY")
42
        lfcShrink(dds2, coef=4, res=res, type="normal")  # noqa: F821