Skip to content

Commit

Permalink
Run black formatting on python test scripts.
Browse files Browse the repository at this point in the history
Run black formatting on python test scripts.
  • Loading branch information
ghuls committed Nov 21, 2022
1 parent b05f102 commit 61af4c6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
18 changes: 13 additions & 5 deletions tests/test_aucell.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@
from pyscenic.aucell import aucell, create_rankings, derive_auc_threshold

NOMENCLATURE = "HGNC"
TEST_EXPRESSION_MTX_FNAME = resource_filename('resources.tests', "GSE103322.em.hgnc.sample.cxg.csv")
TEST_SIGNATURE_FNAME = resource_filename('resources.tests', "c6.all.v6.1.symbols.gmt")
TEST_EXPRESSION_MTX_FNAME = resource_filename(
"resources.tests", "GSE103322.em.hgnc.sample.cxg.csv"
)
TEST_SIGNATURE_FNAME = resource_filename("resources.tests", "c6.all.v6.1.symbols.gmt")


@pytest.fixture
def exp_matrix():
return pd.read_csv(TEST_EXPRESSION_MTX_FNAME, sep=',', header=0, index_col=0)
return pd.read_csv(TEST_EXPRESSION_MTX_FNAME, sep=",", header=0, index_col=0)


@pytest.fixture
def gs():
return GeneSignature.from_gmt(TEST_SIGNATURE_FNAME, gene_separator="\t", field_separator="\t", )
return GeneSignature.from_gmt(
TEST_SIGNATURE_FNAME,
gene_separator="\t",
field_separator="\t",
)


def test_create_rankings(exp_matrix):
Expand All @@ -41,6 +47,8 @@ def test_aucell_w2(exp_matrix, gs):

def test_aucell_mismatch(exp_matrix, gs):
percentiles = derive_auc_threshold(exp_matrix)
gss = [GeneSignature(name="test", gene2weight=list(map("FAKE{}".format, range(100))))] + gs
gss = [
GeneSignature(name="test", gene2weight=list(map("FAKE{}".format, range(100))))
] + gs
aucs_mtx = aucell(exp_matrix, gss, auc_threshold=percentiles[0.01], num_workers=1)
print(aucs_mtx.head())
22 changes: 11 additions & 11 deletions tests/test_featureseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@


def test_feature_overlap():
f1 = Feature.from_string('chr1 12 50 feature1 10.0 +')
f2 = Feature.from_string('chr1 40 60 feature2 10.0 -')
f3 = Feature.from_string('chr1 60 80 feature2 10.0 -')
f4 = Feature.from_string('chr2 60 80 feature2 10.0 -')
f1 = Feature.from_string("chr1 12 50 feature1 10.0 +")
f2 = Feature.from_string("chr1 40 60 feature2 10.0 -")
f3 = Feature.from_string("chr1 60 80 feature2 10.0 -")
f4 = Feature.from_string("chr2 60 80 feature2 10.0 -")
assert f1.has_overlap_with(f2)
assert not f1.has_overlap_with(f3)
assert not f3.has_overlap_with(f4)
assert not f2.has_overlap_with(f3)


def test_feature_contains():
f1 = Feature.from_string('chr1 50 60 feature1 10.0 +')
f2 = Feature.from_string('chr1 40 60 feature2 10.0 -')
f3 = Feature.from_string('chr2 40 80 feature2 10.0 -')
f1 = Feature.from_string("chr1 50 60 feature1 10.0 +")
f2 = Feature.from_string("chr1 40 60 feature2 10.0 -")
f3 = Feature.from_string("chr2 40 80 feature2 10.0 -")
assert f1 in f2
assert not f1 in f3


def test_feature_bp_overlap():
f1 = Feature.from_string('chr1 12 50 feature1 10.0 +')
f2 = Feature.from_string('chr1 40 60 feature2 10.0 -')
f3 = Feature.from_string('chr1 60 80 feature2 10.0 -')
f4 = Feature.from_string('chr2 60 80 feature2 10.0 -')
f1 = Feature.from_string("chr1 12 50 feature1 10.0 +")
f2 = Feature.from_string("chr1 40 60 feature2 10.0 -")
f3 = Feature.from_string("chr1 60 80 feature2 10.0 -")
f4 = Feature.from_string("chr2 60 80 feature2 10.0 -")
assert f1.get_overlap_in_bp_with(f2) == 10
assert f1.get_overlap_in_bp_with(f3) == 0
assert f2.get_overlap_in_bp_with(f3) == 0
Expand Down
6 changes: 4 additions & 2 deletions tests/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
def test_masked_rho():
x = np.array([1, 2, -1, 0.0, 4], dtype=float)
y = np.array([1, 2, 0.0, -8, 4], dtype=float)
assert pytest.approx(masked_rho(x, y, 0.0), 0.00001) == \
np.corrcoef(np.array([1.0, 2.0, 4.0]), np.array([1.0, 2.0, 4.0]))[0, 1]
assert (
pytest.approx(masked_rho(x, y, 0.0), 0.00001)
== np.corrcoef(np.array([1.0, 2.0, 4.0]), np.array([1.0, 2.0, 4.0]))[0, 1]
)

0 comments on commit 61af4c6

Please sign in to comment.