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()); 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) { std::cerr << "error: Interaction parameter is out of range " << "(interaction=" << input_var.getInteraction() << ") \n"; exit(1); } return interaction_cox; }
void create_header2(std::vector<std::ofstream*>& outfile, cmdvars& input_var, 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"; 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]; } if (input_var.getInverseFilename() == NULL) { //Han Chen #if !COXPH if (input_var.getInteraction() != 0 && !input_var.getAllcov()) { *outfile[0] << input_var.getSep() << "cov_SNP_int_SNP_" << phd.model_terms[interaction_cox]; } #endif *outfile[0] << input_var.getSep() << "loglik"; //"chi2_SNP"; } //Oct 26, 2009 *outfile[0] << "\n"; }
void loadInvSigma(cmdvars& input_var, phedata& phd, masked_matrix& invvarmatrix) { std::cout << "you are running mmscore...\n"; InvSigma inv(input_var.getInverseFilename(), &phd); // invvarmatrix = inv.get_matrix(); //double par = 1.; //var(phd.Y)*phd.nids/(phd.nids-phd.ncov-1); invvarmatrix.set_matrix(inv.get_matrix()); // = invvarmatrix * par; std::cout << " loaded InvSigma ..." << std::flush; }
int get_start_position(const cmdvars& input_var, int model, int number_of_rows_or_columns) { int start_pos; if (!input_var.getAllcov() && model == 0 && input_var.getInteraction() == 0) { if (input_var.getNgpreds() == 2) { start_pos = number_of_rows_or_columns - 2; } else { start_pos = number_of_rows_or_columns - 1; } } else if (!input_var.getAllcov() && model == 0 && input_var.getInteraction() != 0) { if (input_var.getNgpreds() == 2) { start_pos = number_of_rows_or_columns - 4; } else { start_pos = number_of_rows_or_columns - 2; } } else if (!input_var.getAllcov() && model != 0 && input_var.getInteraction() == 0) { start_pos = number_of_rows_or_columns - 1; } else if (!input_var.getAllcov() && model != 0 && input_var.getInteraction() != 0) { start_pos = number_of_rows_or_columns - 2; } else { start_pos = 0; } return start_pos; }
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]; } }
void create_header(std::vector<std::ofstream*>& outfile, cmdvars& input_var, phedata& phd, int& interaction_cox) { create_start_of_header(outfile, input_var, phd); if (input_var.getNgpreds() == 1) // dose data: only additive model { *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]; } if (input_var.getInverseFilename() == NULL) { //Han Chen #if !COXPH if (input_var.getInteraction() != 0 && !input_var.getAllcov()) { *outfile[0] << input_var.getSep() << "cov_SNP_int_SNP_" << phd.model_terms[interaction_cox]; } #endif } *outfile[0] << input_var.getSep() << "chi2_SNP"; *outfile[0] << "\n"; } // ngpreds == 1 else if (input_var.getNgpreds() == 2) // prob data: all models { *outfile[0] << input_var.getSep() << "beta_SNP_A1A2" << input_var.getSep() << "sebeta_SNP_A1A2" << input_var.getSep() << "beta_SNP_A1A1" << input_var.getSep() << "sebeta_SNP_A1A1"; *outfile[1] << input_var.getSep() << "beta_SNP_addA1" << input_var.getSep() << "sebeta_SNP_addA1"; *outfile[2] << input_var.getSep() << "beta_SNP_domA1" << input_var.getSep() << "sebeta_SNP_domA1"; *outfile[3] << input_var.getSep() << "beta_SNP_recA1" << input_var.getSep() << "sebeta_SNP_recA1"; *outfile[4] << input_var.getSep() << "beta_SNP_odomA1" << input_var.getSep() << "sebeta_SNP_odomA1"; 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]; #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]; } #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]; //Han Chen #if !COXPH if (input_var.getInverseFilename() == NULL && !input_var.getAllcov()) { *outfile[file] << input_var.getSep() << "cov_SNP_int_SNP_" << phd.model_terms[interaction_cox]; } #endif //Oct 26, 2009 } } *outfile[0] << input_var.getSep() << "chi2_SNP_2df\n"; // "loglik\n"; *outfile[1] << input_var.getSep() << "chi2_SNP_A1\n"; // "loglik\n"; *outfile[2] << input_var.getSep() << "chi2_SNP_domA1\n";// "loglik\n"; *outfile[3] << input_var.getSep() << "chi2_SNP_recA1\n";// "loglik\n"; *outfile[4] << input_var.getSep() << "chi2_SNP_odomA1\n"; // "loglik\n"; } // End: ngpreds == 2 else { cerr << "Error: create_header(): ngpreds != 1 or 2.\n"; } }
void create_start_of_header(std::vector<std::ofstream*>& outfile, cmdvars& input_var, phedata& phd) { 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"; if (input_var.getChrom() != "-1") (*outfile[i]) << input_var.getSep() << "chrom"; if (input_var.getMapfilename() != NULL) (*outfile[i]) << input_var.getSep() << "position"; } if (input_var.getAllcov()) //All covariates in output { 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]; } }
void create_header_1(std::vector<std::ofstream*>& outfile, cmdvars& input_var, phedata& phd, int& interaction_cox) { 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"; *outfile[1] << input_var.getSep() << "beta_SNP_addA1" << input_var.getSep() << "sebeta_SNP_addA1"; *outfile[2] << input_var.getSep() << "beta_SNP_domA1" << input_var.getSep() << "sebeta_SNP_domA1"; *outfile[3] << input_var.getSep() << "beta_SNP_recA1" << input_var.getSep() << "sebeta_SNP_recA1"; *outfile[4] << input_var.getSep() << "beta_SNP_odom" << input_var.getSep() << "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]; #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]; } #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]; //Han Chen #if !COXPH if (input_var.getInverseFilename() == NULL && !input_var.getAllcov()) { *outfile[file] << input_var.getSep() << "cov_SNP_int_SNP_" << phd.model_terms[interaction_cox]; } #endif //Oct 26, 2009 } } *outfile[0] << input_var.getSep() << "loglik\n"; //"chi2_SNP_2df\n"; *outfile[1] << input_var.getSep() << "loglik\n"; //"chi2_SNP_A1\n"; *outfile[2] << input_var.getSep() << "loglik\n"; //"chi2_SNP_domA1\n"; *outfile[3] << input_var.getSep() << "loglik\n"; //"chi2_SNP_recA1\n"; *outfile[4] << input_var.getSep() << "loglik\n"; //"chi2_SNP_odom\n"; }