@@ -98,81 +98,3 @@ def test_niche_calc_utag(adata_seqfish: AnnData):
98
98
else :
99
99
raise AssertionError
100
100
101
-
102
- def test_niche_calc_cellcharter (adata_seqfish : AnnData ):
103
- """Check whether niche calculation using CellCharter approach works as intended."""
104
-
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 )
107
- niches = adata_seqfish .obs ["cellcharter_niche" ]
108
-
109
- assert niches .nunique () == 5
110
- assert niches .isna ().sum () == 0
111
-
112
- adj = adata_seqfish .obsp [SPATIAL_CONNECTIVITIES_KEY ]
113
- adj_hop = _setdiag (adj , value = 0 )
114
- assert adj_hop .shape == adj .shape
115
- assert issparse (adj_hop )
116
- assert isinstance (adj_hop , scipy .sparse .csr_matrix )
117
-
118
- adj_visited = _setdiag (adj .copy (), 1 ) # Track visited neighbors
119
- adj_hop , adj_visited = _hop (adj_hop , adj , adj_visited )
120
- assert adj_hop .shape == adj .shape
121
- assert adj_hop .shape == adj_visited .shape
122
-
123
- assert np .array (np .sum (adj , axis = 1 )).squeeze ().max () == N_NEIGHBORS
124
- adj_hop_norm = _normalize (adj_hop )
125
- assert adj_hop_norm .shape == adj .shape
126
-
127
- mean_aggr_matrix = _aggregate (adata_seqfish , adj_hop_norm , "mean" )
128
- assert mean_aggr_matrix .shape == adata_seqfish .X .shape
129
- var_aggr_matrix = _aggregate (adata_seqfish , adj_hop_norm , "variance" )
130
- assert var_aggr_matrix .shape == adata_seqfish .X .shape
131
-
132
- # TODO: add test for GMM
133
-
134
-
135
- class TestNiches (PlotTester , metaclass = PlotTesterMeta ):
136
- def test_plot_utag_niche (self , adata_seqfish : AnnData ):
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 )
139
-
140
- sq .pl .spatial_scatter (
141
- adata_seqfish ,
142
- color = "utag_niche_res=0.5" ,
143
- shape = None ,
144
- )
145
-
146
- def test_plot_neighborhood_niche (self , adata_seqfish : AnnData ):
147
- spatial_neighbors (adata_seqfish , coord_type = "generic" , delaunay = False , n_neighs = N_NEIGHBORS )
148
-
149
- calculate_niche (
150
- adata_seqfish ,
151
- groups = GROUPS ,
152
- flavor = "neighborhood" ,
153
- n_neighbors = N_NEIGHBORS ,
154
- resolutions = 0.5 ,
155
- min_niche_size = 100 ,
156
- )
157
-
158
- sq .pl .spatial_scatter (
159
- adata_seqfish ,
160
- color = "nhood_niche_res=0.5" ,
161
- shape = None ,
162
- )
163
-
164
- def test_plot_cellcharter_niche (self , adata_seqfish : AnnData ):
165
- spatial_neighbors (adata_seqfish , coord_type = "generic" , delaunay = False , n_neighs = N_NEIGHBORS )
166
- calculate_niche (
167
- adata_seqfish ,
168
- groups = GROUPS ,
169
- flavor = "cellcharter" ,
170
- distance = 3 ,
171
- n_components = 5 ,
172
- )
173
-
174
- sq .pl .spatial_scatter (
175
- adata_seqfish ,
176
- color = "cellcharter_niche" ,
177
- shape = None ,
178
- )
0 commit comments