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

Commit ec26e1a

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 414265f commit ec26e1a

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

docs/notebooks/breast_cancer.ipynb

+21-16
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"%autoreload 2\n",
2828
"from multi_condition_comparisions.tl.de import StatsmodelsDE\n",
2929
"\n",
30-
"import scanpy as sc\n",
3130
"import decoupler as dc"
3231
]
3332
},
@@ -44,11 +43,11 @@
4443
"metadata": {},
4544
"outputs": [],
4645
"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",
46+
"# import cellxgene_census\n",
47+
"# cellxgene_census.download_source_h5ad('cd74e95e-6583-4875-a0ba-f2eae5a1e5a6.h5ad',\n",
48+
"# to_path=\"breast_cancer.h5ad\")\n",
5049
"\n",
51-
"#adata = sc.read_h5ad('./cd74e95e-6583-4875-a0ba-f2eae5a1e5a6.h5ad')"
50+
"# adata = sc.read_h5ad('./cd74e95e-6583-4875-a0ba-f2eae5a1e5a6.h5ad')"
5251
]
5352
},
5453
{
@@ -57,8 +56,8 @@
5756
"metadata": {},
5857
"outputs": [],
5958
"source": [
60-
"adata.layers['counts'] = adata.raw.X\n",
61-
"adata.layers['normalised_counts'] = adata.X\n"
59+
"adata.layers[\"counts\"] = adata.raw.X\n",
60+
"adata.layers[\"normalised_counts\"] = adata.X"
6261
]
6362
},
6463
{
@@ -116,13 +115,14 @@
116115
}
117116
],
118117
"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",
118+
"pbulk = dc.get_pseudobulk(\n",
119+
" 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",
126126
")\n",
127127
"\n",
128128
"pbulk"
@@ -713,8 +713,13 @@
713713
}
714714
],
715715
"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\")})"
716+
"mod.test_contrasts(\n",
717+
" {\"T cells\": mod.cond(disease=\"breast cancer\", cell_type=\"T cell\") - mod.cond(disease=\"normal\", cell_type=\"T cell\")},\n",
718+
" {\n",
719+
" \"fibroblasts\": mod.cond(disease=\"breast cancer\", cell_type=\"fibroblast\")\n",
720+
" - mod.cond(disease=\"normal\", cell_type=\"fibroblast\")\n",
721+
" },\n",
722+
")"
718723
]
719724
}
720725
],

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)