[Genabel-commits] r1123 - pkg/ProbABEL/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Mar 9 00:19:12 CET 2013
Author: maartenk
Date: 2013-03-09 00:19:11 +0100 (Sat, 09 Mar 2013)
New Revision: 1123
Modified:
pkg/ProbABEL/src/main.cpp
Log:
first commit to remove the code dulication for ngpreds=1 and ngpreds=2. This should make the code beter readable
Modified: pkg/ProbABEL/src/main.cpp
===================================================================
--- pkg/ProbABEL/src/main.cpp 2013-03-08 16:54:39 UTC (rev 1122)
+++ pkg/ProbABEL/src/main.cpp 2013-03-08 23:19:11 UTC (rev 1123)
@@ -58,33 +58,31 @@
{
if (csnp == 0)
{
- std::cout << "Analysis: "
- << setw(5) << 100. * static_cast<double>(csnp)
- / static_cast<double>(nsnps)
- << "%...";
- }
- else
+ std::cout << "Analysis: " << setw(5)
+ << 100. * static_cast<double>(csnp)
+ / static_cast<double>(nsnps) << "%...";
+ } else
{
- std::cout << "\b\b\b\b\b\b\b\b\b"
- << setw (5) << 100. * static_cast<double>(csnp)
- / static_cast<double>(nsnps)
- << "%...";
+ `
+ std::cout << "\b\b\b\b\b\b\b\b\b" << setw(5)
+ << 100. * static_cast<double>(csnp)
+ / static_cast<double>(nsnps) << "%...";
}
std::cout.flush();
}
}
void open_files_for_output(std::vector<std::ofstream*>& outfile,
- std::string& outfilename_str)
+ std::string& outfilename_str)
{
//create a list of filenames
const int amount_of_files = 5;
- std::string filenames[amount_of_files] =
- { outfilename_str + "_2df.out.txt",
- outfilename_str + "_add.out.txt",
- outfilename_str + "_domin.out.txt",
- outfilename_str + "_recess.out.txt",
- outfilename_str + "_over_domin.out.txt" };
+ std::string filenames[amount_of_files] = {
+ outfilename_str + "_2df.out.txt",
+ outfilename_str + "_add.out.txt",
+ outfilename_str + "_domin.out.txt",
+ outfilename_str + "_recess.out.txt",
+ outfilename_str + "_over_domin.out.txt" };
for (int i = 0; i < amount_of_files; i++)
{
@@ -93,7 +91,7 @@
if (!outfile[i]->is_open())
{
std::cerr << "Cannot open file for writing: " << filenames[i]
- << "\n";
+ << "\n";
exit(1);
}
}
@@ -102,23 +100,20 @@
int create_phenotype(phedata& phd, cmdvars& input_var)
{
phd.set_is_interaction_excluded(input_var.isIsInteractionExcluded());
- phd.setphedata(input_var.getPhefilename(),
- input_var.getNoutcomes(),
- input_var.getNpeople(),
- input_var.getInteraction(),
- input_var.isIscox());
+ phd.setphedata(input_var.getPhefilename(), input_var.getNoutcomes(),
+ input_var.getNpeople(), input_var.getInteraction(),
+ input_var.isIscox());
int interaction_cox = input_var.getInteraction();
#if COXPH
interaction_cox--;
#endif
- if (input_var.getInteraction() < 0 ||
- input_var.getInteraction() > phd.ncov ||
- interaction_cox > phd.ncov)
+ if (input_var.getInteraction() < 0 || input_var.getInteraction() > phd.ncov
+ || interaction_cox > phd.ncov)
{
std::cerr << "error: Interaction parameter is out of range "
- << "(interaction=" << input_var.getInteraction() << ") \n";
+ << "(interaction=" << input_var.getInteraction() << ") \n";
exit(1);
}
@@ -140,15 +135,12 @@
{
for (unsigned int i = 0; i < outfile.size(); i++)
{
- (*outfile[i]) << "name" << input_var.getSep()
- << "A1" << input_var.getSep()
- << "A2" << input_var.getSep()
- << "Freq1" << input_var.getSep()
- << "MAF" << input_var.getSep()
- << "Quality" << input_var.getSep()
- << "Rsq" << input_var.getSep()
- << "n" << input_var.getSep()
- << "Mean_predictor_allele";
+ (*outfile[i]) << "name" << input_var.getSep() << "A1"
+ << input_var.getSep() << "A2" << input_var.getSep() << "Freq1"
+ << input_var.getSep() << "MAF" << input_var.getSep()
+ << "Quality" << input_var.getSep() << "Rsq"
+ << input_var.getSep() << "n" << input_var.getSep()
+ << "Mean_predictor_allele";
if (input_var.getChrom() != "-1")
(*outfile[i]) << input_var.getSep() << "chrom";
if (input_var.getMapfilename() != NULL)
@@ -159,10 +151,9 @@
{
for (unsigned int file = 0; file < outfile.size(); file++)
for (int i = 0; i < phd.n_model_terms - 1; i++)
- *outfile[file] << input_var.getSep()
- << "beta_" << phd.model_terms[i]
- << input_var.getSep() << "sebeta_"
- << phd.model_terms[i];
+ *outfile[file] << input_var.getSep() << "beta_"
+ << phd.model_terms[i] << input_var.getSep() << "sebeta_"
+ << phd.model_terms[i];
}
}
@@ -172,51 +163,48 @@
create_start_of_header(outfile, input_var, phd);
*outfile[0] << input_var.getSep() << "beta_SNP_A1A2" << input_var.getSep()
- << "beta_SNP_A1A1" << input_var.getSep() << "sebeta_SNP_A1A2"
- << input_var.getSep() << "sebeta_SNP_A1A1";
+ << "beta_SNP_A1A1" << input_var.getSep() << "sebeta_SNP_A1A2"
+ << input_var.getSep() << "sebeta_SNP_A1A1";
*outfile[1] << input_var.getSep() << "beta_SNP_addA1" << input_var.getSep()
- << "sebeta_SNP_addA1";
+ << "sebeta_SNP_addA1";
*outfile[2] << input_var.getSep() << "beta_SNP_domA1" << input_var.getSep()
- << "sebeta_SNP_domA1";
+ << "sebeta_SNP_domA1";
*outfile[3] << input_var.getSep() << "beta_SNP_recA1" << input_var.getSep()
- << "sebeta_SNP_recA1";
+ << "sebeta_SNP_recA1";
*outfile[4] << input_var.getSep() << "beta_SNP_odom" << input_var.getSep()
- << "sebeta_SNP_odom";
+ << "sebeta_SNP_odom";
if (input_var.getInteraction() != 0)
{
//Han Chen
*outfile[0] << input_var.getSep() << "beta_SNP_A1A2_"
- << phd.model_terms[interaction_cox]
- << input_var.getSep() << "sebeta_SNP_A1A2_"
- << phd.model_terms[interaction_cox]
- << input_var.getSep() << "beta_SNP_A1A1_"
- << phd.model_terms[interaction_cox]
- << input_var.getSep() << "sebeta_SNP_A1A1_"
- << phd.model_terms[interaction_cox];
+ << phd.model_terms[interaction_cox] << input_var.getSep()
+ << "sebeta_SNP_A1A2_" << phd.model_terms[interaction_cox]
+ << input_var.getSep() << "beta_SNP_A1A1_"
+ << phd.model_terms[interaction_cox] << input_var.getSep()
+ << "sebeta_SNP_A1A1_" << phd.model_terms[interaction_cox];
#if !COXPH
if (input_var.getInverseFilename() == NULL && !input_var.getAllcov())
{
*outfile[0] << input_var.getSep() << "cov_SNP_A1A2_int_SNP_"
- << phd.model_terms[interaction_cox]
- << input_var.getSep() << "cov_SNP_A1A1_int_SNP_"
- << phd.model_terms[interaction_cox];
+ << phd.model_terms[interaction_cox] << input_var.getSep()
+ << "cov_SNP_A1A1_int_SNP_"
+ << phd.model_terms[interaction_cox];
}
#endif
//Oct 26, 2009
for (unsigned int file = 1; file < outfile.size(); file++)
{
*outfile[file] << input_var.getSep() << "beta_SNP_"
- << phd.model_terms[interaction_cox]
- << input_var.getSep() << "sebeta_SNP_"
- << phd.model_terms[interaction_cox];
+ << phd.model_terms[interaction_cox] << input_var.getSep()
+ << "sebeta_SNP_" << phd.model_terms[interaction_cox];
//Han Chen
#if !COXPH
if (input_var.getInverseFilename() == NULL
- && !input_var.getAllcov())
+ && !input_var.getAllcov())
{
*outfile[file] << input_var.getSep() << "cov_SNP_int_SNP_"
- << phd.model_terms[interaction_cox];
+ << phd.model_terms[interaction_cox];
}
#endif
//Oct 26, 2009
@@ -230,18 +218,17 @@
}
void create_header2(std::vector<std::ofstream*>& outfile, cmdvars& input_var,
- phedata& phd, int interaction_cox)
+ phedata& phd, int interaction_cox)
{
create_start_of_header(outfile, input_var, phd);
- *outfile[0] << input_var.getSep() << "beta_SNP_add"
- << input_var.getSep() << "sebeta_SNP_add";
+ *outfile[0] << input_var.getSep() << "beta_SNP_add" << input_var.getSep()
+ << "sebeta_SNP_add";
if (input_var.getInteraction() != 0)
{
*outfile[0] << input_var.getSep() << "beta_SNP_"
- << phd.model_terms[interaction_cox]
- << input_var.getSep() << "sebeta_SNP_"
- << phd.model_terms[interaction_cox];
+ << phd.model_terms[interaction_cox] << input_var.getSep()
+ << "sebeta_SNP_" << phd.model_terms[interaction_cox];
}
if (input_var.getInverseFilename() == NULL)
@@ -251,7 +238,7 @@
if (input_var.getInteraction() != 0 && !input_var.getAllcov())
{
*outfile[0] << input_var.getSep() << "cov_SNP_int_SNP_"
- << phd.model_terms[interaction_cox];
+ << phd.model_terms[interaction_cox];
}
#endif
*outfile[0] << input_var.getSep() << "loglik"; //"chi2_SNP";
@@ -260,6 +247,26 @@
*outfile[0] << "\n";
}
+void write_mlinfo(const std::vector<std::ofstream*>& outfile, unsigned int file,
+ const mlinfo& mli, int csnp, const cmdvars& input_var, int gcount,
+ double freq)
+{
+ *outfile[file] << mli.name[csnp] << input_var.getSep() << mli.A1[csnp]
+ << input_var.getSep() << mli.A2[csnp] << input_var.getSep()
+ << mli.Freq1[csnp] << input_var.getSep() << mli.MAF[csnp]
+ << input_var.getSep() << mli.Quality[csnp] << input_var.getSep()
+ << mli.Rsq[csnp] << input_var.getSep() << gcount
+ << input_var.getSep() << freq;
+ if (input_var.getChrom() != "-1")
+ {
+ *outfile[file] << input_var.getSep() << input_var.getChrom();
+ }
+ if (input_var.getMapfilename() != NULL)
+ {
+ *outfile[file] << input_var.getSep() << mli.map[csnp];
+ }
+}
+
int main(int argc, char * argv[])
{
cmdvars input_var;
@@ -301,8 +308,8 @@
#if LOGISTIC
if (input_var.getInverseFilename()!= NULL)
{
- std::cerr << "ERROR: mmscore is forbidden for logistic regression\n";
- exit(1);
+ std::cerr << "ERROR: mmscore is forbidden for logistic regression\n";
+ exit(1);
}
#endif
*/
@@ -317,24 +324,24 @@
if (!input_var.getIsFvf())
// use the non-filevector input format
gtd.re_gendata(input_var.getGenfilename(), nsnps,
- input_var.getNgpreds(), phd.nids_all, phd.nids,
- phd.allmeasured, input_var.getSkipd(), phd.idnames);
+ input_var.getNgpreds(), phd.nids_all, phd.nids, phd.allmeasured,
+ input_var.getSkipd(), phd.idnames);
else
// use the filevector input format (missing second last skipd
// parameter)
gtd.re_gendata(input_var.getStrGenfilename(), nsnps,
- input_var.getNgpreds(), phd.nids_all, phd.nids,
- phd.allmeasured, phd.idnames);
+ input_var.getNgpreds(), phd.nids_all, phd.nids, phd.allmeasured,
+ phd.idnames);
std::cout << " loaded genotypic data ..." << std::flush;
/**
- if (input_var.getIsFvf())
- gendata gtd(str_genfilename, nsnps, input_var.getNgpreds(),
- phd.nids_all, phd.allmeasured, phd.idnames);
- else
- gendata gtd(input_var.getGenfilename(), nsnps,
- input_var.getNgpreds(), phd.nids_all, phd.nids,
- phd.allmeasured, skipd, phd.idnames);
+ if (input_var.getIsFvf())
+ gendata gtd(str_genfilename, nsnps, input_var.getNgpreds(),
+ phd.nids_all, phd.allmeasured, phd.idnames);
+ else
+ gendata gtd(input_var.getGenfilename(), nsnps,
+ input_var.getNgpreds(), phd.nids_all, phd.nids,
+ phd.allmeasured, skipd, phd.idnames);
**/
// estimate null model
@@ -348,8 +355,8 @@
#if LOGISTIC
logistic_reg nrd = logistic_reg(nrgd);
nrd.estimate(nrgd, 0, MAXITER, EPS, CHOLTOL, 0,
- input_var.getInteraction(), input_var.getNgpreds(),
- invvarmatrix, input_var.getRobust(), 1);
+ input_var.getInteraction(), input_var.getNgpreds(),
+ invvarmatrix, input_var.getRobust(), 1);
#elif LINEAR
linear_reg nrd = linear_reg(nrgd);
@@ -357,12 +364,12 @@
std::cout << "[DEBUG] linear_reg nrd = linear_reg(nrgd); DONE.";
#endif
nrd.estimate(nrgd, 0, CHOLTOL, 0, input_var.getInteraction(),
- input_var.getNgpreds(), invvarmatrix, input_var.getRobust(), 1);
+ input_var.getNgpreds(), invvarmatrix, input_var.getRobust(), 1);
#elif COXPH
coxph_reg nrd(nrgd);
nrd.estimate(nrgd, 0, MAXITER, EPS, CHOLTOL, 0,
- input_var.getInteraction(), input_var.getNgpreds(), 1);
+ input_var.getInteraction(), input_var.getNgpreds(), 1);
#endif
std::cout << " estimated null model ...";
@@ -389,16 +396,15 @@
{
create_header_1(outfile, input_var, phd, interaction_cox);
}
- }
- else //Only additive model. Only one output file
+ } else //Only additive model. Only one output file
{
outfile.push_back(
- new std::ofstream((outfilename_str + "_add.out.txt").c_str()));
+ new std::ofstream((outfilename_str + "_add.out.txt").c_str()));
if (!outfile[0]->is_open())
{
std::cerr << "Cannot open file for writing: " << outfilename_str
- << "\n";
+ << "\n";
exit(1);
}
if (input_var.getNohead() != 1)
@@ -426,32 +432,32 @@
}
if (input_var.getNgpreds()==2)
{
- outfile << input_var.getSep() << "beta_SNP_A1A2"
- << input_var.getSep() << "beta_SNP_A1A1"
- << input_var.getSep() << "sebeta_SNP_A1A2"
- << input_var.getSep() << "sebeta_SNP_a1A1"
- << input_var.getSep() << "chi2_SNP_2df"
- << input_var.getSep() << "beta_SNP_addA1"
- << input_var.getSep() << "sebeta_SNP_addA1"
- << input_var.getSep() << "chi2_SNP_addA1"
- << input_var.getSep() << "beta_SNP_domA1"
- << input_var.getSep() << "sebeta_SNP_domA1"
- << input_var.getSep() << "chi2_SNP_domA1"
- << input_var.getSep() << "beta_SNP_recA1"
- << input_var.getSep() << "sebeta_SNP_recA1"
- << input_var.getSep() << "chi2_SNP_recA1"
- << input_var.getSep() << "beta_SNP_odom"
- << input_var.getSep() << "sebeta_SNP_odom"
- << input_var.getSep() << "chi2_SNP_odom\n";
+ outfile << input_var.getSep() << "beta_SNP_A1A2"
+ << input_var.getSep() << "beta_SNP_A1A1"
+ << input_var.getSep() << "sebeta_SNP_A1A2"
+ << input_var.getSep() << "sebeta_SNP_a1A1"
+ << input_var.getSep() << "chi2_SNP_2df"
+ << input_var.getSep() << "beta_SNP_addA1"
+ << input_var.getSep() << "sebeta_SNP_addA1"
+ << input_var.getSep() << "chi2_SNP_addA1"
+ << input_var.getSep() << "beta_SNP_domA1"
+ << input_var.getSep() << "sebeta_SNP_domA1"
+ << input_var.getSep() << "chi2_SNP_domA1"
+ << input_var.getSep() << "beta_SNP_recA1"
+ << input_var.getSep() << "sebeta_SNP_recA1"
+ << input_var.getSep() << "chi2_SNP_recA1"
+ << input_var.getSep() << "beta_SNP_odom"
+ << input_var.getSep() << "sebeta_SNP_odom"
+ << input_var.getSep() << "chi2_SNP_odom\n";
}
else
{
- outfile << input_var.getSep() << "beta_SNP_add"
- << input_var.getSep() << "sebeta_SNP_add"
- << input_var.getSep() << "chi2_SNP_add\n";
+ outfile << input_var.getSep() << "beta_SNP_add"
+ << input_var.getSep() << "sebeta_SNP_add"
+ << input_var.getSep() << "chi2_SNP_add\n";
}
- */
+ */
// exit(1);
//________________________________________________________________
//Maksim, 9 Jan, 2009
@@ -492,8 +498,7 @@
gcount++;
freq += snpdata1[ii] + snpdata2[ii] * 0.5;
}
- }
- else
+ } else
{
// freq = (gtd.G).column_mean(csnp)/2.;
gtd.get_var(csnp, snpdata1);
@@ -507,56 +512,48 @@
freq /= static_cast<double>(gcount);
int poly = 1;
if (fabs(freq) < 1.e-16 || fabs(1. - freq) < 1.e-16)
+ {
poly = 0;
-
+ }
if (fabs(mli.Rsq[csnp]) < 1.e-16)
+ {
poly = 0;
+ }
+ //
//All models output. One file per each model
+ //
if (input_var.getNgpreds() == 2)
{
//Write mlinfo to output:
for (unsigned int file = 0; file < outfile.size(); file++)
{
- *outfile[file] << mli.name[csnp]
- << input_var.getSep() << mli.A1[csnp]
- << input_var.getSep() << mli.A2[csnp]
- << input_var.getSep() << mli.Freq1[csnp]
- << input_var.getSep() << mli.MAF[csnp]
- << input_var.getSep() << mli.Quality[csnp]
- << input_var.getSep() << mli.Rsq[csnp]
- << input_var.getSep() << gcount
- << input_var.getSep() << freq;
- if (input_var.getChrom() != "-1")
- *outfile[file] << input_var.getSep()
- << input_var.getChrom();
- if (input_var.getMapfilename() != NULL)
- *outfile[file] << input_var.getSep() << mli.map[csnp];
+ write_mlinfo(outfile, file, mli, csnp, input_var, gcount, freq);
}
for (int model = 0; model < maxmod; model++)
{
if (poly) //allel freq is not to rare
{
+
#if LOGISTIC
logistic_reg rd(rgd);
if (input_var.getScore())
- rd.score(nrd.residuals, rgd, 0, CHOLTOL, model,
- input_var.getInteraction(),
- input_var.getNgpreds(),
- invvarmatrix);
+ rd.score(nrd.residuals, rgd, 0, CHOLTOL, model,
+ input_var.getInteraction(),
+ input_var.getNgpreds(),
+ invvarmatrix);
else
rd.estimate(rgd, 0, MAXITER, EPS, CHOLTOL, model,
- input_var.getInteraction(),
- input_var.getNgpreds(),
- invvarmatrix,
- input_var.getRobust());
+ input_var.getInteraction(),
+ input_var.getNgpreds(),
+ invvarmatrix,
+ input_var.getRobust());
#elif LINEAR
linear_reg rd(rgd);
if (input_var.getScore())
rd.score(nrd.residuals, rgd, 0, CHOLTOL, model,
- input_var.getInteraction(),
- input_var.getNgpreds(),
- invvarmatrix);
+ input_var.getInteraction(),
+ input_var.getNgpreds(), invvarmatrix);
else
{
// rd.mmscore(rgd,0,CHOLTOL,model,input_var.getInteraction(), input_var.getNgpreds(), invvarmatrix);
@@ -568,50 +565,67 @@
#elif COXPH
coxph_reg rd(rgd);
rd.estimate(rgd, 0, MAXITER, EPS, CHOLTOL, model,
- input_var.getInteraction(), true,
- input_var.getNgpreds());
+ input_var.getInteraction(), true,
+ input_var.getNgpreds());
#endif
if (!input_var.getAllcov() && model == 0
- && input_var.getInteraction() == 0)
- start_pos = rd.beta.nrow - 2;
- else if (!input_var.getAllcov() && model == 0
- && input_var.getInteraction() != 0)
- start_pos = rd.beta.nrow - 4;
- else if (!input_var.getAllcov() && model != 0
- && input_var.getInteraction() == 0)
+ && input_var.getInteraction() == 0)
+ {
+ if (input_var.getNgpreds() == 2)
+ {
+ start_pos = rd.beta.nrow - 2;
+ } else
+ {
+ start_pos = rd.beta.nrow - 1;
+ }
+ } else if (!input_var.getAllcov() && model == 0
+ && input_var.getInteraction() != 0)
+ {
+ if (input_var.getNgpreds() == 2)
+ {
+ start_pos = rd.beta.nrow - 4;
+ } else
+ {
+ start_pos = rd.beta.nrow - 2;
+ }
+ } else if (!input_var.getAllcov() && model != 0
+ && input_var.getInteraction() == 0)
+ {
start_pos = rd.beta.nrow - 1;
- else if (!input_var.getAllcov() && model != 0
- && input_var.getInteraction() != 0)
+ } else if (!input_var.getAllcov() && model != 0
+ && input_var.getInteraction() != 0)
+ {
start_pos = rd.beta.nrow - 2;
- else
+ } else
+ {
start_pos = 0;
+ }
for (int pos = start_pos; pos < rd.beta.nrow; pos++)
{
*beta_sebeta[model] << input_var.getSep()
- << rd.beta[pos]
- << input_var.getSep()
- << rd.sebeta[pos];
+ << rd.beta[pos] << input_var.getSep()
+ << rd.sebeta[pos];
//Han Chen
#if !COXPH
if (input_var.getInverseFilename() == NULL
- && !input_var.getAllcov()
- && input_var.getInteraction() != 0)
+ && !input_var.getAllcov()
+ && input_var.getInteraction() != 0)
{
if (pos > start_pos)
{
if (model == 0)
{
- if (pos > start_pos + 2)
+ if (pos > start_pos + 2
+ || input_var.getNgpreds() != 2)
{
*covvalue[model]
- << rd.covariance[pos - 3]
- << input_var.getSep()
- << rd.covariance[pos - 2];
+ << rd.covariance[pos - 3]
+ << input_var.getSep()
+ << rd.covariance[pos - 2];
}
- }
- else
+ } else
{
*covvalue[model] << rd.covariance[pos - 1];
}
@@ -623,153 +637,222 @@
//calculate chi2
//________________________________
- if (input_var.getScore() == 0)
+ if (input_var.getInverseFilename() == NULL
+ && input_var.getNgpreds() != 2)
{
- //*chi2[model] << 2.*(rd.loglik-null_loglik);
- *chi2[model] << rd.loglik;
+
+ if (input_var.getScore() == 0)
+ {
+ //*chi2[model] << 2.*(rd.loglik-null_loglik);
+ *chi2[model] << rd.loglik;
+ } else
+ {
+ //*chi2[model] << rd.chi2_score;
+ *chi2[model] << "nan";
+ }
}
- else
- {
- //*chi2[model] << rd.chi2_score;
- *chi2[model] << "nan";
- }
//________________________________
- }
- else //beta, sebeta = nan
+ } else //beta, sebeta = nan
{
if (!input_var.getAllcov() && model == 0
- && input_var.getInteraction() == 0)
- start_pos = rgd.X.ncol - 2;
- else if (!input_var.getAllcov() && model == 0
- && input_var.getInteraction() != 0)
- start_pos = rgd.X.ncol - 4;
- else if (!input_var.getAllcov() && model != 0
- && input_var.getInteraction() == 0)
+ && input_var.getInteraction() == 0)
+ {
+ if (input_var.getNgpreds() == 2)
+ {
+ start_pos = rgd.X.ncol - 2;
+ } else
+ {
+ start_pos = rgd.X.ncol - 1;
+ }
+ } else if (!input_var.getAllcov() && model == 0
+ && input_var.getInteraction() != 0)
+ {
+ if (input_var.getNgpreds() == 2)
+ {
+ start_pos = rgd.X.ncol - 4;
+ } else
+ {
+ start_pos = rgd.X.ncol - 2;
+ }
+ } else if (!input_var.getAllcov() && model != 0
+ && input_var.getInteraction() == 0)
+ {
start_pos = rgd.X.ncol - 1;
- else if (!input_var.getAllcov() && model != 0
- && input_var.getInteraction() != 0)
+ } else if (!input_var.getAllcov() && model != 0
+ && input_var.getInteraction() != 0)
+ {
start_pos = rgd.X.ncol - 2;
- else
+ } else
+ {
start_pos = 0;
+ }
+ if (input_var.getInteraction() != 0
+ && !input_var.getAllcov()
+ && input_var.getNgpreds() != 2)
+ {
+ start_pos++;
+ }
if (model == 0)
{
end_pos = rgd.X.ncol;
- }
- else
+ } else
{
end_pos = rgd.X.ncol - 1;
}
if (input_var.getInteraction() != 0)
+ {
end_pos++;
+ }
for (int pos = start_pos; pos < end_pos; pos++)
{
*beta_sebeta[model] << input_var.getSep() << "nan"
- << input_var.getSep() << "nan";
+ << input_var.getSep() << "nan";
}
- //Han Chen
+
+ if (input_var.getNgpreds() == 2)
+ {
+ //Han Chen
#if !COXPH
- if (!input_var.getAllcov()
- && input_var.getInteraction() != 0)
- {
- if (model == 0)
+ if (!input_var.getAllcov()
+ && input_var.getInteraction() != 0)
{
- *covvalue[model] << "nan"
- << input_var.getSep() << "nan";
+ if (model == 0)
+ {
+ *covvalue[model] << "nan" << input_var.getSep()
+ << "nan";
+ } else
+ {
+ *covvalue[model] << "nan";
+ }
}
- else
+#endif
+ //Oct 26, 2009
+ *chi2[model] << "nan";
+ } else
+ { //ngpreds=1
+ if (input_var.getInverseFilename() == NULL)
{
- *covvalue[model] << "nan";
+ // Han Chen
+#if !COXPH
+ if (!input_var.getAllcov()
+ && input_var.getInteraction() != 0)
+ {
+ *covvalue[model] << "nan";
+ }
+#endif
+ //Oct 26, 2009
+ *chi2[model] << "nan";
}
}
+
+ }
+ //end of model cycle
+ if (input_var.getNgpreds() == 2)
+ {
+ //Han Chen
+ *outfile[0] << beta_sebeta[0]->str() << input_var.getSep();
+#if !COXPH
+ if (!input_var.getAllcov()
+ && input_var.getInteraction() != 0)
+ {
+ *outfile[0] << covvalue[0]->str() << input_var.getSep();
+ }
#endif
- //Oct 26, 2009
- *chi2[model] << "nan";
- }
- } //end of model cycle
+ *outfile[0] << chi2[0]->str() << "\n";
- //Han Chen
- *outfile[0] << beta_sebeta[0]->str() << input_var.getSep();
+ *outfile[1] << beta_sebeta[1]->str() << input_var.getSep();
#if !COXPH
- if (!input_var.getAllcov() && input_var.getInteraction() != 0)
- {
- *outfile[0] << covvalue[0]->str() << input_var.getSep();
- }
+ if (!input_var.getAllcov()
+ && input_var.getInteraction() != 0)
+ {
+ *outfile[1] << covvalue[1]->str() << input_var.getSep();
+ }
#endif
- *outfile[0] << chi2[0]->str() << "\n";
+ *outfile[1] << chi2[1]->str() << "\n";
- *outfile[1] << beta_sebeta[1]->str() << input_var.getSep();
+ *outfile[2] << beta_sebeta[2]->str() << input_var.getSep();
#if !COXPH
- if (!input_var.getAllcov() && input_var.getInteraction() != 0)
- {
- *outfile[1] << covvalue[1]->str() << input_var.getSep();
- }
+ if (!input_var.getAllcov()
+ && input_var.getInteraction() != 0)
+ {
+ *outfile[2] << covvalue[2]->str() << input_var.getSep();
+ }
#endif
- *outfile[1] << chi2[1]->str() << "\n";
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/genabel -r 1123
More information about the Genabel-commits
mailing list