Diff of /tests/deseq2/test_LRT.py [000000] .. [ea0fd6]

Switch to unified view

a b/tests/deseq2/test_LRT.py
1
import unittest
2
3
from inmoose.deseq2 import DESeq, makeExampleDESeqDataSet, nbinomLRT
4
from inmoose.utils import Factor
5
6
7
class Test(unittest.TestCase):
8
    def test_LRT(self):
9
        """test that test='LRT' gives correct errors"""
10
        dds = makeExampleDESeqDataSet(n=100, m=4)
11
        dds.obs["group"] = Factor([1, 2, 1, 2])
12
        dds.design = "~condition"
13
        with self.assertRaisesRegex(
14
            ValueError,
15
            expected_regex="the following variables in the reduced formula not in the full formula: group",
16
        ):
17
            DESeq(dds, test="LRT", reduced="~group")
18
        with self.assertRaisesRegex(
19
            ValueError,
20
            expected_regex="test='LRT' does not support use of expanded model matrix",
21
        ):
22
            DESeq(dds, test="LRT", reduced="~1", modelMatrixType="expanded")
23
        with self.assertRaisesRegex(
24
            ValueError,
25
            expected_regex="test='LRT' does not support use of LFC shrinkage, use betaPrior=False",
26
        ):
27
            DESeq(dds, test="LRT", reduced="~group", betaPrior=True)
28
        dds = dds.estimateSizeFactors()
29
        dds = dds.estimateDispersions()
30
        with self.assertRaisesRegex(
31
            ValueError, expected_regex="provide a reduced formula for the LRT"
32
        ):
33
            nbinomLRT(dds)
34
35
    @unittest.skip("unimplemented")
36
    def test_glmGamPoi(self):
37
        raise NotImplementedError()
38
39
    def test_LRT2(self):
40
        """test that test='LRT' with quasi-likelihood estimates gives correct errors"""
41
        dds = makeExampleDESeqDataSet(n=100, m=4)
42
        dds.obs["group"] = Factor([1, 2, 1, 2])
43
        dds.design = "~condition + group"
44
        with self.assertRaises(NotImplementedError):
45
            DESeq(dds, test="Wald", fitType="glmGamPoi")
46
        dds = dds.estimateSizeFactors()
47
        dds_gp = dds.estimateDispersions()
48
        with self.assertRaises(NotImplementedError):
49
            nbinomLRT(dds_gp, reduced="~condition", type_="glmGamPoi")