[ea0fd6]: / tests / deseq2 / test_LRT.py

Download this file

50 lines (44 with data), 2.0 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
import unittest
from inmoose.deseq2 import DESeq, makeExampleDESeqDataSet, nbinomLRT
from inmoose.utils import Factor
class Test(unittest.TestCase):
def test_LRT(self):
"""test that test='LRT' gives correct errors"""
dds = makeExampleDESeqDataSet(n=100, m=4)
dds.obs["group"] = Factor([1, 2, 1, 2])
dds.design = "~condition"
with self.assertRaisesRegex(
ValueError,
expected_regex="the following variables in the reduced formula not in the full formula: group",
):
DESeq(dds, test="LRT", reduced="~group")
with self.assertRaisesRegex(
ValueError,
expected_regex="test='LRT' does not support use of expanded model matrix",
):
DESeq(dds, test="LRT", reduced="~1", modelMatrixType="expanded")
with self.assertRaisesRegex(
ValueError,
expected_regex="test='LRT' does not support use of LFC shrinkage, use betaPrior=False",
):
DESeq(dds, test="LRT", reduced="~group", betaPrior=True)
dds = dds.estimateSizeFactors()
dds = dds.estimateDispersions()
with self.assertRaisesRegex(
ValueError, expected_regex="provide a reduced formula for the LRT"
):
nbinomLRT(dds)
@unittest.skip("unimplemented")
def test_glmGamPoi(self):
raise NotImplementedError()
def test_LRT2(self):
"""test that test='LRT' with quasi-likelihood estimates gives correct errors"""
dds = makeExampleDESeqDataSet(n=100, m=4)
dds.obs["group"] = Factor([1, 2, 1, 2])
dds.design = "~condition + group"
with self.assertRaises(NotImplementedError):
DESeq(dds, test="Wald", fitType="glmGamPoi")
dds = dds.estimateSizeFactors()
dds_gp = dds.estimateDispersions()
with self.assertRaises(NotImplementedError):
nbinomLRT(dds_gp, reduced="~condition", type_="glmGamPoi")