Skip to content

Commit 0694dfa

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

File tree

1 file changed

+11
-33
lines changed

1 file changed

+11
-33
lines changed

tests/graph/test_niche.py

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626

2727
def test_niche_calc_nhood(adata_seqfish: AnnData):
2828
"""Check whether niche calculation using neighborhood profile approach works as intended."""
29-
spatial_neighbors(
30-
adata_seqfish, coord_type="generic", delaunay=False, n_neighs=N_NEIGHBORS
31-
)
29+
spatial_neighbors(adata_seqfish, coord_type="generic", delaunay=False, n_neighs=N_NEIGHBORS)
3230
calculate_niche(
3331
adata_seqfish,
3432
groups=GROUPS,
@@ -50,12 +48,8 @@ def test_niche_calc_nhood(adata_seqfish: AnnData):
5048
matrix = adata_seqfish.obsp[SPATIAL_CONNECTIVITIES_KEY].tocoo()
5149

5250
# get obs x category matrix where each column is the absolute/relative frequency of a category in the neighborhood
53-
rel_nhood_profile = _calculate_neighborhood_profile(
54-
adata_seqfish, groups=GROUPS, matrix=matrix, abs_nhood=False
55-
)
56-
abs_nhood_profile = _calculate_neighborhood_profile(
57-
adata_seqfish, groups=GROUPS, matrix=matrix, abs_nhood=True
58-
)
51+
rel_nhood_profile = _calculate_neighborhood_profile(adata_seqfish, groups=GROUPS, matrix=matrix, abs_nhood=False)
52+
abs_nhood_profile = _calculate_neighborhood_profile(adata_seqfish, groups=GROUPS, matrix=matrix, abs_nhood=True)
5953
# assert shape obs x groups
6054
assert rel_nhood_profile.shape == (
6155
adata_seqfish.n_obs,
@@ -71,12 +65,8 @@ def test_niche_calc_nhood(adata_seqfish: AnnData):
7165

7266
def test_niche_calc_utag(adata_seqfish: AnnData):
7367
"""Check whether niche calculation using UTAG approach works as intended."""
74-
spatial_neighbors(
75-
adata_seqfish, coord_type="generic", delaunay=False, n_neighs=N_NEIGHBORS
76-
)
77-
calculate_niche(
78-
adata_seqfish, flavor="utag", n_neighbors=N_NEIGHBORS, resolutions=[0.1, 1.0]
79-
)
68+
spatial_neighbors(adata_seqfish, coord_type="generic", delaunay=False, n_neighs=N_NEIGHBORS)
69+
calculate_niche(adata_seqfish, flavor="utag", n_neighbors=N_NEIGHBORS, resolutions=[0.1, 1.0])
8070

8171
niches = adata_seqfish.obs["utag_niche_res=1.0"]
8272
niches_low_res = adata_seqfish.obs["utag_niche_res=0.1"]
@@ -112,12 +102,8 @@ def test_niche_calc_utag(adata_seqfish: AnnData):
112102
def test_niche_calc_cellcharter(adata_seqfish: AnnData):
113103
"""Check whether niche calculation using CellCharter approach works as intended."""
114104

115-
spatial_neighbors(
116-
adata_seqfish, coord_type="generic", delaunay=False, n_neighs=N_NEIGHBORS
117-
)
118-
calculate_niche(
119-
adata_seqfish, groups=GROUPS, flavor="cellcharter", distance=3, n_components=5
120-
)
105+
spatial_neighbors(adata_seqfish, coord_type="generic", delaunay=False, n_neighs=N_NEIGHBORS)
106+
calculate_niche(adata_seqfish, groups=GROUPS, flavor="cellcharter", distance=3, n_components=5)
121107
niches = adata_seqfish.obs["cellcharter_niche"]
122108

123109
assert niches.nunique() == 5
@@ -148,12 +134,8 @@ def test_niche_calc_cellcharter(adata_seqfish: AnnData):
148134

149135
class TestNiches(PlotTester, metaclass=PlotTesterMeta):
150136
def test_plot_utag_niche(self, adata_seqfish: AnnData):
151-
spatial_neighbors(
152-
adata_seqfish, coord_type="generic", delaunay=False, n_neighs=N_NEIGHBORS
153-
)
154-
calculate_niche(
155-
adata_seqfish, flavor="utag", n_neighbors=N_NEIGHBORS, resolutions=0.5
156-
)
137+
spatial_neighbors(adata_seqfish, coord_type="generic", delaunay=False, n_neighs=N_NEIGHBORS)
138+
calculate_niche(adata_seqfish, flavor="utag", n_neighbors=N_NEIGHBORS, resolutions=0.5)
157139

158140
sq.pl.spatial_scatter(
159141
adata_seqfish,
@@ -162,9 +144,7 @@ def test_plot_utag_niche(self, adata_seqfish: AnnData):
162144
)
163145

164146
def test_plot_neighborhood_niche(self, adata_seqfish: AnnData):
165-
spatial_neighbors(
166-
adata_seqfish, coord_type="generic", delaunay=False, n_neighs=N_NEIGHBORS
167-
)
147+
spatial_neighbors(adata_seqfish, coord_type="generic", delaunay=False, n_neighs=N_NEIGHBORS)
168148

169149
calculate_niche(
170150
adata_seqfish,
@@ -182,9 +162,7 @@ def test_plot_neighborhood_niche(self, adata_seqfish: AnnData):
182162
)
183163

184164
def test_plot_cellcharter_niche(self, adata_seqfish: AnnData):
185-
spatial_neighbors(
186-
adata_seqfish, coord_type="generic", delaunay=False, n_neighs=N_NEIGHBORS
187-
)
165+
spatial_neighbors(adata_seqfish, coord_type="generic", delaunay=False, n_neighs=N_NEIGHBORS)
188166
calculate_niche(
189167
adata_seqfish,
190168
groups=GROUPS,

0 commit comments

Comments
 (0)