Skip to content

Commit

Permalink
Test for fail to load remaining cov values if HWE fails
Browse files Browse the repository at this point in the history
  • Loading branch information
welchr committed May 10, 2024
1 parent 344c811 commit de92d92
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 0 deletions.
46 changes: 46 additions & 0 deletions raremetal/tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,52 @@ TEST_CASE("File I/O") {
remove("test.group_var_missing_in_cov.meta.singlevar.results");
remove("test.group_var_missing_in_cov.raremetal.log");
}

SECTION("Regression test for HWE filtered variant stopping additional cov values from loading") {
/**
* Regression test for the following issue:
* - Running meta-analysis with at least 2 studies
* - Have a variant that fails HWE in one study, but not the other
* - The variant failing HWE is present in a group
*
* A similar error will occur as in the "Regression test for group variant not present in covariance matrix file"
* test. The HWE filter causes the variant to be added to an exclusion list. When loading covariance for the study
* where the variant fails HWE, the program will stop loading covariance values for the remaining group variants
* while parsing that line of the covariance file.
*/
Meta meta;
meta.prefix = "test.hwe_stops_cov_load";
meta.setLogFile();
meta.noPDF = true;
meta.Burden = true;
meta.HWE = 1e-05;
meta.MAF_cutoff = 1;

meta.scorefile.Add("tests/datasets/simulated/hwe_stops_cov_load/test.study1.MetaScore.assoc.gz");
meta.scorefile.Add("tests/datasets/simulated/hwe_stops_cov_load/test.study2.MetaScore.assoc.gz");
meta.covfile.Add("tests/datasets/simulated/hwe_stops_cov_load/test.study1.MetaCov.assoc.gz");
meta.covfile.Add("tests/datasets/simulated/hwe_stops_cov_load/test.study2.MetaCov.assoc.gz");

GroupFromAnnotation group;
group.groupFile = "tests/datasets/simulated/hwe_stops_cov_load/test.mask.tab";

meta.Prepare();
group.Run("", meta.log);
meta.PoolSummaryStat(group);
meta.WriteSingleVariantResults(group);
meta.Run(group);

auto results = RMGroupTestReader("test.hwe_stops_cov_load.meta.burden.results");
auto burden_p = results.get_record("FAIL1");

// If the bug is present, the p-value will be ~ 0.47, because it fails to load the cov value of 0.95 for study 1
REQUIRE(burden_p->pvalue == Approx(0.936002));

// Cleanup
remove("test.hwe_stops_cov_load.meta.burden.results");
remove("test.hwe_stops_cov_load.meta.singlevar.results");
remove("test.hwe_stops_cov_load.raremetal.log");
}
}

TEST_CASE("Heterogeneity statistics") {
Expand Down
1 change: 1 addition & 0 deletions tests/datasets/simulated/hwe_stops_cov_load/test.mask.tab
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FAIL1 1:14896:A:T 1:14897:T:C 1:14898:T:A
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit de92d92

Please sign in to comment.