From 9aa9f76cb16a0e71fea19dd125761034aaca4fd4 Mon Sep 17 00:00:00 2001 From: xiangzhou Date: Mon, 22 Sep 2014 11:12:46 -0400 Subject: version 0.95alpha --- param.cpp | 849 -------------------------------------------------------------- 1 file changed, 849 deletions(-) delete mode 100644 param.cpp (limited to 'param.cpp') diff --git a/param.cpp b/param.cpp deleted file mode 100644 index 7a89ff8..0000000 --- a/param.cpp +++ /dev/null @@ -1,849 +0,0 @@ -/* - Genome-wide Efficient Mixed Model Association (GEMMA) - Copyright (C) 2011 Xiang Zhou - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include -#include -#include -#include -#include -#include -#include - - -#ifdef FORCE_FLOAT -#include "param_float.h" -#include "io_float.h" -#else -#include "param.h" -#include "io.h" -#endif - -using namespace std; - - - - - -PARAM::PARAM(void): -mode_silence (false), a_mode (0), k_mode(1), d_pace (100000), -file_out("result"), path_out("./output/"), -miss_level(0.05), maf_level(0.01), hwe_level(0), r2_level(0.9999), -l_min(1e-5), l_max(1e5), n_region(10),p_nr(0.001),em_prec(0.0001),nr_prec(0.0001),em_iter(10000),nr_iter(100),crt(0), -pheno_mean(0), -h_min(-1), h_max(-1), h_scale(-1), -rho_min(0.0), rho_max(1.0), rho_scale(-1), -logp_min(0.0), logp_max(0.0), logp_scale(-1), -s_min(0), s_max(300), -w_step(100000), s_step(1000000), -r_pace(10), w_pace(1000), -n_accept(0), -n_mh(10), -geo_mean(2000.0), -randseed(-1), -error(false), - n_cvt(1), n_vc(1), -time_total(0.0), time_G(0.0), time_eigen(0.0), time_UtX(0.0), time_UtZ(0.0), time_opt(0.0), time_Omega(0.0) -{} - - -//read files -//obtain ns_total, ng_total, ns_test, ni_test -void PARAM::ReadFiles (void) -{ - string file_str; - if (!file_mk.empty()) { - if (CountFileLines (file_mk, n_vc)==false) {error=true;} - } - - if (!file_snps.empty()) { - if (ReadFile_snps (file_snps, setSnps)==false) {error=true;} - } else { - setSnps.clear(); - } - - //for prediction - if (!file_epm.empty()) { - if (ReadFile_est (file_epm, est_column, mapRS2est)==false) {error=true;} - - if (!file_bfile.empty()) { - file_str=file_bfile+".bim"; - if (ReadFile_bim (file_str, snpInfo)==false) {error=true;} - - file_str=file_bfile+".fam"; - if (ReadFile_fam (file_str, indicator_pheno, pheno, mapID2num, p_column)==false) {error=true;} - } - - if (!file_geno.empty()) { - if (ReadFile_pheno (file_pheno, indicator_pheno, pheno, p_column)==false) {error=true;} - - if (CountFileLines (file_geno, ns_total)==false) {error=true;} - } - - if (!file_ebv.empty() ) { - if (ReadFile_column (file_ebv, indicator_bv, vec_bv, 1)==false) {error=true;} - } - - if (!file_log.empty() ) { - if (ReadFile_log (file_log, pheno_mean)==false) {error=true;} - } - - //convert indicator_pheno to indicator_idv - int k=1; - for (size_t i=0; i::size_type i=0; i<(indicator_idv).size(); ++i) { - indicator_idv[i]*=indicator_read[i]; - ni_test+=indicator_idv[i]; - } - - if (ni_test==0) { - error=true; - cout<<"error! number of analyzed individuals equals 0. "<1) {cout<<"error! missing level needs to be between 0 and 1. current value = "<0.5) {cout<<"error! maf level needs to be between 0 and 0.5. current value = "<1) {cout<<"error! hwe level needs to be between 0 and 1. current value = "<1) {cout<<"error! r2 level needs to be between 0 and 1. current value = "<1) {cout<<"error! h values must be bewtween 0 and 1. current values = "<1) {cout<<"error! rho values must be between 0 and 1. current values = "<0) {cout<<"error! maximum logp value must be smaller than 0. current values = "<1.0) {cout<<"error! hscale value must be between 0 and 1. current value = "<1.0) {cout<<"error! rscale value must be between 0 and 1. current value = "<1.0) {cout<<"error! pscale value must be between 0 and 1. current value = "<1 && a_mode!=1 && a_mode!=2 && a_mode!=3 && a_mode!=4 && a_mode!=43) { - cout<<"error! the current analysis mode "<1 && !file_gene.empty() ) { - cout<<"error! multiple phenotype analysis option not allowed with gene expression files. "<1) { - cout<<"error! pnr value must be between 0 and 1. current value = "<::size_type i=0; i<(indicator_idv).size(); ++i) { - if (indicator_idv[i]==0) {continue;} - ni_test++; - } - - ni_cvt=0; - for (size_t i=0; i::size_type i=0; i<(indicator_idv).size(); ++i) { - indicator_idv[i]*=indicator_cvt[i]; - ni_test+=indicator_idv[i]; - } - } - - if ((indicator_read).size()!=0) { - ni_test=0; - for (vector::size_type i=0; i<(indicator_idv).size(); ++i) { - indicator_idv[i]*=indicator_read[i]; - ni_test+=indicator_idv[i]; - } - } - */ - if (ni_test==0) { - error=true; - cout<<"error! number of analyzed individuals equals 0. "<ns_test) {s_max=ns_test; cout<<"s_max is re-set to the number of analyzed SNPs."<size1; ++i) { - for (size_t j=0; jsize2; ++j) { - outfile<size; ++i) { - outfile<::size_type i=0; i set_remove; - - //check if any columns is an intercept - for (size_t i=0; isize2; i++) { - gsl_vector_view w_col=gsl_matrix_column (W, i); - gsl_vector_minmax (&w_col.vector, &v_min, &v_max); - if (v_min==v_max) {flag_ipt=1; set_remove.insert (i);} - } - - //add an intecept term if needed - if (n_cvt==set_remove.size()) { - indicator_cvt.clear(); - n_cvt=1; - } else if (flag_ipt==0) { - cout<<"no intecept term is found in the cvt file. a column of 1s is added."<::size_type i=0; i::size_type i=0; i<(indicator_idv).size(); ++i) { - indicator_idv[i]*=indicator_cvt[i]; - } - } - - //obtain ni_test - ni_test=0; - for (vector::size_type i=0; i<(indicator_idv).size(); ++i) { - if (indicator_idv[i]==0) {continue;} - ni_test++; - } - - if (ni_test==0) { - error=true; - cout<<"error! number of analyzed individuals equals 0. "< cvt_row; - cvt_row.push_back(1); - - for (vector::size_type i=0; i<(indicator_idv).size(); ++i) { - indicator_cvt.push_back(1); - - cvt.push_back(cvt_row); - } - } - - return; -} - - - - -void PARAM::CopyCvt (gsl_matrix *W) -{ - size_t ci_test=0; - - for (vector::size_type i=0; i::size_type i=0; i::size_type i=0; i::size_type i=0; i