|
a |
|
b/tests/edgepy/test_lik.py |
|
|
1 |
import unittest |
|
|
2 |
|
|
|
3 |
import numpy as np |
|
|
4 |
|
|
|
5 |
from inmoose.edgepy import DGEList, adjustedProfileLik |
|
|
6 |
from inmoose.utils import rnbinom |
|
|
7 |
|
|
|
8 |
|
|
|
9 |
class test_APL(unittest.TestCase): |
|
|
10 |
def setUp(self): |
|
|
11 |
y = np.array(rnbinom(80, size=5, mu=20, seed=42)).reshape((20, 4)) |
|
|
12 |
y = np.vstack(([0, 0, 0, 0], [0, 0, 2, 2], y)) |
|
|
13 |
self.group = np.array([1, 1, 2, 2]) |
|
|
14 |
self.d = DGEList(counts=y, group=self.group, lib_size=np.arange(1001, 1005)) |
|
|
15 |
|
|
|
16 |
def test_adjustedProfileLik(self): |
|
|
17 |
apl = adjustedProfileLik( |
|
|
18 |
0.05, |
|
|
19 |
self.d.counts, |
|
|
20 |
np.ones((self.d.counts.shape[1], 1)), |
|
|
21 |
self.d.getOffset(), |
|
|
22 |
) |
|
|
23 |
ref = [ |
|
|
24 |
np.inf, |
|
|
25 |
-6.052019642, |
|
|
26 |
-14.4426662, |
|
|
27 |
-12.70072688, |
|
|
28 |
-23.58414577, |
|
|
29 |
-17.64428625, |
|
|
30 |
-15.06042351, |
|
|
31 |
-18.9616632, |
|
|
32 |
-12.42791699, |
|
|
33 |
-18.5664074, |
|
|
34 |
-15.50008961, |
|
|
35 |
-13.15651905, |
|
|
36 |
-18.58032921, |
|
|
37 |
-16.07588861, |
|
|
38 |
-14.2002113, |
|
|
39 |
-15.92987782, |
|
|
40 |
-12.68396098, |
|
|
41 |
-24.62550341, |
|
|
42 |
-17.70222029, |
|
|
43 |
-15.50752335, |
|
|
44 |
-14.39845558, |
|
|
45 |
-13.04470154, |
|
|
46 |
] |
|
|
47 |
self.assertTrue(np.allclose(apl, ref, atol=0, rtol=1e-9)) |