diff options
author | xiangzhou | 2014-09-20 11:51:03 -0400 |
---|---|---|
committer | xiangzhou | 2014-09-20 11:51:03 -0400 |
commit | 1f35ffa0806f5f0d70f31f3894cfd1ef816c2fdb (patch) | |
tree | 2dc0724fd56152b9d174c4aa5c2562a72d042d59 | |
parent | 05307b545d60931d265f0c81c0ed67b97321e076 (diff) | |
download | pangemma-1f35ffa0806f5f0d70f31f3894cfd1ef816c2fdb.tar.gz |
version 0.95alpha
-rw-r--r-- | bslmm.cpp | 13 | ||||
-rw-r--r-- | bslmm.h | 1 | ||||
-rw-r--r-- | gemma.cpp | 12 | ||||
-rw-r--r-- | lm.cpp | 3 | ||||
-rw-r--r-- | lm.h | 1 | ||||
-rw-r--r-- | lmm.cpp | 5 | ||||
-rw-r--r-- | lmm.h | 1 | ||||
-rw-r--r-- | main.cpp | 10 | ||||
-rw-r--r-- | mvlmm.cpp | 3 | ||||
-rw-r--r-- | mvlmm.h | 1 | ||||
-rw-r--r-- | param.cpp | 6 | ||||
-rw-r--r-- | param.h | 1 | ||||
-rw-r--r-- | prdt.cpp | 5 | ||||
-rw-r--r-- | prdt.h | 1 | ||||
-rw-r--r-- | vc.h | 2 |
15 files changed, 43 insertions, 22 deletions
@@ -70,6 +70,7 @@ void BSLMM::CopyFromParam (PARAM &cPar) file_bfile=cPar.file_bfile; file_geno=cPar.file_geno; file_out=cPar.file_out; + path_out=cPar.path_out; l_min=cPar.h_min; l_max=cPar.h_max; @@ -134,7 +135,7 @@ void BSLMM::CopyToParam (PARAM &cPar) void BSLMM::WriteBV (const gsl_vector *bv) { string file_str; - file_str="./output/"+file_out; + file_str=path_out+"/"+file_out; file_str+=".bv.txt"; ofstream outfile (file_str.c_str(), ofstream::out); @@ -162,7 +163,7 @@ void BSLMM::WriteBV (const gsl_vector *bv) void BSLMM::WriteParam (vector<pair<double, double> > &beta_g, const gsl_vector *alpha, const size_t w) { string file_str; - file_str="./output/"+file_out; + file_str=path_out+"/"+file_out; file_str+=".param.txt"; ofstream outfile (file_str.c_str(), ofstream::out); @@ -198,7 +199,7 @@ void BSLMM::WriteParam (vector<pair<double, double> > &beta_g, const gsl_vector void BSLMM::WriteParam (const gsl_vector *alpha) { string file_str; - file_str="./output/"+file_out; + file_str=path_out+"/"+file_out; file_str+=".param.txt"; ofstream outfile (file_str.c_str(), ofstream::out); @@ -228,9 +229,9 @@ void BSLMM::WriteParam (const gsl_vector *alpha) void BSLMM::WriteResult (const int flag, const gsl_matrix *Result_hyp, const gsl_matrix *Result_gamma, const size_t w_col) { string file_gamma, file_hyp; - file_gamma="./output/"+file_out; + file_gamma=path_out+"/"+file_out; file_gamma+=".gamma.txt"; - file_hyp="./output/"+file_out; + file_hyp=path_out+"/"+file_out; file_hyp+=".hyp.txt"; ofstream outfile_gamma, outfile_hyp; @@ -1448,7 +1449,7 @@ void BSLMM::SetXgamma (const gsl_matrix *X, const gsl_matrix *X_old, const gsl_m //somehow the lapack_dgemm does not work here //#ifdef WITH_LAPACK //lapack_dgemm ((char *)"T", (char *)"N", 1.0, X_add, X_add, 0.0, XtX_aa); - //lapack_dgemm ((char *)"T", (char *)"N", 1.0, X_add, X_old, 0.0, XtX_ao); + //lapack_dgemm ((char *)"T", (char *)"N", 1.0, X_add, X_temp, 0.0, XtX_at); //#else gsl_blas_dgemm (CblasTrans, CblasNoTrans, 1.0, X_add, X_add, 0.0, XtX_aa); @@ -49,6 +49,7 @@ public: string file_bfile; string file_geno; string file_out; + string path_out; // LMM related parameters double l_min; @@ -61,7 +61,7 @@ using namespace std; GEMMA::GEMMA(void): -version("0.95"), date("08/08/2014"), year("2011") +version("0.95alpha"), date("08/08/2014"), year("2011") {} void GEMMA::PrintHeader (void) @@ -238,6 +238,7 @@ void GEMMA::PrintHelp(size_t option) cout<<" 2: \"id id value\" format"<<endl; cout<<" -n [num] "<<" specify phenotype column in the phenotype/*.fam file (optional; default 1)"<<endl; cout<<" -pace [num] "<<" specify terminal display update pace (default 100000 SNPs or 100000 iterations)."<<endl; + cout<<" -outdir [path] "<<" specify output directory path (default \"./output/\")"<<endl; cout<<" -o [prefix] "<<" specify output file prefix (default \"result\")"<<endl; cout<<" output: prefix.cXX.txt or prefix.sXX.txt from kinship/relatedness matrix estimation"<<endl; cout<<" output: prefix.assoc.txt and prefix.log.txt form association tests"<<endl; @@ -519,6 +520,13 @@ void GEMMA::Assign(int argc, char ** argv, PARAM &cPar) str.assign(argv[i]); cPar.d_pace=atoi(str.c_str()); } + else if (strcmp(argv[i], "-outdir")==0) { + if(argv[i+1] == NULL || argv[i+1][0] == '-') {continue;} + ++i; + str.clear(); + str.assign(argv[i]); + cPar.path_out=str; + } else if (strcmp(argv[i], "-o")==0) { if(argv[i+1] == NULL || argv[i+1][0] == '-') {continue;} ++i; @@ -1567,7 +1575,7 @@ void GEMMA::BatchRun (PARAM &cPar) void GEMMA::WriteLog (int argc, char ** argv, PARAM &cPar) { string file_str; - file_str="./output/"+cPar.file_out; + file_str=cPar.path_out+"/"+cPar.file_out; file_str+=".log.txt"; ofstream outfile (file_str.c_str(), ofstream::out); @@ -65,6 +65,7 @@ void LM::CopyFromParam (PARAM &cPar) file_bfile=cPar.file_bfile; file_geno=cPar.file_geno; file_out=cPar.file_out; + path_out=cPar.path_out; file_gene=cPar.file_gene; time_opt=0.0; @@ -100,7 +101,7 @@ void LM::CopyToParam (PARAM &cPar) void LM::WriteFiles () { string file_str; - file_str="./output/"+file_out; + file_str=path_out+"/"+file_out; file_str+=".assoc.txt"; ofstream outfile (file_str.c_str(), ofstream::out); @@ -44,6 +44,7 @@ public: string file_bfile; string file_geno; string file_out; + string path_out; string file_gene; @@ -1,5 +1,5 @@ /* - Genome-wide Efficient Mixed Model Association (GEMMA) + Genome-wide Efficient Mixed Model Association (GEMMA) Copyright (C) 2011 Xiang Zhou This program is free software: you can redistribute it and/or modify @@ -66,6 +66,7 @@ void LMM::CopyFromParam (PARAM &cPar) file_bfile=cPar.file_bfile; file_geno=cPar.file_geno; file_out=cPar.file_out; + path_out=cPar.path_out; file_gene=cPar.file_gene; l_min=cPar.l_min; @@ -109,7 +110,7 @@ void LMM::CopyToParam (PARAM &cPar) void LMM::WriteFiles () { string file_str; - file_str="./output/"+file_out; + file_str=path_out+"/"+file_out; file_str+=".assoc.txt"; ofstream outfile (file_str.c_str(), ofstream::out); @@ -61,6 +61,7 @@ public: string file_bfile; string file_geno; string file_out; + string path_out; string file_gene; @@ -56,14 +56,14 @@ int main(int argc, char * argv[]) if (argc==2 && argv[1][0] == '-' && argv[1][1] == 'l') { cGemma.PrintLicense(); return EXIT_SUCCESS; - } - - ifstream check_dir("output/"); - if (!check_dir) { - mkdir("output", S_IRWXU|S_IRGRP|S_IROTH); } cGemma.Assign(argc, argv, cPar); + + ifstream check_dir((cPar.path_out).c_str()); + if (!check_dir) { + mkdir((cPar.path_out).c_str(), S_IRWXU|S_IRGRP|S_IROTH); + } if (cPar.error==true) {return EXIT_FAILURE;} @@ -68,6 +68,7 @@ void MVLMM::CopyFromParam (PARAM &cPar) file_bfile=cPar.file_bfile; file_geno=cPar.file_geno; file_out=cPar.file_out; + path_out=cPar.path_out; l_min=cPar.l_min; l_max=cPar.l_max; @@ -132,7 +133,7 @@ void MVLMM::CopyToParam (PARAM &cPar) void MVLMM::WriteFiles () { string file_str; - file_str="./output/"+file_out; + file_str=path_out+"/"+file_out; file_str+=".assoc.txt"; ofstream outfile (file_str.c_str(), ofstream::out); @@ -47,6 +47,7 @@ public: string file_bfile; string file_geno; string file_out; + string path_out; // MVLMM related parameters double l_min; @@ -41,7 +41,7 @@ using namespace std; PARAM::PARAM(void): mode_silence (false), a_mode (0), k_mode(1), d_pace (100000), -file_out("result"), +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), @@ -614,7 +614,7 @@ void PARAM::CalcKin (gsl_matrix *matrix_kin) { void PARAM::WriteMatrix (const gsl_matrix *matrix_U, const string suffix) { string file_str; - file_str="./output/"+file_out; + file_str=path_out+"/"+file_out; file_str+="."; file_str+=suffix; file_str+=".txt"; @@ -640,7 +640,7 @@ void PARAM::WriteMatrix (const gsl_matrix *matrix_U, const string suffix) void PARAM::WriteVector (const gsl_vector *vector_D, const string suffix) { string file_str; - file_str="./output/"+file_out; + file_str=path_out+"/"+file_out; file_str+="."; file_str+=suffix; file_str+=".txt"; @@ -100,6 +100,7 @@ public: string file_ku, file_kd; string file_mk; string file_out; + string path_out; string file_epm; //estimated parameter file string file_ebv; //estimated breeding value file @@ -61,6 +61,7 @@ void PRDT::CopyFromParam (PARAM &cPar) file_bfile=cPar.file_bfile; file_geno=cPar.file_geno; file_out=cPar.file_out; + path_out=cPar.path_out; indicator_pheno=cPar.indicator_pheno; indicator_cvt=cPar.indicator_cvt; @@ -94,7 +95,7 @@ void PRDT::CopyToParam (PARAM &cPar) void PRDT::WriteFiles (gsl_vector *y_prdt) { string file_str; - file_str="./output/"+file_out; + file_str=path_out+"/"+file_out; file_str+="."; file_str+="prdt"; file_str+=".txt"; @@ -121,7 +122,7 @@ void PRDT::WriteFiles (gsl_vector *y_prdt) void PRDT::WriteFiles (gsl_matrix *Y_full) { string file_str; - file_str="./output/"+file_out; + file_str=path_out+"/"+file_out; file_str+=".prdt.txt"; ofstream outfile (file_str.c_str(), ofstream::out); @@ -44,6 +44,7 @@ public: string file_bfile; string file_geno; string file_out; + string path_out; vector<vector<int> > indicator_pheno; vector<int> indicator_cvt; @@ -57,6 +57,7 @@ class VC { public: // IO related parameters string file_out; + string path_out; vector<double> v_sigma2; vector<double> v_se_sigma2; @@ -72,6 +73,7 @@ public: // Main functions void CopyFromParam (PARAM &cPar); void CopyToParam (PARAM &cPar); + void CalcVChe (const gsl_matrix *K, const gsl_matrix *W, const gsl_vector *y); void CalcVCreml (const gsl_matrix *K, const gsl_matrix *W, const gsl_vector *y); }; |