Skip to content

Commit

Permalink
Fix test case for heterogeneity chisq values
Browse files Browse the repository at this point in the history
Test for #20
  • Loading branch information
welchr committed Apr 24, 2020
1 parent 08f234c commit 56ab521
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions raremetal/tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,33 @@

TEST_CASE("Heterogeneity statistics") {
SECTION("Should be correct on simple example") {
FILE *logFile;
Meta meta;
String filename;
if (Meta::prefix == "") {

if (meta.prefix == "") {
filename = "raremetal.log";
}
else if (Meta::prefix.Last() == '.' || Meta::prefix.Last() == '/') {
filename = Meta::prefix + "raremetal.log";
else if (meta.prefix.Last() == '.' || meta.prefix.Last() == '/') {
filename = meta.prefix + "raremetal.log";
}
else {
filename = Meta::prefix + ".raremetal.log";
filename = meta.prefix + ".raremetal.log";
}

logFile = freopen(filename, "wt", stderr);

String path;
Meta meta(logFile);

FILE *logFile = freopen(filename, "wt", stderr);
meta.setLogFile(logFile);
meta.skipOutput = true;
meta.bHeterogeneity = true;
meta.scorefile.Add("tests/datasets/simulated/heterog/study0_raremetal.txt.gz");
meta.scorefile.Add("tests/datasets/simulated/heterog/study1_raremetal.txt.gz");

GroupFromAnnotation group;
meta.Prepare();
group.Run(path, logFile);
meta.PoolSummaryStat(group);
meta.Run(group);

// High heterogeneity
REQUIRE(meta.SNP_heterog_stat.Double("3:1291852") == Approx(109.990000));

// Low heterogeneity
REQUIRE(meta.SNP_heterog_stat.Double("8:875238") == Approx(0.357466));
}
}

0 comments on commit 56ab521

Please sign in to comment.