Skip to content

Commit 4ad1b06

Browse files
committed
Flake8
1 parent 9798266 commit 4ad1b06

8 files changed

+18
-16
lines changed

decoupler/method_aucell.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import pandas as pd
88
from scipy.sparse import csr_matrix
99

10-
from numpy.random import default_rng
1110
from tqdm.auto import tqdm
1211

1312
from .pre import extract, rename_net, filt_min_n, return_data, break_ties

decoupler/method_gsva.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import numpy as np
77
import pandas as pd
88

9-
from scipy.stats import norm
109
from scipy.sparse import csr_matrix
11-
from numpy.random import default_rng
1210
import math
1311

1412
from .pre import extract, rename_net, filt_min_n, return_data, break_ties
@@ -36,6 +34,7 @@ def erf(x):
3634
y = 1.0 - (((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t * np.exp(-abs_x * abs_x))
3735
return sign * y
3836

37+
3938
@nb.njit(nb.f8[:](nb.f8[:], nb.f8, nb.f8), cache=True)
4039
def norm_cdf(x, mu=0.0, sigma=1.0):
4140
e = erf((x - mu) / (sigma * np.sqrt(2.0)))

decoupler/method_ora.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import numpy as np
77
import pandas as pd
88

9-
from numpy.random import default_rng
109
from scipy.sparse import csr_matrix
1110

1211
from scipy.stats import rankdata

decoupler/method_udt.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from tqdm.auto import tqdm
1313

14+
1415
def check_if_sklearn():
1516
try:
1617
import sklearn as sk

decoupler/method_zscore.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ def zscore(m, net, flavor='RoKAI', verbose=False):
2525

2626

2727
def run_zscore(mat, net, source='source', target='target', weight='weight', batch_size=10000, flavor='RoKAI',
28-
min_n=5, verbose=False, use_raw=True):
28+
min_n=5, verbose=False, use_raw=True):
2929
"""
3030
z-score.
3131
32-
Calculates regulatory activities using a z-score as descibed in KSEA or RoKAI. The z-score calculates the mean of the molecular features of the
33-
known targets for each regulator and adjusts it for the number of identified targets for the regulator, the standard deviation of all molecular
34-
features (RoKAI), as well as the mean of all moleculare features (KSEA).
32+
Calculates regulatory activities using a z-score as descibed in KSEA or RoKAI. The z-score calculates the mean of the
33+
molecular features of the known targets for each regulator and adjusts it for the number of identified targets for the
34+
regulator, the standard deviation of all molecular features (RoKAI), as well as the mean of all moleculare features (KSEA).
3535
3636
Parameters
3737
----------
@@ -74,7 +74,8 @@ def run_zscore(mat, net, source='source', target='target', weight='weight', batc
7474
net = match(c, targets, net)
7575

7676
if verbose:
77-
print('Running zscore on mat with {0} samples and {1} targets for {2} sources.'.format(m.shape[0], len(c), net.shape[1]))
77+
print('Running zscore on mat with {0} samples and {1} targets for {2} sources.'.format(
78+
m.shape[0], len(c), net.shape[1]))
7879

7980
# Run ULM
8081
estimate, pvals = zscore(m, net, flavor=flavor)

decoupler/pre.py

-1
Original file line numberDiff line numberDiff line change
@@ -307,4 +307,3 @@ def break_ties(m, c, seed):
307307
idx = rng.choice(idx, c.size, replace=False)
308308
m, c = m[:, idx], c[idx]
309309
return m, c
310-

decoupler/tests/test_gsva.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def test_ppois():
4242

4343

4444
def test_norm_cdf():
45-
assert np.isclose(norm_cdf(np.array([1, 2, 3], dtype=float), mu=0.0, sigma=1.0), np.array([0.8413447, 0.9772499, 0.9986501])).all()
45+
assert np.isclose(norm_cdf(np.array([1, 2, 3], dtype=float), mu=0.0, sigma=1.0),
46+
np.array([0.8413447, 0.9772499, 0.9986501])).all()
4647
assert np.isclose(norm_cdf(np.array([0, 9, 1], dtype=float), mu=0.0, sigma=1.0), np.array([0.5, 1., 0.8413447])).all()
4748

4849

decoupler/tests/test_zscore.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
from anndata import AnnData
44
from ..method_zscore import zscore, run_zscore
55

6+
67
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)
810
net = np.array([[1., 0.], [1, 0.], [0., -1.], [0., -1.]], dtype=np.float32)
911
act, pvl = zscore(m, net)
1012
assert act[0, 0] < 0
@@ -13,7 +15,7 @@ def test_zscore():
1315
assert act[3, 0] > 0
1416
assert act[4, 0] < 0
1517
assert np.all((0. <= pvl) * (pvl <= 1.))
16-
18+
1719
act2, pvl2 = zscore(m, net, flavor='KSEA')
1820
assert act2[0, 0] < 0
1921
assert act2[1, 0] < 0
@@ -22,6 +24,7 @@ def test_zscore():
2224
assert act2[4, 0] < 0
2325
assert np.all((0. <= pvl2) * (pvl2 <= 1.))
2426

27+
2528
def test_run_zscore():
2629
m = np.array([[-7., -1., 1., 1.], [-4., -2., 1., 2.], [1., 2., 5., 1.], [1., 1., -6., -8.], [-8., -7., 1., 1.]])
2730
r = np.array(['S1', 'S2', 'S3', 'S4', 'S5'])
@@ -36,14 +39,14 @@ def test_run_zscore():
3639
assert res[0].loc['S4', 'T2'] > 0
3740
assert res[0].loc['S5', 'T2'] < 0
3841
assert res[1].map(lambda x: 0 <= x <= 1).all().all()
39-
42+
4043
res2 = run_zscore(df, net, verbose=True, use_raw=False, min_n=0, flavor='KSEA')
4144
assert res2[0].loc['S1', 'T2'] > 0
4245
assert res2[0].loc['S2', 'T2'] < 0
4346
assert res2[0].loc['S3', 'T2'] < 0
4447
assert res2[0].loc['S4', 'T2'] > 0
4548
assert res2[0].loc['S5', 'T2'] > 0
4649
assert res2[1].map(lambda x: 0 <= x <= 1).all().all()
47-
50+
4851
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

Comments
 (0)