3
3
from anndata import AnnData
4
4
from ..method_zscore import zscore , run_zscore
5
5
6
+
6
7
def test_zscore ():
7
- m = np .array ([[- 7. , - 1. , 1. , 1. ], [- 4. , - 2. , 1. , 2. ], [1. , 2. , 5. , 1. ], [1. , 1. , 6. , 2. ], [- 8. , - 7. , 1. , 1. ]], dtype = np .float32 )
8
+ m = np .array ([[- 7. , - 1. , 1. , 1. ], [- 4. , - 2. , 1. , 2. ], [1. , 2. , 5. , 1. ],
9
+ [1. , 1. , 6. , 2. ], [- 8. , - 7. , 1. , 1. ]], dtype = np .float32 )
8
10
net = np .array ([[1. , 0. ], [1 , 0. ], [0. , - 1. ], [0. , - 1. ]], dtype = np .float32 )
9
11
act , pvl = zscore (m , net )
10
12
assert act [0 , 0 ] < 0
@@ -13,7 +15,7 @@ def test_zscore():
13
15
assert act [3 , 0 ] > 0
14
16
assert act [4 , 0 ] < 0
15
17
assert np .all ((0. <= pvl ) * (pvl <= 1. ))
16
-
18
+
17
19
act2 , pvl2 = zscore (m , net , flavor = 'KSEA' )
18
20
assert act2 [0 , 0 ] < 0
19
21
assert act2 [1 , 0 ] < 0
@@ -22,6 +24,7 @@ def test_zscore():
22
24
assert act2 [4 , 0 ] < 0
23
25
assert np .all ((0. <= pvl2 ) * (pvl2 <= 1. ))
24
26
27
+
25
28
def test_run_zscore ():
26
29
m = np .array ([[- 7. , - 1. , 1. , 1. ], [- 4. , - 2. , 1. , 2. ], [1. , 2. , 5. , 1. ], [1. , 1. , - 6. , - 8. ], [- 8. , - 7. , 1. , 1. ]])
27
30
r = np .array (['S1' , 'S2' , 'S3' , 'S4' , 'S5' ])
@@ -36,14 +39,14 @@ def test_run_zscore():
36
39
assert res [0 ].loc ['S4' , 'T2' ] > 0
37
40
assert res [0 ].loc ['S5' , 'T2' ] < 0
38
41
assert res [1 ].map (lambda x : 0 <= x <= 1 ).all ().all ()
39
-
42
+
40
43
res2 = run_zscore (df , net , verbose = True , use_raw = False , min_n = 0 , flavor = 'KSEA' )
41
44
assert res2 [0 ].loc ['S1' , 'T2' ] > 0
42
45
assert res2 [0 ].loc ['S2' , 'T2' ] < 0
43
46
assert res2 [0 ].loc ['S3' , 'T2' ] < 0
44
47
assert res2 [0 ].loc ['S4' , 'T2' ] > 0
45
48
assert res2 [0 ].loc ['S5' , 'T2' ] > 0
46
49
assert res2 [1 ].map (lambda x : 0 <= x <= 1 ).all ().all ()
47
-
50
+
48
51
adata = AnnData (df .astype (np .float32 ))
49
- run_zscore (adata , net , verbose = True , use_raw = False , min_n = 0 )
52
+ run_zscore (adata , net , verbose = True , use_raw = False , min_n = 0 )
0 commit comments