Skip to content

Commit 86e7e02

Browse files
committed
Extended the tests to CNVs and HAPs
1 parent 48d0274 commit 86e7e02

2 files changed

Lines changed: 44 additions & 8 deletions

File tree

tests/anoph/test_cnv_frq.py

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
from malariagen_data import ag3 as _ag3
1212
from malariagen_data.anoph.cnv_frq import AnophelesCnvFrequencyAnalysis
1313
from malariagen_data.util import compare_series_like
14+
from .test_frq import (
15+
test_plot_frequencies_heatmap,
16+
test_plot_frequencies_time_series,
17+
test_plot_frequencies_time_series_with_taxa,
18+
test_plot_frequencies_time_series_with_areas,
19+
test_plot_frequencies_interactive_map,
20+
)
1421

1522

1623
@pytest.fixture
@@ -109,6 +116,8 @@ def test_gene_cnv_frequencies_with_str_cohorts(
109116
# Run the function under test.
110117
df_cnv = api.gene_cnv_frequencies(**params)
111118

119+
test_plot_frequencies_heatmap(api, df_cnv)
120+
112121
# Figure out expected cohort labels.
113122
df_samples = api.sample_metadata(sample_sets=sample_sets)
114123
if "cohort_" + cohorts in df_samples:
@@ -166,12 +175,14 @@ def test_gene_cnv_frequencies_with_min_cohort_size(
166175
return
167176

168177
# Run the function under test.
169-
df_snp = api.gene_cnv_frequencies(**params)
178+
df_cnv = api.gene_cnv_frequencies(**params)
179+
180+
test_plot_frequencies_heatmap(api, df_cnv)
170181

171182
# Standard checks.
172183
check_gene_cnv_frequencies(
173184
api=api,
174-
df=df_snp,
185+
df=df_cnv,
175186
cohort_labels=cohort_labels,
176187
region=region,
177188
)
@@ -212,12 +223,14 @@ def test_gene_cnv_frequencies_with_str_cohorts_and_sample_query(
212223
)
213224

214225
# Run the function under test.
215-
df_snp = api.gene_cnv_frequencies(**params)
226+
df_cnv = api.gene_cnv_frequencies(**params)
227+
228+
test_plot_frequencies_heatmap(api, df_cnv)
216229

217230
# Standard checks.
218231
check_gene_cnv_frequencies(
219232
api=api,
220-
df=df_snp,
233+
df=df_cnv,
221234
cohort_labels=cohort_labels,
222235
region=region,
223236
)
@@ -268,12 +281,14 @@ def test_gene_cnv_frequencies_with_str_cohorts_and_sample_query_options(
268281
)
269282

270283
# Run the function under test.
271-
df_snp = api.gene_cnv_frequencies(**params)
284+
df_cnv = api.gene_cnv_frequencies(**params)
285+
286+
test_plot_frequencies_heatmap(api, df_cnv)
272287

273288
# Standard checks.
274289
check_gene_cnv_frequencies(
275290
api=api,
276-
df=df_snp,
291+
df=df_cnv,
277292
cohort_labels=cohort_labels,
278293
region=region,
279294
)
@@ -305,12 +320,14 @@ def test_gene_cnv_frequencies_with_dict_cohorts(
305320
)
306321

307322
# Run the function under test.
308-
df_snp = api.gene_cnv_frequencies(**params)
323+
df_cnv = api.gene_cnv_frequencies(**params)
324+
325+
test_plot_frequencies_heatmap(api, df_cnv)
309326

310327
# Standard checks.
311328
check_gene_cnv_frequencies(
312329
api=api,
313-
df=df_snp,
330+
df=df_cnv,
314331
cohort_labels=cohort_labels,
315332
region=region,
316333
)
@@ -350,6 +367,9 @@ def test_gene_cnv_frequencies_without_drop_invariant(
350367
df_cnv_a = api.gene_cnv_frequencies(drop_invariant=True, **params)
351368
df_cnv_b = api.gene_cnv_frequencies(drop_invariant=False, **params)
352369

370+
test_plot_frequencies_heatmap(api, df_cnv_a)
371+
test_plot_frequencies_heatmap(api, df_cnv_b)
372+
353373
# Standard checks.
354374
check_gene_cnv_frequencies(
355375
api=api,
@@ -418,6 +438,8 @@ def test_gene_cnv_frequencies_with_max_coverage_variance(
418438
# checks.
419439
df_cnv = api.gene_cnv_frequencies(**params)
420440

441+
test_plot_frequencies_heatmap(api, df_cnv)
442+
421443
# Figure out expected cohort labels.
422444
df_samples = api.sample_metadata(sample_sets=sample_sets)
423445
if "cohort_" + cohorts in df_samples:
@@ -711,6 +733,10 @@ def check_gene_cnv_frequencies_advanced(
711733

712734
# Check the result.
713735
assert isinstance(ds, xr.Dataset)
736+
test_plot_frequencies_time_series(api, ds)
737+
test_plot_frequencies_time_series_with_taxa(api, ds)
738+
test_plot_frequencies_time_series_with_areas(api, ds)
739+
test_plot_frequencies_interactive_map(api, ds)
714740
assert set(ds.dims) == {"cohorts", "variants"}
715741

716742
# Check variant variables.

tests/anoph/test_hap_frq.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
from malariagen_data import ag3 as _ag3
1010
from malariagen_data.anoph.hap_frq import AnophelesHapFrequencyAnalysis
11+
from .test_frq import (
12+
test_plot_frequencies_time_series,
13+
test_plot_frequencies_time_series_with_taxa,
14+
test_plot_frequencies_time_series_with_areas,
15+
test_plot_frequencies_interactive_map,
16+
)
1117

1218

1319
@pytest.fixture
@@ -82,6 +88,10 @@ def check_hap_frequencies_advanced(
8288
ds,
8389
):
8490
assert isinstance(ds, xr.Dataset)
91+
test_plot_frequencies_time_series(api, ds)
92+
test_plot_frequencies_time_series_with_taxa(api, ds)
93+
test_plot_frequencies_time_series_with_areas(api, ds)
94+
test_plot_frequencies_interactive_map(api, ds)
8595
assert set(ds.dims) == {"cohorts", "variants"}
8696

8797
expected_cohort_vars = [

0 commit comments

Comments
 (0)