Skip to content

Commit e704029

Browse files
committed
Test that set_af_filter and scan_all_samples parameters can be combined in read() and read_arrow()
1 parent 7a10f98 commit e704029

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

apis/python/tests/test_stats.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,36 @@ def test_read_with_scan_all_samples(stats_v3_dataset, stats_sample_names):
5454
assert tbl.to_pandas().equals(df)
5555

5656

57+
@skip_if_no_bcftools
58+
def test_read_with_af_filter_and_scan_all_samples(stats_v3_dataset, stats_sample_names):
59+
"""set_af_filter and scan_all_samples can be combined.
60+
scan_all_samples normalises AF across all samples, so more variants pass
61+
the filter compared to using set_af_filter alone."""
62+
attrs = ["contig", "pos_start", "sample_name"]
63+
64+
df_filter_only = stats_v3_dataset.read(
65+
samples=stats_sample_names,
66+
attrs=attrs,
67+
set_af_filter="<0.2",
68+
)
69+
70+
df = stats_v3_dataset.read(
71+
samples=stats_sample_names,
72+
attrs=attrs,
73+
set_af_filter="<0.2",
74+
scan_all_samples=True,
75+
)
76+
assert len(df) > len(df_filter_only)
77+
78+
tbl = stats_v3_dataset.read_arrow(
79+
samples=stats_sample_names,
80+
attrs=attrs,
81+
set_af_filter="<0.2",
82+
scan_all_samples=True,
83+
)
84+
assert tbl.to_pandas().equals(df)
85+
86+
5787
@skip_if_no_bcftools
5888
def test_variant_stats_parameter_errors(stats_v3_dataset):
5989
no_region = '"region" or "regions" parameter is required'

0 commit comments

Comments
 (0)