From d9556d0aa21a084bd39f0188c88c8c3f09f71ab4 Mon Sep 17 00:00:00 2001
From: Pjotr Prins
Date: Mon, 14 Aug 2017 09:59:42 +0000
Subject: Issue 58, add tests for GSLv2 NaN's showing up with covariates

https://github.com/genetics-statistics/GEMMA/issues/58
---
 test/test_suite.sh | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

(limited to 'test/test_suite.sh')

diff --git a/test/test_suite.sh b/test/test_suite.sh
index 625298e..71901d7 100755
--- a/test/test_suite.sh
+++ b/test/test_suite.sh
@@ -80,6 +80,37 @@ testMultivariateLinearMixedModel() {
     assertEquals "139867" `wc -w < $outfn`
     assertEquals "4029037056.54" `perl -nle 'foreach $x (split(/\s+/,$_)) { $sum += sprintf("%.2f",(substr($x,,0,6))) } END { printf "%.2f",$sum }' $outfn`
 }
+
+testPlinkStandardRelatednessMatrixK() {
+    testname=testPlinkStandardRelatednessMatrixK
+    datadir=../example
+    outfn=output/$testname.sXX.txt
+    rm -f $outfn
+    $gemma -bfile $datadir/HLC \
+           -gk 2 -o $testname
+    assertEquals 0 $?
+    assertEquals 0 $?
+    assertEquals "427" `wc -l < $outfn`
+    assertEquals "-358.07" `perl -nle 'foreach $x (split(/\s+/,$_)) { $sum += sprintf("%.2f",(substr($x,,0,6))) } END { printf "%.2f",$sum }' $outfn`
+}
+
+# Test for https://github.com/genetics-statistics/GEMMA/issues/58
+# fixed GSLv2 NaN's that appeared with covariates.
+testPlinkMultivariateLinearMixedModel() {
+    testname=testPlinkMultivariateLinearMixedModel
+    datadir=../example
+    $gemma -bfile $datadir/HLC \
+           -k output/testPlinkStandardRelatednessMatrixK.sXX.txt \
+           -lmm 1 \
+           -maf 0.1 \
+           -c $datadir/HLC_covariates.txt \
+           -o $testname
+    assertEquals 0 $?
+    outfn=output/$testname.assoc.txt
+    assertEquals "223243" `wc -l < $outfn`
+    assertEquals "89756559859.06" `perl -nle 'foreach $x (split(/\s+/,$_)) { $sum += sprintf("%.2f",(substr($x,,0,6))) } END { printf "%.2f",$sum }' $outfn`
+}
+
 shunit2=`which shunit2`
 
 if [ -x "$shunit2" ]; then
-- 
cgit v1.2.3