[b44cdf]: / tests / deseq2 / test_DESeq.py

Download this file

59 lines (51 with data), 2.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import unittest
import patsy
from inmoose.deseq2 import DESeq, makeExampleDESeqDataSet
from inmoose.utils import Factor
class Test(unittest.TestCase):
def test_DESeq(self):
"""test that DESeq() gives correct errors"""
dds = makeExampleDESeqDataSet(n=100, m=8)
with self.assertRaisesRegex(
ValueError,
expected_regex="likelihood ratio test requires a 'reduced' design",
):
DESeq(dds, test="LRT")
with self.assertRaisesRegex(
ValueError, expected_regex="'reduced' ignored when test='Wald'"
):
DESeq(dds, test="Wald", full="~condition", reduced="~1")
with self.assertRaisesRegex(
ValueError,
expected_regex="'full' specified as formula should match obj.design",
):
DESeq(dds, full="~1")
m = patsy.dmatrix("~condition", dds.obs)
with self.assertRaisesRegex(
ValueError,
expected_regex="if one of 'full' or 'reduced' is a matrix, the other must also be a matrix",
):
DESeq(dds, test="LRT", full=m, reduced="~1")
with self.assertRaisesRegex(
ValueError,
expected_regex="the number of columns of 'full' should be larger than the number of columns of 'reduced'",
):
DESeq(dds, test="LRT", full=m, reduced=m)
with self.assertRaisesRegex(
ValueError,
expected_regex="'betaPrior'=True is not supported for user-provided model matrices",
):
DESeq(dds, full=m, betaPrior=True)
dds.design = "~0 + condition"
with self.assertRaisesRegex(
ValueError,
expected_regex="betaPrior=True can only be used if the design has an intercept. If not, use betaPrior=False",
):
DESeq(dds, betaPrior=True)
dds = makeExampleDESeqDataSet(n=100)
dds.obs["condition"] = Factor(dds.obs["condition"]).add_categories("C")
dds.design = "~condition"
with self.assertRaisesRegex(
ValueError, expected_regex="full model matrix is not full rank"
):
DESeq(dds)