Skip to content
This repository was archived by the owner on May 27, 2024. It is now read-only.

Commit d597400

Browse files
committed
Fix pre-commit
1 parent 414265f commit d597400

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

docs/notebooks/breast_cancer.ipynb

+23-17
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"%autoreload 2\n",
2828
"from multi_condition_comparisions.tl.de import StatsmodelsDE\n",
2929
"\n",
30-
"import scanpy as sc\n",
31-
"import decoupler as dc"
30+
"import decoupler as dc\n",
31+
"import scanpy as sc"
3232
]
3333
},
3434
{
@@ -44,11 +44,11 @@
4444
"metadata": {},
4545
"outputs": [],
4646
"source": [
47-
"#import cellxgene_census\n",
48-
"#cellxgene_census.download_source_h5ad('cd74e95e-6583-4875-a0ba-f2eae5a1e5a6.h5ad',\n",
49-
" #to_path=\"breast_cancer.h5ad\")\n",
47+
"import cellxgene_census\n",
5048
"\n",
51-
"#adata = sc.read_h5ad('./cd74e95e-6583-4875-a0ba-f2eae5a1e5a6.h5ad')"
49+
"cellxgene_census.download_source_h5ad(\"cd74e95e-6583-4875-a0ba-f2eae5a1e5a6.h5ad\", to_path=\"breast_cancer.h5ad\")\n",
50+
"\n",
51+
"adata = sc.read_h5ad(\"./cd74e95e-6583-4875-a0ba-f2eae5a1e5a6.h5ad\")"
5252
]
5353
},
5454
{
@@ -57,8 +57,8 @@
5757
"metadata": {},
5858
"outputs": [],
5959
"source": [
60-
"adata.layers['counts'] = adata.raw.X\n",
61-
"adata.layers['normalised_counts'] = adata.X\n"
60+
"adata.layers[\"counts\"] = adata.raw.X\n",
61+
"adata.layers[\"normalised_counts\"] = adata.X"
6262
]
6363
},
6464
{
@@ -116,13 +116,14 @@
116116
}
117117
],
118118
"source": [
119-
"pbulk = dc.get_pseudobulk(adata,\n",
120-
" sample_col='donor_id',\n",
121-
" groups_col='cell_type',\n",
122-
" layer='normalised_counts',\n",
123-
" mode='sum',\n",
124-
" min_cells=10,\n",
125-
" min_counts=1000,\n",
119+
"pbulk = dc.get_pseudobulk(\n",
120+
" adata,\n",
121+
" sample_col=\"donor_id\",\n",
122+
" groups_col=\"cell_type\",\n",
123+
" layer=\"normalised_counts\",\n",
124+
" mode=\"sum\",\n",
125+
" min_cells=10,\n",
126+
" min_counts=1000,\n",
126127
")\n",
127128
"\n",
128129
"pbulk"
@@ -713,8 +714,13 @@
713714
}
714715
],
715716
"source": [
716-
"mod.test_contrasts({\"T cells\": mod.cond(disease=\"breast cancer\", cell_type=\"T cell\") - mod.cond(disease=\"normal\", cell_type=\"T cell\")},\n",
717-
" {\"fibroblasts\": mod.cond(disease=\"breast cancer\", cell_type=\"fibroblast\") - mod.cond(disease=\"normal\", cell_type=\"fibroblast\")})"
717+
"mod.test_contrasts(\n",
718+
" {\"T cells\": mod.cond(disease=\"breast cancer\", cell_type=\"T cell\") - mod.cond(disease=\"normal\", cell_type=\"T cell\")},\n",
719+
" {\n",
720+
" \"fibroblasts\": mod.cond(disease=\"breast cancer\", cell_type=\"fibroblast\")\n",
721+
" - mod.cond(disease=\"normal\", cell_type=\"fibroblast\")\n",
722+
" },\n",
723+
")"
718724
]
719725
}
720726
],

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ convention = "numpy"
125125
"docs/*" = ["I"]
126126
"tests/*" = ["D"]
127127
"*/__init__.py" = ["F401"]
128+
"*.ipynb" = ["E402"] # module level import not at top of cell
128129

129130
[tool.cruft]
130131
skip = [

src/multi_condition_comparisions/tl/de.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ def cond(self, **kwargs) -> np.ndarray:
165165
"""
166166
The intention is to make contrasts using this function as in glmGamPoi
167167
168-
>>> res <- test_de(fit, contrast = cond(cell = "B cells", condition = "stim") - cond(cell = "B cells", condition = "ctrl"))
168+
>>> res < -test_de(
169+
... fit, contrast=cond(cell="B cells", condition="stim") - cond(cell="B cells", condition="ctrl")
170+
... )
169171
170172
Parameters
171173
----------

tests/test_de.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pandas import testing as tm
55

66
import multi_condition_comparisions
7-
from multi_condition_comparisions.tl.de import PyDESeq2DE, StatsmodelsDE, EdgeRDE
7+
from multi_condition_comparisions.tl.de import EdgeRDE, PyDESeq2DE, StatsmodelsDE
88

99

1010
def test_package_has_version():
@@ -78,6 +78,7 @@ def test_pydeseq2_complex(test_adata):
7878
assert expected_columns.issubset(set(res_df.columns))
7979
assert np.all((0 <= res_df["pvals"]) & (res_df["pvals"] <= 1))
8080

81+
8182
def test_edger_complex(test_adata):
8283
"""Check that the EdgeR method can be initialized with a different covariate name and fitted and that the test_contrast
8384
method returns a dataframe with the correct number of rows.
@@ -94,4 +95,3 @@ def test_edger_complex(test_adata):
9495
expected_columns = {"pvals", "pvals_adj", "logfoldchanges"}
9596
assert expected_columns.issubset(set(res_df.columns))
9697
assert np.all((0 <= res_df["pvals"]) & (res_df["pvals"] <= 1))
97-

0 commit comments

Comments
 (0)