diff options
Diffstat (limited to 'src/param.cpp')
| -rw-r--r-- | src/param.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/param.cpp b/src/param.cpp index 955da8e..a81d18f 100644 --- a/src/param.cpp +++ b/src/param.cpp @@ -163,7 +163,7 @@ void PARAM::ReadFiles(void) { setSnps.clear(); } - // Also read KSNP set. Snps used by GRM. + // Also read KSNP set. Reads all Snps later to be used by GRM. if (!file_ksnps.empty()) { if (ReadFile_snps(file_ksnps, setKSnps) == false) { error = true; @@ -192,10 +192,12 @@ void PARAM::ReadFiles(void) { if (!file_geno.empty()) { + // --- Read (multi-)column phenotypes into pheno and set the NA indicator if (ReadFile_pheno(file_pheno, indicator_pheno, pheno, p_column) == false) { error = true; } + // --- compute ns_total by readin geno file if (!is_mdb && is_check_mode() && CountFileLines(file_geno, ns_total) == false) { error = true; } @@ -225,7 +227,7 @@ void PARAM::ReadFiles(void) { indicator_idv.push_back(k); } - ns_test = 0; + ns_test = 0; // number of snps to test return; } @@ -283,7 +285,7 @@ void PARAM::ReadFiles(void) { // Post-process covariates and phenotypes, obtain // ni_test, save all useful covariates. - ProcessCvtPhen(); + ProcessInclusionIndicators(); // Obtain covariate matrix. auto W1 = gsl_matrix_safe_alloc(ni_test, n_cvt); @@ -316,7 +318,7 @@ void PARAM::ReadFiles(void) { // Post-process covariates and phenotypes, obtain // ni_test, save all useful covariates. - ProcessCvtPhen(); + ProcessInclusionIndicators(); // Obtain covariate matrix. auto W2 = gsl_matrix_safe_alloc(ni_test, n_cvt); @@ -335,10 +337,9 @@ void PARAM::ReadFiles(void) { ns_total = indicator_snp.size(); } - - // Check MDB format + // lmdb-type genotype file: if (is_mdb && !file_geno.empty()) { - ns_total = -1; + ns_total = indicator_snp.size(); } // Read genotype file for multiple PLINK files. @@ -376,7 +377,7 @@ void PARAM::ReadFiles(void) { // Post-process covariates and phenotypes, obtain // ni_test, save all useful covariates. - ProcessCvtPhen(); + ProcessInclusionIndicators(); // Obtain covariate matrix. W3 = gsl_matrix_safe_alloc(ni_test, n_cvt); @@ -420,7 +421,7 @@ void PARAM::ReadFiles(void) { // Post-process covariates and phenotypes, obtain ni_test, // save all useful covariates. - ProcessCvtPhen(); + ProcessInclusionIndicators(); // Obtain covariate matrix. gsl_matrix *W4 = gsl_matrix_safe_alloc(ni_test, n_cvt); @@ -473,7 +474,7 @@ void PARAM::ReadFiles(void) { // Post-process covariates and phenotypes, obtain // ni_test, save all useful covariates. - ProcessCvtPhen(); + ProcessInclusionIndicators(); // Obtain covariate matrix. // gsl_matrix *W5 = gsl_matrix_alloc(ni_test, n_cvt); @@ -508,7 +509,7 @@ void PARAM::ReadFiles(void) { // Post-process covariates and phenotypes, obtain // ni_test, save all useful covariates. - ProcessCvtPhen(); + ProcessInclusionIndicators(); } // Compute setKSnps when -loco is passed in @@ -1989,7 +1990,7 @@ void PARAM::CheckCvt() { } // Post-process phenotypes and covariates. -void PARAM::ProcessCvtPhen() { +void PARAM::ProcessInclusionIndicators() { // Convert indicator_pheno to indicator_idv. int k = 1; @@ -2027,11 +2028,8 @@ void PARAM::ProcessCvtPhen() { // Obtain ni_test. ni_test = 0; - for (vector<int>::size_type i = 0; i < (indicator_idv).size(); ++i) { - if (indicator_idv[i] == 0) { - continue; - } - ni_test++; + for(auto &i : indicator_idv) { + ni_test += indicator_idv[i]; } // If subsample number is set, perform a random sub-sampling |
