about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPjotr Prins2025-11-23 12:43:58 +0100
committerPjotr Prins2025-11-23 12:43:58 +0100
commit663778957ad37d5c7806d4f17c1f2e77b2b268fa (patch)
treeccba7405d0a609bd8dc1bf6e21069bf7ed3e5e80 /src
parent5b6b5e2ad97b4733125c0845cfae007e8094a687 (diff)
downloadpangemma-663778957ad37d5c7806d4f17c1f2e77b2b268fa.tar.gz
Replace G with K to avoid (my) confusion
Diffstat (limited to 'src')
-rw-r--r--src/gemma.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/gemma.cpp b/src/gemma.cpp
index 5804bde..4ef2059 100644
--- a/src/gemma.cpp
+++ b/src/gemma.cpp
@@ -2578,7 +2578,7 @@ void GEMMA::BatchRun(PARAM &cPar) {
     gsl_matrix *B = gsl_matrix_safe_alloc(Y->size2, W->size2); // B is a d by c
                                                           // matrix
     gsl_matrix *se_B = gsl_matrix_safe_alloc(Y->size2, W->size2);
-    gsl_matrix *G = gsl_matrix_safe_alloc(Y->size1, Y->size1);
+    gsl_matrix *K = gsl_matrix_safe_alloc(Y->size1, Y->size1);
     gsl_matrix *U = gsl_matrix_safe_alloc(Y->size1, Y->size1);
     gsl_matrix *UtW = gsl_matrix_calloc(Y->size1, W->size2);
     gsl_matrix *UtY = gsl_matrix_calloc(Y->size1, Y->size2);
@@ -2595,38 +2595,38 @@ void GEMMA::BatchRun(PARAM &cPar) {
       cPar.CopyGxe(env);
     }
 
-    // read relatedness matrix G
+    // read relatedness matrix K
     if (!(cPar.file_kin).empty()) {
       ReadFile_kin(cPar.file_kin, cPar.indicator_idv, cPar.mapID2num,
-                   cPar.k_mode, cPar.error, G);
+                   cPar.k_mode, cPar.error, K);
       debug_msg("Read K/GRM file");
       if (cPar.error == true) {
         cout << "error! fail to read kinship/relatedness file. " << endl;
         return;
       }
 
-      // center matrix G
-      CenterMatrix(G);
-      validate_K(G);
-      write(G, "G");
+      // center matrix K
+      CenterMatrix(K);
+      validate_K(K);
+      write(K, "K");
 
       // is residual weights are provided, then
       if (!cPar.file_weight.empty()) {
         cPar.CopyWeight(weight);
         double d, wi, wj;
-        for (size_t i = 0; i < G->size1; i++) {
+        for (size_t i = 0; i < K->size1; i++) {
           wi = gsl_vector_get(weight, i);
-          for (size_t j = i; j < G->size2; j++) {
+          for (size_t j = i; j < K->size2; j++) {
             wj = gsl_vector_get(weight, j);
-            d = gsl_matrix_get(G, i, j);
+            d = gsl_matrix_get(K, i, j);
             if (wi <= 0 || wj <= 0) {
               d = 0;
             } else {
               d /= safe_sqrt(wi * wj);
             }
-            gsl_matrix_set(G, i, j, d);
+            gsl_matrix_set(K, i, j, d);
             if (j != i) {
-              gsl_matrix_set(G, j, i, d);
+              gsl_matrix_set(K, j, i, d);
             }
           }
         }
@@ -2637,9 +2637,9 @@ void GEMMA::BatchRun(PARAM &cPar) {
       time_start = clock();
 
       if (cPar.a_mode == M_EIGEN) {
-        cPar.trace_G = EigenDecomp_Zeroed(G, U, eval, 0);
+        cPar.trace_G = EigenDecomp_Zeroed(K, U, eval, 0);
       } else {
-        cPar.trace_G = EigenDecomp_Zeroed(G, U, eval, 0);
+        cPar.trace_G = EigenDecomp_Zeroed(K, U, eval, 0);
       }
       // write(eval,"eval");
 
@@ -2876,7 +2876,7 @@ void GEMMA::BatchRun(PARAM &cPar) {
     gsl_matrix_safe_free(W);
     gsl_matrix_warn_free(B); // sometimes unused
     gsl_matrix_warn_free(se_B);
-    gsl_matrix_warn_free(G);
+    gsl_matrix_warn_free(K);
     gsl_matrix_safe_free(U);
     gsl_matrix_safe_free(UtW);
     gsl_matrix_safe_free(UtY);