Skip to content

Commit a272ba4

Browse files
committed
reformat code
1 parent 8fec135 commit a272ba4

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

packaging/generate_changelog.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import re
22
import warnings
33
from pathlib import Path
4-
from typing import Union
4+
from typing import Literal, Union
55

66
import rst_to_myst
7-
from typing import Literal
87

98

109
def get_change_log_for(version: Union[str, Literal['latest']] = 'latest'):

rnalysis/utils/enrichment_runner.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -923,11 +923,10 @@ def format_results(self, unformatted_results_list: list):
923923

924924
# filter non-significant results
925925
if not self.return_nonsignificant:
926-
self.results = self.results.filter(pl.col('significant') is True)
927-
926+
self.results = self.results.filter(pl.col('significant'))
928927
def _correct_multiple_comparisons(self):
929-
results_nulls = self.results.filter(pl.col('pval').is_nan())
930-
self.results = self.results.filter(pl.col('pval').is_not_nan())
928+
results_nulls = self.results.filter(pl.col('pval').is_null())
929+
self.results = self.results.filter(pl.col('pval').is_not_null())
931930

932931
significant, padj = multitest.fdrcorrection(self.results['pval'].to_list(), alpha=self.alpha)
933932
self.results = pl.concat([self.results.with_columns(padj=padj, significant=significant), results_nulls],
@@ -1390,6 +1389,7 @@ def _go_classic_on_batch(self, go_term_batch: Iterable[str], annotation_idx: int
13901389
"""
13911390
gene_set = self.ranked_genes if self.single_set else self.gene_set
13921391
annotations = self.mutable_annotations[annotation_idx]
1392+
print(annotations)
13931393
return {go_id: self.stats_test.run(go_id, annotations[go_id], gene_set, self.background_set) for go_id in
13941394
go_term_batch}
13951395

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"""The setup script."""
55

6-
from setuptools import setup, find_packages
6+
from setuptools import find_packages, setup
77

88

99
def get_extra_requires(path, add_all=True):

tests/test_enrichment_runner.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import matplotlib
55
import pytest
6+
from polars.testing import assert_frame_equal
67

78
from rnalysis import filtering
89
from rnalysis.utils import enrichment_runner
@@ -17,7 +18,7 @@ def _df_to_dict(df, null_mode: bool = True):
1718
if null_mode:
1819
return {attr: set(df.filter(pl.col(attr).is_not_null()).select(pl.first()).to_series()) for attr in
1920
df.columns[1:]}
20-
return {attr: set(df.filter(pl.col(attr) is True).select(pl.first()).to_series()) for attr in df.columns[1:]}
21+
return {attr: set(df.filter(pl.col(attr)).select(pl.first()).to_series()) for attr in df.columns[1:]}
2122

2223

2324
def test_enrichment_runner_from_results():
@@ -182,7 +183,7 @@ def test_results_to_csv():
182183
def _compare_go_result_dfs(res, truth):
183184
res = res.sort(pl.first())
184185
truth = truth.sort(pl.first())
185-
assert res.select(pl.col('GO ID', 'n', 'obs')).equals(truth.select(pl.col('GO ID', 'n', 'obs')))
186+
assert_frame_equal(res.select(pl.col('GO ID', 'n', 'obs')),truth.select(pl.col('GO ID', 'n', 'obs')))
186187
assert np.allclose(res.select(pl.col('exp', 'log2fc', 'pval')), res.select(pl.col('exp', 'log2fc', 'pval')), atol=0)
187188

188189

@@ -207,7 +208,6 @@ def __getitem__(self, item):
207208
e.annotations = annotations
208209
e.mutable_annotations = annotations,
209210
e.attributes = list(annotations.keys())
210-
211211
res = pl.DataFrame([i for i in e._go_classic_on_batch(tuple(annotations.keys()), 0).values()],
212212
schema=['GO ID', 'n', 'obs', 'exp', 'log2fc', 'pval'])
213213
_compare_go_result_dfs(res, truth)
@@ -354,7 +354,6 @@ def alt_calc_pval(self, log2fc: float, reps: int, obs_frac: float, bg_size: int,
354354

355355
attr = truth[0]
356356
res = stats_test.run(attr, annotations[attr], gene_set, background_set)
357-
print(res)
358357
assert res == truth
359358

360359

@@ -732,8 +731,6 @@ def test_noncategorical_enrichment_runner_format_results(monkeypatch):
732731
truth = io.load_table('tests/test_files/non_categorical_enrichment_runner_format_results_truth.csv')
733732
runner.return_nonsignificant = True
734733
runner.format_results(results_list)
735-
print(truth)
736-
print(runner.results)
737734
assert truth.equals(runner.results)
738735

739736

@@ -1040,9 +1037,8 @@ def add_sig(self):
10401037
runner.en_score_col = 'colName'
10411038
runner.single_set = False
10421039
runner.return_nonsignificant = return_nonsignificant
1043-
10441040
runner.format_results(results_dict)
1045-
assert truth.equals(runner.results)
1041+
assert_frame_equal(truth, runner.results)
10461042

10471043

10481044
@pytest.mark.parametrize("propagate_annotations,truth",
@@ -1200,7 +1196,6 @@ def _get_annotation_iter_zero(self):
12001196
runner.organism = "organism"
12011197
runner.taxon_id = "taxon id"
12021198
runner._process_annotations()
1203-
print(e)
12041199

12051200

12061201
def test_go_enrichment_runner_process_annotations(monkeypatch):

0 commit comments

Comments
 (0)