about summary refs log tree commit diff
path: root/src/gemma.cpp
diff options
context:
space:
mode:
authorPjotr Prins2025-12-01 08:43:56 +0100
committerPjotr Prins2025-12-01 08:43:56 +0100
commitb76a21467c8692f263c07aa4f013370a8d10ce20 (patch)
tree5c7a985c97e745e24b7793e5aa3114c9b6ff40a7 /src/gemma.cpp
parente0a32b97dd2e6b0ab769b6e7ec6d3d217eeb15a0 (diff)
downloadpangemma-b76a21467c8692f263c07aa4f013370a8d10ce20.tar.gz
mdb gwa
Diffstat (limited to 'src/gemma.cpp')
-rw-r--r--src/gemma.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/gemma.cpp b/src/gemma.cpp
index fb2227e..0145563 100644
--- a/src/gemma.cpp
+++ b/src/gemma.cpp
@@ -2591,21 +2591,20 @@ void GEMMA::BatchRun(PARAM &cPar) {
       cPar.a_mode == M_LMM4 || cPar.a_mode == M_LMM5 || cPar.a_mode == M_LMM9 ||
       cPar.a_mode == M_EIGEN) { // Fit LMM or mvLMM or eigen
     write(cPar.a_mode, "Mode");
-    auto ni_test = cPar.ni_test;
-    auto n_ph = cPar.n_ph;
-    enforce(ni_test > 0);
+    auto n_ph    = cPar.n_ph;                                      // # of trait values
+    auto ni_test = cPar.ni_test;                                   // # of individuals to test
     enforce(n_ph > 0);
-    gsl_matrix *Y = gsl_matrix_safe_alloc(ni_test, n_ph); // Y is ind x phenotypes
+    enforce(ni_test > 0);
+    gsl_matrix *Y = gsl_matrix_safe_alloc(ni_test, n_ph);          // Y is ind x phenotypes
     enforce_msg(Y, "allocate Y"); // just to be sure
     gsl_matrix *W = gsl_matrix_safe_alloc(ni_test, cPar.n_cvt);    // W is ind x covariates
-    gsl_matrix *B = gsl_matrix_safe_alloc(Y->size2, W->size2);      // B is a d by c (effect size)
-                                                          // matrix
-    gsl_matrix *se_B = gsl_matrix_safe_alloc(Y->size2, W->size2);   // se
+    gsl_matrix *B = gsl_matrix_safe_alloc(n_ph, W->size2);         // B is a d by c (effect size)
+    gsl_matrix *se_B = gsl_matrix_safe_alloc(n_ph, W->size2);      // se
     enforce(ni_test > 0);
-    gsl_matrix *K = gsl_matrix_safe_alloc(ni_test, ni_test);      // Kinship aka as G/GRM in the equation ind x ind
+    gsl_matrix *K = gsl_matrix_safe_alloc(ni_test, ni_test);       // Kinship aka as G/GRM in the equation ind x ind
     gsl_matrix *U = gsl_matrix_safe_alloc(ni_test, ni_test);
     gsl_matrix *UtW = gsl_matrix_calloc(ni_test, W->size2);        // Transformed ind x covariates
-    gsl_matrix *UtY = gsl_matrix_calloc(ni_test, Y->size2);        // Transforemd ind x phenotypes
+    gsl_matrix *UtY = gsl_matrix_calloc(ni_test, n_ph);            // Transformed ind x phenotypes
     gsl_vector *eval = gsl_vector_calloc(ni_test);                 // eigen values
     gsl_vector *env = gsl_vector_safe_alloc(ni_test);              // E environment
     gsl_vector *weight = gsl_vector_safe_alloc(ni_test);           // weights