-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modified files for strain-specific residual variance option #269
base: master
Are you sure you want to change the base?
Modified files for strain-specific residual variance option #269
Conversation
… option similar to cvt
…eplaced in the math with the null Ve
Small formatting change to -residvar
Updated resid_var math to CalcQi
Updated most functions except MphEM and remaining P-val functions
Continued to make appropriate math changes to MphCalcSigma, UpdateV, MphCalcLogL, MphEM, MphCalcP, MphCalcBeta, and other functions.
Finished theoretical changes in other functions and replaced all "eps_eval" entries with "eval_vec, sigmasq".
Replaced any lingering mentions of "eps_eval" with "eval_vec, sigmasq".
Changed mentions of "eps_eval" with "sigmasq". Still need to figure out how to get eigenvectors from the same place "eval" is derived.
Changed mention of eps_eval as a vector to "gsl_matrix *sigmasq"
Changed the one mention of "eps_eval" to "eval_vec" and "sigmasq". May actually need to return to this file in order for the code to actually run.
eps_eval --> eval_vec, sigmasq
Changed eps_eval to sigmasq and corrected any identified regions where dimensions did not match.
Replaced input of CopyResid from eps_eval to sigmasq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's what I've noticed. Most of the errors you're getting are due to mismatch between the arguments function requires and the arguments you provide, so ensure these are in sync. The rest I've tried to locate and comment on. Let's have a call (coordinate via Matrix) in case there's something I missed.
src/param.h
Outdated
@@ -136,6 +136,7 @@ class PARAM { | |||
string file_anno; // Optional. | |||
string file_gxe; // Optional. | |||
string file_cvt; // Optional. | |||
string file_residvar; // Optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice you called it file_residvar
here, but are using it as file_resid
elsewhere. A typo?
src/gemma.cpp
Outdated
@@ -2795,22 +2816,22 @@ void GEMMA::BatchRun(PARAM &cPar) { | |||
if (!cPar.file_bfile.empty()) { | |||
// PLINK analysis | |||
if (cPar.file_gxe.empty()) { | |||
cLmm.AnalyzePlink(U, eval, UtW, &UtY_col.vector, W, | |||
cLmm.AnalyzePlink(U, eval, eval_vec, sigmasq, UtW, &UtY_col.vector, W, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You didn't define eval_vec
anywhere earlier, that's why compiler is shouting. What is the intended use for eval_vec
?
Also note that sigmasq
is not defined either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then there's also required/provided argument mismatch. AnalyzePlink
requires (U, eval, UtW, Uty, W, y, gwasnps)
, while you provide (U, eval, eval_vec, sigmasq, UtW, Uty, W, y, gwasnps)
. I guess AnalyzePlink
needs to be modified to accept new arguments first.
src/mvlmm.h
Outdated
@@ -35,6 +35,7 @@ class MVLMM { | |||
|
|||
string file_bfile; | |||
string file_geno; | |||
//string file_residvar maybe? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if you need to use it (although you seems to only use residuals as sigmasq
, so maybe no need for it.) And don't forget to add a line assigning it to CopyFromParam
in case you add this field.
Changed "file_residvar" back to "file_resid"
Transferred all instances of "eval_vec" to "U".
Changed all instances of "_residvar" to "resid" to keep things consistent.
Changed all instances of "residvar" to "resid" to keep things consistent
Changed inputs to "CalcLmmVgVeBeta", "CalcLambda", and "AnalyzePlink" according to their use elsewhere (i.e. no more "eval_vec").
Changed residvar to resid for consistency.
Changed all mentions of residvar to resid for consistency
Changed all residvar to resid for consistency.
Changed "residvar" to "resid" and removed unnecessary mentions of "eval_vec" from other functions.
Removed repeat parameter mentions of eigenvectors U in Analyze functions
Fixed examples of mishandled data types from when defining "scalar" data type to: double scalar = gsl_matrix_get(sigmasq, 0, 0) / ve; gsl_matrix_scale(Sigma, scalar); double epsilon = gsl_matrix_get(Sigma, k, k);
Fixed remaining cases of how the "scalar" variable is defined, and how many other functions are attributed.
Cleaned up various parameter specifications within function definitions.
Corrected CalcLambda and CalcLmmVgVeBeta mentions that were actually from lmm no mvlmm
sigmasq needs to be in the AnalyzeBimbam and AnalyzePlink function definitions.
const gsl_matrix *sigmasq, needs to be in these functions due to MphEM calls within other functions in mvlmm.cpp.
Removed duplicate mention of U within AnalyzePlinkGXE
Updated AnalyzePlink and AnalyzeBimbam function calls to include "sigmasq".
Added variable declaration for "sigmasq" matrix.
Added sigmasq variable calls for other places.
Converted "resid" from vector<double to vector<vector<double>>
Removed the (I think) unnecessary input of U within the "CalcLmmVgVeBeta" function call.
Updated residual variance file reading call from ReadFile_column() to ReadFile_resid().
Bug fixes after session with Artyom
Big fixes after session with Artyom
Bug fixes after session with Artyom
Bug fixes after session with Artyom
Major bug fixes after session with Artyom
Changed ReadFile_resid's parameter expectations.
Redefined ReadFile_resid() to expect a gsl_matrix instead of <vector<vector<double>> for resid. This seems to be a consistent sticking point.
Changed ReadFile_resid so that gsl_matrix operations are being used for resid instead of vector<vector<double>> operations.
Threw out the following additional definition of ReadFile_resid: void ReadFile_resid(const string &file_resid, bool &error, gsl_matrix *sigmasq) { debug_msg("entered"); igzstream infile(file_resid.c_str(), igzstream::in); if (!infile) { cout << "error! fail to open the residual variance file: " << file_resid << endl; error = true; return; } size_t n_row = sigmasq->size1, n_col = sigmasq->size2, i_row = 0, i_col = 0; gsl_matrix_set_zero(sigmasq); //change this so that sigmasq = V_e somehow string line; char *ch_ptr; double d; while (getline(infile, line)) { if (i_row == n_row) { cout << "error! number of rows in the residual variance file is larger " << "than expected." << endl; error = true; } i_col = 0; ch_ptr = strtok((char *)line.c_str(), " ,\t"); while (ch_ptr != NULL) { if (i_col == n_col) { cout << "error! number of columns in the residual variance file " << "is larger than expected, for row = " << i_row << endl; error = true; } d = atof(ch_ptr); gsl_matrix_set(sigmasq, i_row, i_col, d); i_col++; ch_ptr = strtok(NULL, " ,\t"); } i_row++; } infile.close(); infile.clear(); return; }
Added additional ReadFile_resid call back, changing mentions of sigmasq back to resid.
Edited user documentation for "-resid" option.
Changed mention of "resid" to "sigmasq" within the function "CheckResid"
Created new version of "CheckResid" function that hopefully helps in debugging the empty "sigmasq" issue and commented out seemingly redundant "CheckResid" function initiation.
Restored ReadFile_resid to its original, because the other caused compile errors.
These changes include the modifications to the math inside mvlmm, and attempts to add an option for the user to input their own strain-specific residual variance column within the files gemma_io.cpp and param.cpp. Thanks for your help!