[Genabel-commits] r911 - branches/ProbABEL-refactoring/ProbABEL/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue May 22 10:20:05 CEST 2012


Author: lckarssen
Date: 2012-05-22 10:20:05 +0200 (Tue, 22 May 2012)
New Revision: 911

Modified:
   branches/ProbABEL-refactoring/ProbABEL/src/Makefile.am
   branches/ProbABEL-refactoring/ProbABEL/src/coxph_data.cpp
   branches/ProbABEL-refactoring/ProbABEL/src/coxph_data.h
Log:
- src/Makefile.am: minor layout change and fixed one filename
- src/coxph_data.{cpp,h}: added necessary includes for pacoxph to build succesfully. 


Modified: branches/ProbABEL-refactoring/ProbABEL/src/Makefile.am
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/Makefile.am	2012-05-21 20:06:03 UTC (rev 910)
+++ branches/ProbABEL-refactoring/ProbABEL/src/Makefile.am	2012-05-22 08:20:05 UTC (rev 911)
@@ -3,7 +3,11 @@
 ## Using wildcards in these lists doesn't work. Also GNU make's ($wildcard,) doesn't
 ## work. It gives warning message about portability, but in the end doesn't work,
 ## I tried :-).
-REGFILES = data.h data.cpp gendata.h gendata.cpp mematrix.h mematri1.h comand_line_settings.h comand_line_settings.cpp reg1.h usage.h usage.cpp main.cpp utilities.h utilities.cpp phedata.h phedata.cpp cholesky.h cholesky.cpp regdata.h regdata.cpp coxph_data.h coxph_data.h
+REGFILES = data.h data.cpp gendata.h gendata.cpp mematrix.h mematri1.h	\
+ comand_line_settings.h comand_line_settings.cpp reg1.h usage.h		\
+ usage.cpp main.cpp utilities.h utilities.cpp phedata.h phedata.cpp	\
+ cholesky.h cholesky.cpp regdata.h regdata.cpp coxph_data.h		\
+ coxph_data.cpp
 
 ## Filevector files:
 FVSRC = fvlib/AbstractMatrix.cpp fvlib/CastUtils.cpp			\

Modified: branches/ProbABEL-refactoring/ProbABEL/src/coxph_data.cpp
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/coxph_data.cpp	2012-05-21 20:06:03 UTC (rev 910)
+++ branches/ProbABEL-refactoring/ProbABEL/src/coxph_data.cpp	2012-05-22 08:20:05 UTC (rev 911)
@@ -5,6 +5,7 @@
  *      Author: mkooyman
  */
 
+#include "coxph_data.h"
 #include "fvlib/AbstractMatrix.h"
 #include "fvlib/CastUtils.h"
 #include "fvlib/const.h"
@@ -22,15 +23,15 @@
     double el2 = *(double*) b;
     if (el1 > el2)
     {
-        return 1;
+	return 1;
     }
     if (el1 < el2)
     {
-        return -1;
+	return -1;
     }
     if (el1 == el2)
     {
-        return 0;
+	return 0;
     }
 }
 
@@ -48,25 +49,25 @@
     order = obj.order;
     masked_data = new unsigned short int[nids];
     for (int i = 0; i < nids; i++)
-        masked_data[i] = 0;
+	masked_data[i] = 0;
 }
 coxph_data::coxph_data(phedata &phed, gendata &gend, int snpnum)
 {
     nids = gend.nids;
     masked_data = new unsigned short int[nids];
     for (int i = 0; i < nids; i++)
-        masked_data[i] = 0;
+	masked_data[i] = 0;
     ngpreds = gend.ngpreds;
     if (snpnum >= 0)
-        ncov = phed.ncov + ngpreds;
+	ncov = phed.ncov + ngpreds;
     else
-        ncov = phed.ncov;
+	ncov = phed.ncov;
     if (phed.noutcomes != 2)
     {
-        fprintf(stderr,
-                "coxph_data: number of outcomes should be 2 (now: %d)\n",
-                phed.noutcomes);
-        exit(1);
+	fprintf(stderr,
+		"coxph_data: number of outcomes should be 2 (now: %d)\n",
+		phed.noutcomes);
+	exit(1);
     }
     //      X.reinit(nids,(ncov+1));
     X.reinit(nids, ncov);
@@ -78,29 +79,29 @@
     order.reinit(nids, 1);
     for (int i = 0; i < nids; i++)
     {
-        //          X.put(1.,i,0);
-        stime[i] = (phed.Y).get(i, 0);
-        sstat[i] = int((phed.Y).get(i, 1));
-        if (sstat[i] != 1 && sstat[i] != 0)
-        {
-            fprintf(stderr,
-                    "coxph_data: status not 0/1 (right order: id, fuptime, status ...) %d \n",
-                    phed.noutcomes);
-            exit(1);
-        }
+	//          X.put(1.,i,0);
+	stime[i] = (phed.Y).get(i, 0);
+	sstat[i] = int((phed.Y).get(i, 1));
+	if (sstat[i] != 1 && sstat[i] != 0)
+	{
+	    fprintf(stderr,
+		    "coxph_data: status not 0/1 (right order: id, fuptime, status ...) %d \n",
+		    phed.noutcomes);
+	    exit(1);
+	}
     }
     for (int j = 0; j < phed.ncov; j++)
-        for (int i = 0; i < nids; i++)
-            X.put((phed.X).get(i, j), i, j);
+	for (int i = 0; i < nids; i++)
+	    X.put((phed.X).get(i, j), i, j);
 
     if (snpnum > 0)
-        for (int j = 0; j < ngpreds; j++)
-        {
-            float snpdata[nids];
-            gend.get_var(snpnum * ngpreds + j, snpdata);
-            for (int i = 0; i < nids; i++)
-                X.put(snpdata[i], i, (ncov - ngpreds + j));
-        }
+	for (int j = 0; j < ngpreds; j++)
+	{
+	    float snpdata[nids];
+	    gend.get_var(snpnum * ngpreds + j, snpdata);
+	    for (int i = 0; i < nids; i++)
+		X.put(snpdata[i], i, (ncov - ngpreds + j));
+	}
 
     //          for (int i=0;i<nids;i++)
     //              for (int j=0;j<ngpreds;j++)
@@ -108,36 +109,36 @@
 
     for (int i = 0; i < nids; i++)
     {
-        weights[i] = 1.0;
-        offset[i] = 0.0;
-        strata[i] = 0;
+	weights[i] = 1.0;
+	offset[i] = 0.0;
+	strata[i] = 0;
     }
     // sort by time
     double tmptime[nids];
     int passed_sorted[nids];
     for (int i = 0; i < nids; i++)
     {
-        tmptime[i] = stime[i];
-        passed_sorted[i] = 0;
+	tmptime[i] = stime[i];
+	passed_sorted[i] = 0;
     }
     qsort(tmptime, nids, sizeof(double), cmpfun);
     for (int i = 0; i < nids; i++)
     {
-        int passed = 0;
-        for (int j = 0; j < nids; j++)
-            if (tmptime[j] == stime[i])
-                if (!passed_sorted[j])
-                {
-                    order[i] = j;
-                    passed_sorted[j] = 1;
-                    passed = 1;
-                    break;
-                }
-        if (passed != 1)
-        {
-            fprintf(stderr, "cannot recover element %d\n", i);
-            exit(1);
-        }
+	int passed = 0;
+	for (int j = 0; j < nids; j++)
+	    if (tmptime[j] == stime[i])
+		if (!passed_sorted[j])
+		{
+		    order[i] = j;
+		    passed_sorted[j] = 1;
+		    passed = 1;
+		    break;
+		}
+	if (passed != 1)
+	{
+	    fprintf(stderr, "cannot recover element %d\n", i);
+	    exit(1);
+	}
     }
     stime = reorder(stime, order);
     sstat = reorder(sstat, order);
@@ -158,16 +159,16 @@
 
     for (int j = 0; j < ngpreds; j++)
     {
-        float snpdata[nids];
-        for (int i = 0; i < nids; i++)
-            masked_data[i] = 0;
-        gend.get_var(snpnum * ngpreds + j, snpdata);
-        for (int i = 0; i < nids; i++)
-        {
-            X.put(snpdata[i], (ncov - ngpreds + j), order[i]);
-            if (isnan(snpdata[i]))
-                masked_data[order[i]] = 1;
-        }
+	float snpdata[nids];
+	for (int i = 0; i < nids; i++)
+	    masked_data[i] = 0;
+	gend.get_var(snpnum * ngpreds + j, snpdata);
+	for (int i = 0; i < nids; i++)
+	{
+	    X.put(snpdata[i], (ncov - ngpreds + j), order[i]);
+	    if (isnan(snpdata[i]))
+		masked_data[order[i]] = 1;
+	}
     }
     //      for (int i=0;i<nids;i++)
     //          for (int j=0;j<ngpreds;j++)
@@ -193,8 +194,8 @@
 
     int nmeasured = 0;
     for (int i = 0; i < nids; i++)
-        if (masked_data[i] == 0)
-            nmeasured++;
+	if (masked_data[i] == 0)
+	    nmeasured++;
     to.nids = nmeasured;
 //      std::cout << "nmeasured=" << nmeasured << "\n";
     to.ncov = ncov;
@@ -218,26 +219,25 @@
     for (int i = 0; i < nids; i++)
     {
 //          std::cout << nids << " " << i << " " << masked_data[i] << "\n";
-        if (masked_data[i] == 0)
-        {
-            (to.weights).put(weights.get(i, 1), j, 1);
-            (to.stime).put(stime.get(i, 1), j, 1);
-            (to.sstat).put(sstat.get(i, 1), j, 1);
-            (to.offset).put(offset.get(i, 1), j, 1);
-            (to.strata).put(strata.get(i, 1), j, 1);
-            (to.order).put(order.get(i, 1), j, 1);
-            for (int nc = 0; nc < dim1X; nc++)
-                (to.X).put(X.get(nc, i), nc, j);
-            j++;
-        }
+	if (masked_data[i] == 0)
+	{
+	    (to.weights).put(weights.get(i, 1), j, 1);
+	    (to.stime).put(stime.get(i, 1), j, 1);
+	    (to.sstat).put(sstat.get(i, 1), j, 1);
+	    (to.offset).put(offset.get(i, 1), j, 1);
+	    (to.strata).put(strata.get(i, 1), j, 1);
+	    (to.order).put(order.get(i, 1), j, 1);
+	    for (int nc = 0; nc < dim1X; nc++)
+		(to.X).put(X.get(nc, i), nc, j);
+	    j++;
+	}
     }
 //      std::cout << " !!! just after cycle !!! ";
 
     //delete [] to.masked_data;
     to.masked_data = new unsigned short int[to.nids];
     for (int i = 0; i < to.nids; i++)
-        to.masked_data[i] = 0;
+	to.masked_data[i] = 0;
     //fprintf(stdout,"get_unmasked: %i %i %i\n",to.nids,dim2X,dim2Y);
     return (to);
 }
-

Modified: branches/ProbABEL-refactoring/ProbABEL/src/coxph_data.h
===================================================================
--- branches/ProbABEL-refactoring/ProbABEL/src/coxph_data.h	2012-05-21 20:06:03 UTC (rev 910)
+++ branches/ProbABEL-refactoring/ProbABEL/src/coxph_data.h	2012-05-22 08:20:05 UTC (rev 911)
@@ -8,6 +8,17 @@
 #ifndef COXPH_DATA_H_
 #define COXPH_DATA_H_
 
+#if EIGEN
+#include "eigen_mematrix.h"
+#include "eigen_mematri1.h"
+#else
+#include "mematrix.h"
+#include "mematri1.h"
+#endif
+
+#include "gendata.h"
+#include "phedata.h"
+
 class coxph_data
 {
 public:



More information about the Genabel-commits mailing list