aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Carbonetto2017-08-15 16:21:57 -0500
committerGitHub2017-08-15 16:21:57 -0500
commit85797beb24da3d591a79fddcff4ab48d702b465f (patch)
treec6912583a251e428f6da5cc81205cde6a12db6a0 /src
parent7fa36b1c2d6101a6daf4c4e7fd58e759c67e714c (diff)
parent51ad0de5cad238b8d9bae63564366e058deccccf (diff)
downloadpangemma-85797beb24da3d591a79fddcff4ab48d702b465f.tar.gz
Merge pull request #70 from genenetwork/issue14
Fixes output file with kinship has extra column.
Diffstat (limited to 'src')
-rw-r--r--src/gemma.cpp24
-rw-r--r--src/io.cpp2
-rw-r--r--src/io.h2
-rw-r--r--src/param.cpp2
4 files changed, 16 insertions, 14 deletions
diff --git a/src/gemma.cpp b/src/gemma.cpp
index 3197043..c82bf4a 100644
--- a/src/gemma.cpp
+++ b/src/gemma.cpp
@@ -1789,14 +1789,14 @@ void GEMMA::BatchRun(PARAM &cPar) {
cout << "REMLE estimate for Vg in the null model: " << endl;
for (size_t i = 0; i < Vg->size1; i++) {
for (size_t j = 0; j <= i; j++) {
- cout << gsl_matrix_get(Vg, i, j) << "\t";
+ cout << tab(j) << gsl_matrix_get(Vg, i, j);
}
cout << endl;
}
cout << "REMLE estimate for Ve in the null model: " << endl;
for (size_t i = 0; i < Ve->size1; i++) {
for (size_t j = 0; j <= i; j++) {
- cout << gsl_matrix_get(Ve, i, j) << "\t";
+ cout << tab(j) << gsl_matrix_get(Ve, i, j);
}
cout << endl;
}
@@ -3560,7 +3560,7 @@ void GEMMA::WriteLog(int argc, char **argv, PARAM &cPar) {
for (size_t j = 0; j <= i; j++) {
c = (2 * cPar.n_ph - min(i, j) + 1) * min(i, j) / 2 + max(i, j) -
min(i, j);
- outfile << cPar.Vg_remle_null[c] << "\t";
+ outfile << tab(j) << cPar.Vg_remle_null[c];
}
outfile << endl;
}
@@ -3569,7 +3569,7 @@ void GEMMA::WriteLog(int argc, char **argv, PARAM &cPar) {
for (size_t j = 0; j <= i; j++) {
c = (2 * cPar.n_ph - min(i, j) + 1) * min(i, j) / 2 + max(i, j) -
min(i, j);
- outfile << sqrt(cPar.VVg_remle_null[c]) << "\t";
+ outfile << tab(j) << sqrt(cPar.VVg_remle_null[c]);
}
outfile << endl;
}
@@ -3578,7 +3578,7 @@ void GEMMA::WriteLog(int argc, char **argv, PARAM &cPar) {
for (size_t j = 0; j <= i; j++) {
c = (2 * cPar.n_ph - min(i, j) + 1) * min(i, j) / 2 + max(i, j) -
min(i, j);
- outfile << cPar.Ve_remle_null[c] << "\t";
+ outfile << tab(j) << cPar.Ve_remle_null[c];
}
outfile << endl;
}
@@ -3587,7 +3587,7 @@ void GEMMA::WriteLog(int argc, char **argv, PARAM &cPar) {
for (size_t j = 0; j <= i; j++) {
c = (2 * cPar.n_ph - min(i, j) + 1) * min(i, j) / 2 + max(i, j) -
min(i, j);
- outfile << sqrt(cPar.VVe_remle_null[c]) << "\t";
+ outfile << tab(j) << sqrt(cPar.VVe_remle_null[c]);
}
outfile << endl;
}
@@ -3597,7 +3597,7 @@ void GEMMA::WriteLog(int argc, char **argv, PARAM &cPar) {
for (size_t j = 0; j < cPar.n_ph; j++) {
c = (2 * cPar.n_ph - min(i, j) + 1) * min(i, j) / 2 + max(i, j) -
min(i, j);
- outfile << cPar.Vg_mle_null[c] << "\t";
+ outfile << tab(j) << cPar.Vg_mle_null[c];
}
outfile << endl;
}
@@ -3606,7 +3606,7 @@ void GEMMA::WriteLog(int argc, char **argv, PARAM &cPar) {
for (size_t j = 0; j <= i; j++) {
c = (2 * cPar.n_ph - min(i, j) + 1) * min(i, j) / 2 + max(i, j) -
min(i, j);
- outfile << sqrt(cPar.VVg_mle_null[c]) << "\t";
+ outfile << tab(j) << sqrt(cPar.VVg_mle_null[c]);
}
outfile << endl;
}
@@ -3615,7 +3615,7 @@ void GEMMA::WriteLog(int argc, char **argv, PARAM &cPar) {
for (size_t j = 0; j < cPar.n_ph; j++) {
c = (2 * cPar.n_ph - min(i, j) + 1) * min(i, j) / 2 + max(i, j) -
min(i, j);
- outfile << cPar.Ve_mle_null[c] << "\t";
+ outfile << tab(j) << cPar.Ve_mle_null[c];
}
outfile << endl;
}
@@ -3624,7 +3624,7 @@ void GEMMA::WriteLog(int argc, char **argv, PARAM &cPar) {
for (size_t j = 0; j <= i; j++) {
c = (2 * cPar.n_ph - min(i, j) + 1) * min(i, j) / 2 + max(i, j) -
min(i, j);
- outfile << sqrt(cPar.VVe_mle_null[c]) << "\t";
+ outfile << tab(j) << sqrt(cPar.VVe_mle_null[c]);
}
outfile << endl;
}
@@ -3634,7 +3634,7 @@ void GEMMA::WriteLog(int argc, char **argv, PARAM &cPar) {
for (size_t i = 0; i < cPar.n_ph; i++) {
for (size_t j = 0; j < cPar.n_cvt; j++) {
c = i * cPar.n_cvt + j;
- outfile << cPar.beta_remle_null[c] << "\t";
+ outfile << tab(j) << cPar.beta_remle_null[c];
}
outfile << endl;
}
@@ -3642,7 +3642,7 @@ void GEMMA::WriteLog(int argc, char **argv, PARAM &cPar) {
for (size_t i = 0; i < cPar.n_ph; i++) {
for (size_t j = 0; j < cPar.n_cvt; j++) {
c = i * cPar.n_cvt + j;
- outfile << cPar.se_beta_remle_null[c] << "\t";
+ outfile << tab(j) << cPar.se_beta_remle_null[c];
}
outfile << endl;
}
diff --git a/src/io.cpp b/src/io.cpp
index 79e753a..8f3b58f 100644
--- a/src/io.cpp
+++ b/src/io.cpp
@@ -1162,7 +1162,7 @@ void ReadFile_kin(const string &file_kin, vector<int> &indicator_idv,
}
if (i_total != ni_total) {
cout << "error! number of rows in the kinship file do "
- << "not match the number of phentypes." << endl;
+ << "not match the number of phenotypes." << endl;
error = true;
}
} else {
diff --git a/src/io.h b/src/io.h
index 27f145f..9edc5eb 100644
--- a/src/io.h
+++ b/src/io.h
@@ -28,6 +28,8 @@
#include "gzstream.h"
#include "param.h"
+#define tab(col) ( col ? "\t" : "")
+
using namespace std;
void ProgressBar(string str, double p, double total);
diff --git a/src/param.cpp b/src/param.cpp
index 6ab4339..d1879d1 100644
--- a/src/param.cpp
+++ b/src/param.cpp
@@ -1955,7 +1955,7 @@ void PARAM::WriteMatrix(const gsl_matrix *matrix_U, const string suffix) {
for (size_t i = 0; i < matrix_U->size1; ++i) {
for (size_t j = 0; j < matrix_U->size2; ++j) {
- outfile << gsl_matrix_get(matrix_U, i, j) << "\t";
+ outfile << tab(j) << gsl_matrix_get(matrix_U, i, j);
}
outfile << endl;
}