[Genabel-commits] r753 - in pkg/GenABEL: inst/unitTests src/GAlib
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jul 15 19:52:53 CEST 2011
Author: yurii
Date: 2011-07-15 19:52:52 +0200 (Fri, 15 Jul 2011)
New Revision: 753
Modified:
pkg/GenABEL/inst/unitTests/report.html
pkg/GenABEL/inst/unitTests/report.txt
pkg/GenABEL/inst/unitTests/reportSummary.txt
pkg/GenABEL/src/GAlib/gwaa.c
Log:
reformatted gwaa.c for better readability
Modified: pkg/GenABEL/inst/unitTests/report.html
===================================================================
--- pkg/GenABEL/inst/unitTests/report.html 2011-07-15 17:50:55 UTC (rev 752)
+++ pkg/GenABEL/inst/unitTests/report.html 2011-07-15 17:52:52 UTC (rev 753)
@@ -1,9 +1,9 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/transitional.dtd">
-<html><head><title>RUNIT TEST PROTOCOL--Fri Jul 15 18:24:27 2011</title>
+<html><head><title>RUNIT TEST PROTOCOL--Fri Jul 15 19:22:57 2011</title>
</head>
-<body><h1 TRUE>RUNIT TEST PROTOCOL--Fri Jul 15 18:24:27 2011</h1>
-<p>Number of test functions: 10</p>
+<body><h1 TRUE>RUNIT TEST PROTOCOL--Fri Jul 15 19:22:57 2011</h1>
+<p>Number of test functions: 11</p>
<p>Number of errors: 0</p>
<p>Number of failures: 0</p>
<hr>
@@ -15,7 +15,7 @@
<th width="20%">Failures</th>
</tr>
<tr><td><a href="#GenABEL unit testing">GenABEL unit testing</a></td>
-<td>10</td>
+<td>11</td>
<td>0</td>
<td>0</td>
</tr>
@@ -23,7 +23,7 @@
<hr>
<h3 TRUE>Details</h3>
<p><a name="GenABEL unit testing"><h5 TRUE>Test Suite: GenABEL unit testing</h5>
-</a>Test function regexp: ^test.+<br/>Test file regexp: ^runit.+\.[rR]$<br/>Involved directory:<br/>/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests<br/><ul><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.convert.snp.R">Test file: runit.convert.snp.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.convert.snp.R_test.convert.snp">test.convert.snp: (4 checks) ... OK (0.93 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.convert.snp.ped.R">Test file: runit.convert.snp.ped.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.convert.snp.ped.R_test.convert.snp.ped">test.convert.snp.ped: (0 checks) ... OK (0.05 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.descriptives.trait.R">Test file: runit.descriptives.trait.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.descriptives.trait.R_test.descriptives.trait">test.descriptives.trait: (1 checks) ... OK (0.42 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.findRelatives.R">Test file: runit.findRelatives.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.findRelatives.R_test.findRelatives">test.findRelatives: (10 checks) ... OK (51.72 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.impute2xxx.R">Test file: runit.impute2xxx.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.impute2xxx.R_test.impute2databel">test.impute2databel: (23 checks) ... OK (0.44 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.impute2xxx_large.R">Test file: runit.impute2xxx_large.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.impute2xxx_large.R_test.impute2xxx_large">test.impute2xxx_large: (0 checks) ... OK (0 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.iterator.R">Test file: runit.iterator.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.iterator.R_test.qtscore">test.qtscore: (0 checks) ... OK (0 seconds)<br/></a></li><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.iterator.R_test.summary_snp_data">test.summary_snp_data: (3 checks) ... OK (4.03 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.mach2databel.R">Test file: runit.mach2databel.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.mach2databel.R_test.mach2databel">test.mach2databel: (8 checks) ... OK (0.13 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.polylik.R">Test file: runit.polylik.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.polylik.R_test.polylik">test.polylik: (6 checks) ... OK (7.72 seconds)<br/></a></li></ul></li></ul><hr>
+</a>Test function regexp: ^test.+<br/>Test file regexp: ^runit.+\.[rR]$<br/>Involved directory:<br/>/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests<br/><ul><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.convert.snp.R">Test file: runit.convert.snp.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.convert.snp.R_test.convert.snp">test.convert.snp: (4 checks) ... OK (0.86 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.convert.snp.ped.R">Test file: runit.convert.snp.ped.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.convert.snp.ped.R_test.convert.snp.ped">test.convert.snp.ped: (0 checks) ... OK (0.01 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.descriptives.trait.R">Test file: runit.descriptives.trait.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.descriptives.trait.R_test.descriptives.trait">test.descriptives.trait: (1 checks) ... OK (0.37 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.findRelatives.R">Test file: runit.findRelatives.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.findRelatives.R_test.findRelatives">test.findRelatives: (10 checks) ... OK (52.69 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.impute2xxx.R">Test file: runit.impute2xxx.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.impute2xxx.R_test.impute2databel">test.impute2databel: (23 checks) ... OK (0.38 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.impute2xxx_large.R">Test file: runit.impute2xxx_large.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.impute2xxx_large.R_test.impute2xxx_large">test.impute2xxx_large: (0 checks) ... OK (0 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.iterator.R">Test file: runit.iterator.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.iterator.R_test.qtscore">test.qtscore: (0 checks) ... OK (0 seconds)<br/></a></li><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.iterator.R_test.summary_snp_data">test.summary_snp_data: (3 checks) ... OK (4.05 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.mach2databel.R">Test file: runit.mach2databel.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.mach2databel.R_test.mach2databel">test.mach2databel: (8 checks) ... OK (0.13 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.polygenic.R">Test file: runit.polygenic.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.polygenic.R_test.polygenic.Bug1322">test.polygenic.Bug1322: (2 checks) ... OK (1.53 seconds)<br/></a></li></ul></li><li><a href="/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.polylik.R">Test file: runit.polylik.R</a><ul><li><a name="GenABEL unit testing__Users_yuryaulchenko_eclipse_workspace_genabel_pkg_GenABEL_tests_.._inst_unitTests_runit.polylik.R_test.polylik">test.polylik: (6 checks) ... OK (7.38 seconds)<br/></a></li></ul></li></ul><hr>
<table border="0" width="80%" >
<tr><th>Name</th>
<th>Value</th>
Modified: pkg/GenABEL/inst/unitTests/report.txt
===================================================================
--- pkg/GenABEL/inst/unitTests/report.txt 2011-07-15 17:50:55 UTC (rev 752)
+++ pkg/GenABEL/inst/unitTests/report.txt 2011-07-15 17:52:52 UTC (rev 753)
@@ -1,12 +1,12 @@
-RUNIT TEST PROTOCOL -- Fri Jul 15 18:24:27 2011
+RUNIT TEST PROTOCOL -- Fri Jul 15 19:22:57 2011
***********************************************
-Number of test functions: 10
+Number of test functions: 11
Number of errors: 0
Number of failures: 0
1 Test Suite :
-GenABEL unit testing - 10 test functions, 0 errors, 0 failures
+GenABEL unit testing - 11 test functions, 0 errors, 0 failures
@@ -19,29 +19,32 @@
/Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests
---------------------------
Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.convert.snp.R
-test.convert.snp: (4 checks) ... OK (0.93 seconds)
+test.convert.snp: (4 checks) ... OK (0.86 seconds)
---------------------------
Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.convert.snp.ped.R
-test.convert.snp.ped: (0 checks) ... OK (0.05 seconds)
+test.convert.snp.ped: (0 checks) ... OK (0.01 seconds)
---------------------------
Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.descriptives.trait.R
-test.descriptives.trait: (1 checks) ... OK (0.42 seconds)
+test.descriptives.trait: (1 checks) ... OK (0.37 seconds)
---------------------------
Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.findRelatives.R
-test.findRelatives: (10 checks) ... OK (51.72 seconds)
+test.findRelatives: (10 checks) ... OK (52.69 seconds)
---------------------------
Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.impute2xxx.R
-test.impute2databel: (23 checks) ... OK (0.44 seconds)
+test.impute2databel: (23 checks) ... OK (0.38 seconds)
---------------------------
Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.impute2xxx_large.R
test.impute2xxx_large: (0 checks) ... OK (0 seconds)
---------------------------
Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.iterator.R
test.qtscore: (0 checks) ... OK (0 seconds)
-test.summary_snp_data: (3 checks) ... OK (4.03 seconds)
+test.summary_snp_data: (3 checks) ... OK (4.05 seconds)
---------------------------
Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.mach2databel.R
test.mach2databel: (8 checks) ... OK (0.13 seconds)
---------------------------
+Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.polygenic.R
+test.polygenic.Bug1322: (2 checks) ... OK (1.53 seconds)
+---------------------------
Test file: /Users/yuryaulchenko/eclipse_workspace/genabel/pkg/GenABEL/tests/../inst/unitTests/runit.polylik.R
-test.polylik: (6 checks) ... OK (7.72 seconds)
+test.polylik: (6 checks) ... OK (7.38 seconds)
Modified: pkg/GenABEL/inst/unitTests/reportSummary.txt
===================================================================
--- pkg/GenABEL/inst/unitTests/reportSummary.txt 2011-07-15 17:50:55 UTC (rev 752)
+++ pkg/GenABEL/inst/unitTests/reportSummary.txt 2011-07-15 17:52:52 UTC (rev 753)
@@ -1,9 +1,9 @@
-RUNIT TEST PROTOCOL -- Fri Jul 15 18:24:27 2011
+RUNIT TEST PROTOCOL -- Fri Jul 15 19:22:57 2011
***********************************************
-Number of test functions: 10
+Number of test functions: 11
Number of errors: 0
Number of failures: 0
1 Test Suite :
-GenABEL unit testing - 10 test functions, 0 errors, 0 failures
+GenABEL unit testing - 11 test functions, 0 errors, 0 failures
Modified: pkg/GenABEL/src/GAlib/gwaa.c
===================================================================
--- pkg/GenABEL/src/GAlib/gwaa.c 2011-07-15 17:50:55 UTC (rev 752)
+++ pkg/GenABEL/src/GAlib/gwaa.c 2011-07-15 17:52:52 UTC (rev 753)
@@ -1,8 +1,8 @@
/*
-****************************************************
-** GenABEL v 1.1-9 (c) 2006 Yurii Aulchenko, EMCR **
-****************************************************
-*/
+ ****************************************************
+ ** GenABEL v 1.1-9 (c) 2006 Yurii Aulchenko, EMCR **
+ ****************************************************
+ */
#include <stdlib.h>
#include <stdio.h>
@@ -16,38 +16,38 @@
double CalculateRS(unsigned intnAA, unsigned int nAB, unsigned int nBA, unsigned int nBB, unsigned int nDH);
void put_snps(int *b, int *Nsnps, char *a) {
- int i,j,k,idx;
- unsigned int sto;
-// int ofs[4] = {6,4,2,0};
- int nsnps = (*Nsnps);
- int nbytes;
- if ((nsnps % 4) == 0) nbytes = nsnps/4; else nbytes = ceil(1.*nsnps/4.);
-/*
+ int i,j,k,idx;
+ unsigned int sto;
+ // int ofs[4] = {6,4,2,0};
+ int nsnps = (*Nsnps);
+ int nbytes;
+ if ((nsnps % 4) == 0) nbytes = nsnps/4; else nbytes = ceil(1.*nsnps/4.);
+ /*
printf("nsnps = %i\n",nsnps);
printf("nbytes = %i\n",nbytes);
for (i=0;i<nsnps;i++) printf ("%i ",b[i]);
printf("\n");
-*/
- idx = 0;
- for (i=0;i<nbytes;i++) {
- sto = 0;
- for (j=0;j<4;j++) {
- k = b[idx++] << ofs[j];
- sto = sto | k;
- if (idx>=nsnps) break;
- }
- a[i] = sto;
-/*
+ */
+ idx = 0;
+ for (i=0;i<nbytes;i++) {
+ sto = 0;
+ for (j=0;j<4;j++) {
+ k = b[idx++] << ofs[j];
+ sto = sto | k;
+ if (idx>=nsnps) break;
+ }
+ a[i] = sto;
+ /*
printf("%i %i %c\n",i,sto,a[i]);
-*/
- }
+ */
+ }
}
-
+
void decomp(char *indata, int nids, int *gt) {
int i,j,idx;
char str;
-// int msk[4] = {192,48,12,3};
-// int ofs[4] = {6,4,2,0};
+ // int msk[4] = {192,48,12,3};
+ // int ofs[4] = {6,4,2,0};
int nbytes;
if ((nids % 4) == 0) nbytes = nids/4; else nbytes = ceil(1.*nids/4.);
idx = 0;
@@ -73,59 +73,59 @@
}
void get_snps_many(char *a, int *Nsnps, int *Nrows, int *b) {
- int i,j,m,idx=0;
- char str;
-// int msk[4] = {192,48,12,3};
-// int ofs[4] = {6,4,2,0};
- int nsnps = (*Nsnps);
- int nrows = (*Nrows);
- int nbytes;
- if ((nsnps % 4) == 0) nbytes = nsnps/4; else nbytes = ceil(1.*nsnps/4.);
- /*
+ int i,j,m,idx=0;
+ char str;
+ // int msk[4] = {192,48,12,3};
+ // int ofs[4] = {6,4,2,0};
+ int nsnps = (*Nsnps);
+ int nrows = (*Nrows);
+ int nbytes;
+ if ((nsnps % 4) == 0) nbytes = nsnps/4; else nbytes = ceil(1.*nsnps/4.);
+ /*
printf("nsnps = %i\n",nsnps);
printf("nbytes = %i\n",nbytes);
printf("nrows = %i\n",nrows);
- */
- for (m=0;m<nrows;m++) {
- idx = 0;
- for (i=0;i<nbytes;i++) {
- /*
+ */
+ for (m=0;m<nrows;m++) {
+ idx = 0;
+ for (i=0;i<nbytes;i++) {
+ /*
printf("adr(a) = %i\n",m*nbytes + i);
- */
- str = a[m*nbytes + i];
- /*
+ */
+ str = a[m*nbytes + i];
+ /*
Rprintf("a = %c\n",str);
Rprintf("a = %u\n",(unsigned short int) str);
- */
- for (j=0;j<4;j++) {
- b[m*nsnps+idx] = str & msk[j];
- b[m*nsnps+(idx++)] >>= ofs[j];
- if (idx>=nsnps) {idx=0;break;}
- }
- }
- }
- /*
+ */
+ for (j=0;j<4;j++) {
+ b[m*nsnps+idx] = str & msk[j];
+ b[m*nsnps+(idx++)] >>= ofs[j];
+ if (idx>=nsnps) {idx=0;break;}
+ }
+ }
+ }
+ /*
for (i=0;i<nsnps;i++) printf ("%i ",b[i]);
printf("\n");
- */
+ */
}
void get_snps_many_internal(char *a, int nsnps, int nrows, int *b) {
- int i,j,m,idx=0;
- char str;
- int nbytes;
- if ((nsnps % 4) == 0) nbytes = nsnps/4; else nbytes = ceil(1.*nsnps/4.);
- for (m=0;m<nrows;m++) {
- idx = 0;
- for (i=0;i<nbytes;i++) {
- str = a[m*nbytes + i];
- for (j=0;j<4;j++) {
- b[m*nsnps+idx] = str & msk[j];
- b[m*nsnps+(idx++)] >>= ofs[j];
- if (idx>=nsnps) {idx=0;break;}
- }
- }
- }
+ int i,j,m,idx=0;
+ char str;
+ int nbytes;
+ if ((nsnps % 4) == 0) nbytes = nsnps/4; else nbytes = ceil(1.*nsnps/4.);
+ for (m=0;m<nrows;m++) {
+ idx = 0;
+ for (i=0;i<nbytes;i++) {
+ str = a[m*nbytes + i];
+ for (j=0;j<4;j++) {
+ b[m*nsnps+idx] = str & msk[j];
+ b[m*nsnps+(idx++)] >>= ofs[j];
+ if (idx>=nsnps) {idx=0;break;}
+ }
+ }
+ }
}
@@ -134,20 +134,20 @@
char str;
unsigned int k;
unsigned int sto;
-// int msk[4] = {192,48,12,3};
-// int ofs[4] = {6,4,2,0};
+ // int msk[4] = {192,48,12,3};
+ // int ofs[4] = {6,4,2,0};
int nsnps = (*Nsnps);
int nids = (*Nids);
int noutlist = (*Noutlist);
int gt[nids];
int outgt[noutlist];
- int nbytes;
- if ((nids % 4) == 0) nbytes = nids/4; else nbytes = ceil(1.*nids/4.);
- int nbyte1;
- if ((noutlist % 4) == 0) nbyte1 = noutlist/4; else nbyte1 = ceil(1.*noutlist/4.);
-// printf("nsnps = %i\n",nsnps);
-// printf("nbytes = %i\n",nbytes);
-// printf("nbyte1 = %i\n",nbyte1);
+ int nbytes;
+ if ((nids % 4) == 0) nbytes = nids/4; else nbytes = ceil(1.*nids/4.);
+ int nbyte1;
+ if ((noutlist % 4) == 0) nbyte1 = noutlist/4; else nbyte1 = ceil(1.*noutlist/4.);
+ // printf("nsnps = %i\n",nsnps);
+ // printf("nbytes = %i\n",nbytes);
+ // printf("nbyte1 = %i\n",nbyte1);
for (m=0;m<nsnps;m++) {
idx = 0;
for (i=0;i<nbytes;i++) {
@@ -158,12 +158,12 @@
if (idx>=nids) {idx=0;break;}
}
}
-// subset gt
+ // subset gt
for (i=0;i<noutlist;i++) {
outgt[i] = gt[outlist[i]-1];
-// printf("%i ",outgt[i]);
+ // printf("%i ",outgt[i]);
}
-// printf("\n");
+ // printf("\n");
idx = 0;
for (i=0;i<nbyte1;i++) {
sto = 0;
@@ -175,10 +175,10 @@
out[m*nbyte1+i] = sto;
}
}
-/*
+ /*
for (i=0;i<nsnps;i++) printf ("%i ",b[i]);
printf("\n");
-*/
+ */
}
@@ -191,12 +191,12 @@
int gt[nids];
char str;
int count[3];
-// int msk[4] = {192,48,12,3};
-// int ofs[4] = {6,4,2,0};
+ // int msk[4] = {192,48,12,3};
+ // int ofs[4] = {6,4,2,0};
int nbytes;
if ((nids % 4) == 0) nbytes = nids/4; else nbytes = ceil(1.*nids/4.);
double meaids,p;
-// printf("! nsnps = %i nids = %i nbytes=%i\n",nsnps,nids,nbytes);
+ // printf("! nsnps = %i nids = %i nbytes=%i\n",nsnps,nids,nbytes);
for (m=0;m<nsnps;m++) {
idx = 0;
for (i=0;i<nbytes;i++) {
@@ -212,7 +212,7 @@
if (gt[i]) {
count[gt[i]-1]++;
p+=(gt[i]-1);
-// printf("%i = %i ",i,gt[i]);
+ // printf("%i = %i ",i,gt[i]);
}
meaids = 1.*(count[0]+count[1]+count[2]);
double chi = 0.;
@@ -221,8 +221,8 @@
double div = 1./(4*meaids);
double expec[3] = {q*q*div,2.*p*q*div,p*p*div};
for (i=0;i<3;i++) chi+= (1.*count[i]-expec[i])*(1.*count[i]-expec[i])/expec[i];
-// printf("%f %f %f\n",p,q,div);
-// printf("%f %f %f\n",expec[0],expec[1],expec[2]);
+ // printf("%f %f %f\n",p,q,div);
+ // printf("%f %f %f\n",expec[0],expec[1],expec[2]);
} else {chi=0.;}
out[m] = meaids;
out[(nsnps)*1+m] = meaids/nids;
@@ -231,7 +231,7 @@
out[(nsnps)*4+m] = count[1];
out[(nsnps)*5+m] = count[2];
out[(nsnps)*6+m] = chi;
-// printf("\n%i %f \n",m,out[m*7]);
+ // printf("\n%i %f \n",m,out[m*7]);
}
}
@@ -327,30 +327,30 @@
if (!outlist[j]) {
outlist[j]=i+1;
if (minc>=1.0) {
- for (k=0;k<nbytes;k++)
- if (indata[i*nbytes+k] != indata[j*nbytes+k]) {
- outlist[j]=0;
- break;
- }
+ for (k=0;k<nbytes;k++)
+ if (indata[i*nbytes+k] != indata[j*nbytes+k]) {
+ outlist[j]=0;
+ break;
+ }
} else {
- for (t=0;t<4;t++) for (t1=0;t1<4;t1++) ctg[t][t1]=0;
- for (k=0;k<nbytes;k++)
- if (indata[i*nbytes+k] != indata[j*nbytes+k])
- {
- get_snps_many(indata+i*nbytes+k,&i4,&i1,gt0);
- get_snps_many(indata+j*nbytes+k,&i4,&i1,gt1);
- for (t=0;t<4;t++) ctg[gt0[t]][gt1[t]]++;
- }
- else {ctg[1][1]+=4;}
- s1 = ctg[0][1]+ctg[0][2]+ctg[0][3]+
- ctg[1][0]+ctg[1][2]+ctg[1][3]+
- ctg[2][0]+ctg[2][1]+ctg[2][3]+
- ctg[3][0]+ctg[3][1]+ctg[3][2];
- s2 = ctg[0][0]+ctg[0][1]+ctg[0][3]+
- ctg[1][0]+ctg[1][2]+ctg[1][3]+
- ctg[2][1]+ctg[2][2]+ctg[2][3]+
- ctg[3][0]+ctg[3][1]+ctg[3][2];
- if (s1 > maxdism && s2 > maxdism) outlist[j]=0;
+ for (t=0;t<4;t++) for (t1=0;t1<4;t1++) ctg[t][t1]=0;
+ for (k=0;k<nbytes;k++)
+ if (indata[i*nbytes+k] != indata[j*nbytes+k])
+ {
+ get_snps_many(indata+i*nbytes+k,&i4,&i1,gt0);
+ get_snps_many(indata+j*nbytes+k,&i4,&i1,gt1);
+ for (t=0;t<4;t++) ctg[gt0[t]][gt1[t]]++;
+ }
+ else {ctg[1][1]+=4;}
+ s1 = ctg[0][1]+ctg[0][2]+ctg[0][3]+
+ ctg[1][0]+ctg[1][2]+ctg[1][3]+
+ ctg[2][0]+ctg[2][1]+ctg[2][3]+
+ ctg[3][0]+ctg[3][1]+ctg[3][2];
+ s2 = ctg[0][0]+ctg[0][1]+ctg[0][3]+
+ ctg[1][0]+ctg[1][2]+ctg[1][3]+
+ ctg[2][1]+ctg[2][2]+ctg[2][3]+
+ ctg[3][0]+ctg[3][1]+ctg[3][2];
+ if (s1 > maxdism && s2 > maxdism) outlist[j]=0;
}
}
}
@@ -454,7 +454,7 @@
chi2[m+4*nsnps] = 0.;
chi2[m+5*nsnps] = 0.;
} else {
-/* genotypic test */
+ /* genotypic test */
rt[0] = count_cas[0]+count_cas[1]+count_cas[2];
rt[1] = count_con[0]+count_con[1]+count_con[2];
ct[0] = count_cas[0]+count_con[0];
@@ -468,16 +468,16 @@
chi2[m+2*nsnps]=2.;
if (ct[0]<1 || ct[1]<1 || ct[2]<1) chi2[m+2*nsnps]=1.;
if (count_cas[0]>0 && count_con[1]>0)
- chi2[m+4*nsnps] = (1.*count_cas[1]*count_con[0])/(1.*count_cas[0]*count_con[1]);
+ chi2[m+4*nsnps] = (1.*count_cas[1]*count_con[0])/(1.*count_cas[0]*count_con[1]);
else
- chi2[m+4*nsnps] = 10000.0;
+ chi2[m+4*nsnps] = 10000.0;
if (count_cas[0]>0 && count_con[2]>0)
- chi2[m+5*nsnps] = (1.*count_cas[2]*count_con[0])/(1.*count_cas[0]*count_con[2]);
+ chi2[m+5*nsnps] = (1.*count_cas[2]*count_con[0])/(1.*count_cas[0]*count_con[2]);
else
- chi2[m+5*nsnps] = 10000.0;
+ chi2[m+5*nsnps] = 10000.0;
chi2[m+6*nsnps] = rt[0] + rt[1];
-/* allelic test */
+ /* allelic test */
total *= 2.;
rt[0] *= 2.;
rt[1] *= 2.;
@@ -493,9 +493,9 @@
for (i=0;i<2;i++) if (ecas[i]>0.) chi2[m]+=(1.*count_cas[i]-ecas[i])*(1.*count_cas[i]-ecas[i])/ecas[i];
for (i=0;i<2;i++) if (econ[i]>0.) chi2[m]+=(1.*count_con[i]-econ[i])*(1.*count_con[i]-econ[i])/econ[i];
if (count_cas[0]>0 && count_con[1]>0)
- chi2[m+3*nsnps] = (1.*count_cas[1]*count_con[0])/(1.*count_cas[0]*count_con[1]);
+ chi2[m+3*nsnps] = (1.*count_cas[1]*count_con[0])/(1.*count_cas[0]*count_con[1]);
else
- chi2[m+3*nsnps] = 10000.0;
+ chi2[m+3*nsnps] = 10000.0;
}
}
}
@@ -513,7 +513,7 @@
double Tsg1, Tsg2, sg1[nstra], sg2[nstra], xg1[nstra], xg2[nstra];
double det, u, v, u1, u2, v11, v12, v22;
if ((nids % 4) == 0) nbytes = nids/4; else nbytes = ceil(1.*nids/4.);
-// char chgt[nbytes];
+ // char chgt[nbytes];
for (igt=0;igt<nsnps;igt++) {
get_snps_many(gdata+nbytes*igt,Nids,&i1,gt);
@@ -527,20 +527,20 @@
xg2[j] = 0.;
}
for (i=0;i<nids;i++) {
- if (gt[i] != 0) {
- cstr = stra[i];
- dgt = 1.*gt[i] - 1.0;
- totg[cstr]+=1.0;
- if (dgt==1) {
- sg1[cstr]+=1.0;
- xg1[cstr]+=pheno[i];
- } else if (dgt==2) {
- sg2[cstr]+=1.0;
- xg2[cstr]+=pheno[i];
+ if (gt[i] != 0) {
+ cstr = stra[i];
+ dgt = 1.*gt[i] - 1.0;
+ totg[cstr]+=1.0;
+ if (dgt==1) {
+ sg1[cstr]+=1.0;
+ xg1[cstr]+=pheno[i];
+ } else if (dgt==2) {
+ sg2[cstr]+=1.0;
+ xg2[cstr]+=pheno[i];
+ }
+ x2[cstr] += pheno[i]*pheno[i];
+ sumx[cstr] += pheno[i];
}
- x2[cstr] += pheno[i]*pheno[i];
- sumx[cstr] += pheno[i];
- }
}
Ttotg=Tsg1=Tsg2=0.;
for (j=0;j<nstra;j++) {
@@ -573,22 +573,22 @@
u = u1+2.*u2;
v = v11+4.*v12+4.*v22;
if (v<1.e-16) {
- chi2[igt]=0.;
- chi2[igt+3*nsnps]=0.;
+ chi2[igt]=0.;
+ chi2[igt+3*nsnps]=0.;
} else {
- chi2[igt]=u*u/v;
- chi2[igt+3*nsnps]=u/(Tsg1+2.*Tsg2);
+ chi2[igt]=u*u/v;
+ chi2[igt+3*nsnps]=u/(Tsg1+2.*Tsg2);
}
det = v11*v22 - v12*v12;
if (det<(1.e-16)) {
chi2[igt+nsnps]=chi2[igt];
chi2[igt+2*nsnps] = 1.;
- chi2[igt+4*nsnps]=chi2[igt+3*nsnps];
- chi2[igt+5*nsnps]=2.*chi2[igt+3*nsnps];
+ chi2[igt+4*nsnps]=chi2[igt+3*nsnps];
+ chi2[igt+5*nsnps]=2.*chi2[igt+3*nsnps];
} else {
chi2[igt+nsnps]=(u1*u1*v22+u2*u2*v11-2.0*u1*u2*v12)/det;
- chi2[igt+4*nsnps]=u1/Tsg1;
- chi2[igt+5*nsnps]=u2/Tsg2;
+ chi2[igt+4*nsnps]=u1/Tsg1;
+ chi2[igt+5*nsnps]=u2/Tsg2;
if (Tsg1>0 && Tsg2>0 && Ttotg>0)
chi2[igt+2*nsnps] = 2.;
else
@@ -612,7 +612,7 @@
double Tsg1, Tsg2, sg1[nstra], sg2[nstra], xg1[nstra], xg2[nstra], gamma[nstra][naxes], saxg[nstra][naxes], sa2[nstra][naxes];
double det, u, v, u1, u2, v11, v12, v22;
if ((nids % 4) == 0) nbytes = nids/4; else nbytes = ceil(1.*nids/4.);
-// char chgt[nbytes];
+ // char chgt[nbytes];
for (igt=0;igt<nsnps;igt++) {
get_snps_many(gdata+nbytes*igt,Nids,&i1,gtint);
@@ -629,49 +629,49 @@
xg2[j] = 0.;
}
for (i=0;i<naxes;i++) {
- for (j=0;j<nstra;j++) {
- gamma[j][i] = 0.;
- saxg[j][i] = 0.;
- sa2[j][i] = 0.;
+ for (j=0;j<nstra;j++) {
+ gamma[j][i] = 0.;
+ saxg[j][i] = 0.;
+ sa2[j][i] = 0.;
+ }
}
- }
for (j=0;j<naxes;j++) {
- for (i=0;i<nids;i++) {
- if (gtint[i] != 0) {
- cstr = stra[i];
- dgt = gt[i] - 1.0;
- saxg[cstr][j] += dgt*axes[i+j*nids];
- sa2[cstr][j] += axes[i+j*nids]*axes[i+j*nids];
-// Rprintf("%d %d %d %e %e %e %e\n",i,j,cstr,dgt,dgt*axes[i+j*nids],saxg[cstr][j],sa2[cstr][j]);
- }
+ for (i=0;i<nids;i++) {
+ if (gtint[i] != 0) {
+ cstr = stra[i];
+ dgt = gt[i] - 1.0;
+ saxg[cstr][j] += dgt*axes[i+j*nids];
+ sa2[cstr][j] += axes[i+j*nids]*axes[i+j*nids];
+ // Rprintf("%d %d %d %e %e %e %e\n",i,j,cstr,dgt,dgt*axes[i+j*nids],saxg[cstr][j],sa2[cstr][j]);
+ }
+ }
}
- }
for (j=0;j<naxes;j++) {
- for (i=0;i<nstra;i++) {
- gamma[i][j] = saxg[i][j]/sa2[i][j];
-// Rprintf("%d %d %e %e %e\n",i,j,gamma[i][j],saxg[i][j],sa2[i][j]);
+ for (i=0;i<nstra;i++) {
+ gamma[i][j] = saxg[i][j]/sa2[i][j];
+ // Rprintf("%d %d %e %e %e\n",i,j,gamma[i][j],saxg[i][j],sa2[i][j]);
+ }
}
- }
for (i=0;i<nids;i++) {
- for (j=0;j<naxes;j++) {
- cstr = stra[i];
- gt[i] = gt[i] - gamma[cstr][j]*axes[i+j*nids];
+ for (j=0;j<naxes;j++) {
+ cstr = stra[i];
+ gt[i] = gt[i] - gamma[cstr][j]*axes[i+j*nids];
+ }
+ // Rprintf("%d %e\n",i,gt[i]);
}
-// Rprintf("%d %e\n",i,gt[i]);
- }
for (j=0;j<nstra;j++) {
- for (i=0;i<nids;i++) {
- if (gtint[i] != 0) {
- cstr = stra[i];
- totg[cstr]+=1.0;
- sg1[cstr]+=gt[i];
- sg2[cstr]+=gt[i]*gt[i];
- sumx[cstr] += pheno[i];
- x2[cstr] += pheno[i]*pheno[i];
- xg1[cstr]+=gt[i]*pheno[i];
- }
+ for (i=0;i<nids;i++) {
+ if (gtint[i] != 0) {
+ cstr = stra[i];
+ totg[cstr]+=1.0;
+ sg1[cstr]+=gt[i];
+ sg2[cstr]+=gt[i]*gt[i];
+ sumx[cstr] += pheno[i];
+ x2[cstr] += pheno[i]*pheno[i];
+ xg1[cstr]+=gt[i]*pheno[i];
+ }
+ }
}
- }
Ttotg=Tsg1=Tsg2=0.;
for (j=0;j<nstra;j++) {
Ttotg += totg[j];
@@ -703,25 +703,25 @@
u += (xg1[j]-sg1[j]*mx);
v += bb*(sg2[j]-sg1[j]*sg1[j]/totg[j]);
}
-// u = u1+2.*u2;
-// v = v11+4.*v12+4.*v22;
+ // u = u1+2.*u2;
+ // v = v11+4.*v12+4.*v22;
if (v<1.e-16) {
- chi2[igt]=0.;
- chi2[igt+3*nsnps]=0.;
+ chi2[igt]=0.;
+ chi2[igt+3*nsnps]=0.;
} else {
- chi2[igt]=(u*u/v)*(1.*nids/(1.*nids-1.*naxes-1.));
- chi2[igt+3*nsnps]=u/(Tsg1+2.*Tsg2);
+ chi2[igt]=(u*u/v)*(1.*nids/(1.*nids-1.*naxes-1.));
+ chi2[igt+3*nsnps]=u/(Tsg1+2.*Tsg2);
}
det = v11*v22 - v12*v12;
if (det<(1.e-16)) {
chi2[igt+nsnps]=chi2[igt];
chi2[igt+2*nsnps] = 1.;
- chi2[igt+4*nsnps]=chi2[igt+3*nsnps];
- chi2[igt+5*nsnps]=2.*chi2[igt+3*nsnps];
+ chi2[igt+4*nsnps]=chi2[igt+3*nsnps];
+ chi2[igt+5*nsnps]=2.*chi2[igt+3*nsnps];
} else {
chi2[igt+nsnps]=(u1*u1*v22+u2*u2*v11-2.0*u1*u2*v12)/det;
- chi2[igt+4*nsnps]=u1/Tsg1;
- chi2[igt+5*nsnps]=u2/Tsg2;
+ chi2[igt+4*nsnps]=u1/Tsg1;
+ chi2[igt+5*nsnps]=u2/Tsg2;
if (Tsg1>0 && Tsg2>0 && Ttotg>0)
chi2[igt+2*nsnps] = 2.;
else
@@ -747,46 +747,46 @@
double Tsg, sg[nstra];
double u, v;
if ((nids % 4) == 0) nbytes = nids/4; else nbytes = ceil(1.*nids/4.);
-// Rprintf("nstra=%d nsnps=%d nids=%d nbytes=%d\n",nstra,nsnps,nids,nbytes);
+ // Rprintf("nstra=%d nsnps=%d nids=%d nbytes=%d\n",nstra,nsnps,nids,nbytes);
for (igt=0;igt<nsnps;igt++) {
get_snps_many(gdata+nbytes*igt,Nids,&i1,gt);
-// for (i=0;i<nids;i++) Rprintf("%d ",gt[i]-1);Rprintf("\n");
+ // for (i=0;i<nids;i++) Rprintf("%d ",gt[i]-1);Rprintf("\n");
for (j=0;j<nstra;j++) {
totg[j] = 0.;
sg[j] = 0.;
}
Ttotg=Tsg=0.;
for (i=0;i<nids;i++)
- if (gt[i] != 0) {
- cstr = stra[i];
- dgt = 1.*gt[i] - 1.0;
- totg[cstr]+=1.0;
- Ttotg += 1.0;
- sg[cstr] += dgt;
- Tsg += dgt;
- }
+ if (gt[i] != 0) {
+ cstr = stra[i];
+ dgt = 1.*gt[i] - 1.0;
+ totg[cstr]+=1.0;
+ Ttotg += 1.0;
+ sg[cstr] += dgt;
+ Tsg += dgt;
+ }
chi2[igt+6*nsnps]=Ttotg;
for (j=0;j<nstra;j++) {
eG[j] = sg[j]/totg[j];
}
for (i=0;i<nids;i++) {
- gtctr[i] = 0.;
- if (gt[i] != 0) {
- cstr = stra[i];
- dgt = 1.*gt[i] - 1.0;
- gtctr[i] = dgt - eG[cstr];
-// Rprintf("i=%d gt[i]=%d gtctr[i]=%f\n",i,gt[i],gtctr[i]);
- }
+ gtctr[i] = 0.;
+ if (gt[i] != 0) {
+ cstr = stra[i];
+ dgt = 1.*gt[i] - 1.0;
+ gtctr[i] = dgt - eG[cstr];
+ // Rprintf("i=%d gt[i]=%d gtctr[i]=%f\n",i,gt[i],gtctr[i]);
+ }
}
for (i=0;i<nids;i++) {
svec[i] = 0.;
for (j=0;j<nids;j++) {
svec[i] += gtctr[j]*invS[nids*i+j];
-// Rprintf("%d ",nids*i+j);
+ // Rprintf("%d ",nids*i+j);
}
}
-// Rprintf("\nTtotg=%f\n",Ttotg);
+ // Rprintf("\nTtotg=%f\n",Ttotg);
if (Ttotg == 0) {
chi2[igt] = 0.;
chi2[igt+nsnps] = 0.;
@@ -797,20 +797,20 @@
} else {
u = v = 0.;
for (i=0;i<nids;i++) {
-// Rprintf("i=%d svec[i]=%f pheno[i]=%f gtctr[i]=%f\n",i,svec[i],pheno[i],gtctr[i]);
+ // Rprintf("i=%d svec[i]=%f pheno[i]=%f gtctr[i]=%f\n",i,svec[i],pheno[i],gtctr[i]);
if (gt[i] != 0) {
u += svec[i]*pheno[i];
v += svec[i]*gtctr[i];
}
}
if (v<1.e-16) {
- chi2[igt]=0.;
- chi2[igt+3*nsnps]=0.;
+ chi2[igt]=0.;
+ chi2[igt+3*nsnps]=0.;
} else {
- chi2[igt]=u*u/v;
- chi2[igt+3*nsnps]=u/Tsg;
+ chi2[igt]=u*u/v;
+ chi2[igt+3*nsnps]=u/Tsg;
}
-// Rprintf("u = %f, v= %f\n",u,v);
+ // Rprintf("u = %f, v= %f\n",u,v);
}
}
}
@@ -841,29 +841,29 @@
}
Ttotg=Tsg=0.;
for (i=0;i<nids;i++)
- if (gt[i] != 0) {
- cstr = stra[i];
- dgt = 1.*gt[i] - 1.0;
- totg[cstr]+=1.0;
- Ttotg += 1.0;
- sg[cstr] += dgt;
- sph[cstr] += pheno[i];
- Tsg += dgt;
- }
+ if (gt[i] != 0) {
+ cstr = stra[i];
+ dgt = 1.*gt[i] - 1.0;
+ totg[cstr]+=1.0;
+ Ttotg += 1.0;
+ sg[cstr] += dgt;
+ sph[cstr] += pheno[i];
+ Tsg += dgt;
+ }
chi2[igt+6*nsnps]=Ttotg;
for (j=0;j<nstra;j++) {
eG[j] = sg[j]/totg[j];
ePH[j] = sph[j]/totg[j];
}
for (i=0;i<nids;i++) {
- gtctr[i] = 0.;
- phctr[i] = 0.;
- if (gt[i] != 0) {
- cstr = stra[i];
- dgt = 1.*gt[i] - 1.0;
- gtctr[i] = dgt - eG[cstr];
- phctr[i] = pheno[i] - ePH[cstr];
- }
+ gtctr[i] = 0.;
+ phctr[i] = 0.;
+ if (gt[i] != 0) {
+ cstr = stra[i];
+ dgt = 1.*gt[i] - 1.0;
+ gtctr[i] = dgt - eG[cstr];
+ phctr[i] = pheno[i] - ePH[cstr];
+ }
}
for (i=0;i<nids;i++) {
svec[i] = 0.;
@@ -885,16 +885,96 @@
}
}
if (v<1.e-16) {
- chi2[igt]=0.;
- chi2[igt+3*nsnps]=0.;
+ chi2[igt]=0.;
+ chi2[igt+3*nsnps]=0.;
} else {
- chi2[igt]=u*u/v;
- chi2[igt+3*nsnps]=u/v;
+ chi2[igt]=u*u/v;
+ chi2[igt+3*nsnps]=u/v;
}
}
}
}
+//
+//new new MMSCORE (2011.07.15)
+//
+
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/genabel -r 753
More information about the Genabel-commits
mailing list