Skip to content

Commit 6c91470

Browse files
committed
Update highly_variable_features_scanpy tests
1 parent 9ececd6 commit 6c91470

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • src/feature_annotation/highly_variable_features_scanpy

src/feature_annotation/highly_variable_features_scanpy/test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,15 @@ def test_filter_with_hvg(run_component, lognormed_test_data_path):
9797
assert os.path.exists("output.h5mu")
9898
data = mu.read_h5mu("output.h5mu")
9999
assert "filter_with_hvg" in data.mod["rna"].var.columns
100+
assert data.mod["rna"].uns["hvg"] == {"flavor": "seurat"}
100101
# Put the output data back into its original shape
101102
# so that we can compare it to the input
102103
data.mod["rna"].var = data.mod["rna"].var.drop(
103104
columns=["filter_with_hvg"], errors="raise"
104105
)
105106
data.var = data.var.drop(columns=["rna:filter_with_hvg"], errors="raise")
106107
del data["rna"].varm["hvg"]
108+
del data["rna"].uns["hvg"]
107109
assert_annotation_objects_equal(lognormed_test_data_path, data)
108110

109111

@@ -161,6 +163,7 @@ def test_filter_with_hvg_var_input(run_component, common_vars_data_path):
161163
)
162164
mdata.var = mdata.var.drop(columns=["rna:filter_with_hvg"], errors="raise")
163165
del mdata["rna"].varm["hvg"]
166+
del mdata["rna"].uns["hvg"]
164167

165168
common_vars.mod["rna"].var = common_vars.mod["rna"].var.drop(
166169
columns=["filter_with_hvg"], errors="raise"
@@ -169,6 +172,7 @@ def test_filter_with_hvg_var_input(run_component, common_vars_data_path):
169172
columns=["rna:filter_with_hvg"], errors="raise"
170173
)
171174
del common_vars["rna"].varm["hvg"]
175+
del common_vars["rna"].uns["hvg"]
172176

173177
assert_annotation_objects_equal(mdata, common_vars)
174178

@@ -197,6 +201,7 @@ def test_filter_with_hvg_batch_with_batch(
197201
assert os.path.exists("output.h5mu")
198202
output_data = mu.read_h5mu("output.h5mu")
199203
assert "filter_with_hvg" in output_data.mod["rna"].var.columns
204+
assert output_data.mod["rna"].uns["hvg"] == {"flavor": "seurat"}
200205

201206
# Check the contents of the output to check if the correct layer was selected
202207
input_mudata = mu.read_h5mu(lognormed_batch_test_data_path)
@@ -221,6 +226,7 @@ def test_filter_with_hvg_batch_with_batch(
221226
output_data.var = output_data.var.drop(
222227
columns=["rna:filter_with_hvg"], errors="raise"
223228
)
229+
del output_data["rna"].uns["hvg"]
224230
assert_annotation_objects_equal(lognormed_batch_test_data_path, output_data)
225231

226232

@@ -258,12 +264,14 @@ def test_filter_with_hvg_seurat_v3(run_component, input_path):
258264
assert os.path.exists("output.h5mu")
259265
data = mu.read_h5mu("output.h5mu")
260266
assert "filter_with_hvg" in data.mod["rna"].var.columns
267+
assert data.mod["rna"].uns["hvg"] == {"flavor": "seurat_v3"}
261268
# Put the output data back into its original shape
262269
# so that we can compare it to the input
263270
data.mod["rna"].var = data.mod["rna"].var.drop(
264271
columns=["filter_with_hvg"], errors="raise"
265272
)
266273
data.var = data.var.drop(columns=["rna:filter_with_hvg"], errors="raise")
274+
del data["rna"].uns["hvg"]
267275
assert_annotation_objects_equal(input_path, data)
268276

269277

@@ -281,13 +289,15 @@ def test_filter_with_hvg_cell_ranger(run_component, filter_data_path):
281289
assert os.path.exists("output.h5mu")
282290
data = mu.read_h5mu("output.h5mu")
283291
assert "filter_with_hvg" in data.mod["rna"].var.columns
292+
assert data.mod["rna"].uns["hvg"] == {"flavor": "cell_ranger"}
284293
# Put the output data back into its original shape
285294
# so that we can compare it to the input
286295
data.mod["rna"].var = data.mod["rna"].var.drop(
287296
columns=["filter_with_hvg"], errors="raise"
288297
)
289298
data.var = data.var.drop(columns=["rna:filter_with_hvg"], errors="raise")
290299
del data["rna"].varm["hvg"]
300+
del data["rna"].uns["hvg"]
291301
assert_annotation_objects_equal(filter_data_path, data)
292302

293303

0 commit comments

Comments
 (0)