[Genabel-commits] r1278 - pkg/OmicABEL/src/reshuffle

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jul 25 08:24:55 CEST 2013


Author: sharapovsodbo
Date: 2013-07-25 08:24:54 +0200 (Thu, 25 Jul 2013)
New Revision: 1278

Modified:
   pkg/OmicABEL/src/reshuffle/Parameters.h
   pkg/OmicABEL/src/reshuffle/iout_file.h
   pkg/OmicABEL/src/reshuffle/reshuffle.cpp
   pkg/OmicABEL/src/reshuffle/reshuffle.h
   pkg/OmicABEL/src/reshuffle/test.h
Log:
--ver 0.01 
2x boost reshuffling! 
data support: ~100K trairs, 120K SNP
(Maybe bigger, info doesn't exist)
problem: heritability estimates
problem: writing slim_data (e.g. "--dataslim --chi=30")



Modified: pkg/OmicABEL/src/reshuffle/Parameters.h
===================================================================
--- pkg/OmicABEL/src/reshuffle/Parameters.h	2013-07-24 11:53:12 UTC (rev 1277)
+++ pkg/OmicABEL/src/reshuffle/Parameters.h	2013-07-25 06:24:54 UTC (rev 1278)
@@ -8,8 +8,6 @@
 #ifndef PARAMETERS_H_
 #define PARAMETERS_H_
 
-typedef long long int64_t;
-
 #include <iostream>
 #include <string>
 #include <set>

Modified: pkg/OmicABEL/src/reshuffle/iout_file.h
===================================================================
--- pkg/OmicABEL/src/reshuffle/iout_file.h	2013-07-24 11:53:12 UTC (rev 1277)
+++ pkg/OmicABEL/src/reshuffle/iout_file.h	2013-07-25 06:24:54 UTC (rev 1278)
@@ -8,8 +8,6 @@
 #ifndef IOUT_FILE_H_
 #define IOUT_FILE_H_
 
-typedef long long int64_t;
-
 #include <fstream>
 #include <iostream>
 #include <vector>
@@ -17,7 +15,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-
 using namespace std;
 
 //Contain meta data

Modified: pkg/OmicABEL/src/reshuffle/reshuffle.cpp
===================================================================
--- pkg/OmicABEL/src/reshuffle/reshuffle.cpp	2013-07-24 11:53:12 UTC (rev 1277)
+++ pkg/OmicABEL/src/reshuffle/reshuffle.cpp	2013-07-25 06:24:54 UTC (rev 1278)
@@ -11,6 +11,8 @@
 #include <math.h>
 #include <iterator>
 #include <list>
+#include <sstream>
+#include <string>
 
 using namespace std;
 
@@ -81,12 +83,14 @@
 	data << endl;
 	double* buf = new double[per_trait_per_snp];
 	char s[30];
+	ostringstream ostr;
 	for (set<int>::iterator trait= (*p_Parameters).traits.numbersset.begin();trait!=(*p_Parameters).traits.numbersset.end();trait++) {
 		int64_t oldPos = 0;
 		int64_t pos;
+		//TODO: 2 previous lines to ONE
 		for (set<int>::iterator snp= (*p_Parameters).snps.numbersset.begin();snp!=(*p_Parameters).snps.numbersset.end();snp++) {
-			data << (*(*p_iout_file).labels.snp_names)[*snp] << "\t";
-			data << (*(*p_iout_file).labels.trait_names)[*trait]<<"\t";
+			ostr << (*(*p_iout_file).labels.snp_names)[*snp] << "\t";
+			ostr << (*(*p_iout_file).labels.trait_names)[*trait]<<"\t";
 			pos = (*p_iout_file).tilecoordinates(*trait, *snp);
 			//cout << oldPos << "-" << pos << endl;
 			if(pos != oldPos)
@@ -97,10 +101,13 @@
 			out_file.read((char *)buf, sizeof(double)*per_trait_per_snp);
 			for (int i = 0; i < per_trait_per_snp; i++) {
 				sprintf(s, "%.15g", buf[i]);
-				data << s << "\t";
+				ostr << s << "\t";
 			}
-			data << endl;
+			ostr << endl;
 		}
+		data << ostr.str();
+		ostr.str("");
+		ostr.clear();
 
 		//txt_trait.close();
 		//cout << "End_write_trait\t" << (*(*p_iout_file).labels.trait_names)[*trait] << " "<< double(clock()) / CLOCKS_PER_SEC <<" sec" << endl;
@@ -126,10 +133,12 @@
 	txt_chi << "Chi2" << endl;
 	double* buf = new double[per_trait_per_snp];
 	char s[30];
+	ostringstream ostr;
 	for (set<int>::iterator trait= (*p_Parameters).traits.numbersset.begin();trait!=(*p_Parameters).traits.numbersset.end();trait++) {
 		//ofstream txt_chi(create_filename("chi_data//chi", (*(*p_iout_file).labels.trait_names)[*trait]).c_str());
 		int64_t oldPos = 0;
 		int64_t pos = 0;
+		//TODO: 2 previous lines to ONE
 		for (set<int>::iterator snp= (*p_Parameters).snps.numbersset.begin();snp!=(*p_Parameters).snps.numbersset.end();snp++) {
 			pos = (*p_iout_file).tilecoordinates(*trait, *snp);
 			//cout << oldPos << "-" << pos << endl;
@@ -141,15 +150,18 @@
 			out_file.read((char *)buf, sizeof(double)*per_trait_per_snp);
 			chi=pow((buf[(*(*p_iout_file).labels.beta).size()-1]/buf[(*(*p_iout_file).labels.beta).size()+(*(*p_iout_file).labels.se).size()-1]),2);
 			if(chi>CheckChi){
-				txt_chi << (*(*p_iout_file).labels.snp_names)[*snp] << "\t";
-				txt_chi << (*(*p_iout_file).labels.trait_names)[*trait]<<"\t";
+				ostr << (*(*p_iout_file).labels.snp_names)[*snp] << "\t";
+				ostr << (*(*p_iout_file).labels.trait_names)[*trait]<<"\t";
 				for (int i = 0; i < per_trait_per_snp; i++) {
 					sprintf(s, "%.15g", buf[i]);
-					txt_chi << s << "\t";
+					ostr << s << "\t";
 				}
-				txt_chi << chi << endl;
+				ostr << chi << endl;
 			}
 		}
+		txt_chi << ostr.str();
+		ostr.str("");
+		ostr.clear();
 
 		//txt_chi.close();
 		//cout << "End_write_chi_trait\t" << (*(*p_iout_file).labels.trait_names)[*trait] << " "<< double(clock()) / CLOCKS_PER_SEC <<" sec" << endl;
@@ -169,10 +181,11 @@
 		exit(1);
 	}
 	double CheckChi = atof((*p_Parameters).chi.value.c_str());
+	double* buf = new double[per_trait_per_snp];
 	for (set<int>::iterator trait= (*p_Parameters).traits.numbersset.begin();trait!=(*p_Parameters).traits.numbersset.end();trait++) {
-		double* buf = new double[per_trait_per_snp];
 		int64_t oldPos = 0;
 		int64_t pos = 0;
+		//TODO: 2 previous lines to ONE
 		//char s[30];
 		for (set<int>::iterator snp= (*p_Parameters).snps.numbersset.begin();snp!=(*p_Parameters).snps.numbersset.end();snp++) {
 			pos = (*p_iout_file).tilecoordinates(*trait, *snp);
@@ -201,11 +214,12 @@
 	for (unsigned int cov = 0;cov < (*(*p_iout_file).labels.cov).size(); cov++)
 		txt_slim << (*(*p_iout_file).labels.cov)[cov] << "\t";
 	txt_slim << "Chi2" << endl;
+	ostringstream ostr;
 	for (set<int>::iterator trait= goodtraits.begin();trait!=goodtraits.end();trait++) {
-		double* buf = new double[per_trait_per_snp];
 		int64_t oldPos = 0;
+		int64_t pos = 0;
+		//TODO: 2 previous lines to ONE
 		char s[30];
-		int64_t pos = 0;
 		for (set<int>::iterator snp= goodsnps.begin();snp!=goodsnps.end();snp++) {
 			txt_slim << (*(*p_iout_file).labels.snp_names)[*snp] << "\t";
 			txt_slim << (*(*p_iout_file).labels.trait_names)[*trait]<<"\t";
@@ -220,10 +234,13 @@
 			chi=pow((buf[(*(*p_iout_file).labels.beta).size()-1]/buf[(*(*p_iout_file).labels.beta).size()+(*(*p_iout_file).labels.se).size()-1]),2);
 			for (int i = 0; i < per_trait_per_snp; i++) {
 				sprintf(s, "%.15g", buf[i]);
-				txt_slim << s << "\t";
+				ostr << s << "\t";
 			}
-			txt_slim << chi << endl;
+			ostr << chi << endl;
 		}
+		txt_slim << ostr.str();
+		ostr.str("");
+		ostr.clear();
 		delete buf;
 	}
 	cout <<"End_write_slim_data\t" << double(clock()) / CLOCKS_PER_SEC <<" sec" << endl;
@@ -241,6 +258,7 @@
 	return shift;
 }
 
+//TODO: check heritability estimates
 void Reshuffle::write_herest(ifstream& out_file, ofstream& herest){
 	ofstream txt_est("estimates.txt");
 	out_file.seekg(herest_startpos, ios_base::beg);

Modified: pkg/OmicABEL/src/reshuffle/reshuffle.h
===================================================================
--- pkg/OmicABEL/src/reshuffle/reshuffle.h	2013-07-24 11:53:12 UTC (rev 1277)
+++ pkg/OmicABEL/src/reshuffle/reshuffle.h	2013-07-25 06:24:54 UTC (rev 1278)
@@ -8,13 +8,11 @@
 #ifndef RESHUFFLE_H_
 #define RESHUFFLE_H_
 
-typedef long long int64_t;
-
 #include "Parameters.h"
 #include "iout_file.h"
 
 using namespace std;
-typedef long long int64_t;
+
 class Reshuffle{
 public:
 	iout_file * p_iout_file;

Modified: pkg/OmicABEL/src/reshuffle/test.h
===================================================================
--- pkg/OmicABEL/src/reshuffle/test.h	2013-07-24 11:53:12 UTC (rev 1277)
+++ pkg/OmicABEL/src/reshuffle/test.h	2013-07-25 06:24:54 UTC (rev 1278)
@@ -8,14 +8,10 @@
 #ifndef TEST_H_
 #define TEST_H_
 
-typedef long long int64_t;
-
-
 #include "Parameters.h"
 #include "iout_file.h"
 #include "reshuffle.h"
 //#include <dir.h>
-using namespace std;
 
 class test{
 public:



More information about the Genabel-commits mailing list