From 40e338ab5d1754f36b6a12b6f29eee74792e3b3e Mon Sep 17 00:00:00 2001 From: Peter Carbonetto Date: Thu, 25 May 2017 22:20:02 -0500 Subject: A couple small adjustments to README. --- README.md | 8 ++-- src/varcov.cpp | 143 +++++++++++---------------------------------------------- src/varcov.h | 15 +++--- 3 files changed, 36 insertions(+), 130 deletions(-) diff --git a/README.md b/README.md index 334d3d9..12081d4 100644 --- a/README.md +++ b/README.md @@ -118,8 +118,7 @@ In both cases, we recommend downloading the ### Using precompiled binaries 1. Go to the [latest stable release](latest_release) and download the -file appropriate for your platform: `gemma.linux.gz` or -`gemma.macosx.gz`. +file appropriate for your platform: gemma.linux.gz or gemma.macosx.gz. 2. Run `gunzip gemma.linux.gz` or `gunzip gemma.linux.gz` to decompress the file. @@ -133,8 +132,9 @@ example, `gemma.linux` was built using `gcc 4.8.5`, so you should have `gcc 4.8.x`. If the libraries are installed somewhere non-standard, you can tell where GEMMA can find the libraries by setting the `LD_LIBRARY_PATH` environment variable. If you have the wrong C++ -compiler version, then the program will likely complain about dynamic -linking errors. +compiler version, or the libraries are in a place where GEMMA cannot +find them, then the program will complain about dynamic linking +errors. ### Building the binaries from source diff --git a/src/varcov.cpp b/src/varcov.cpp index fdc6f10..66cf3c4 100644 --- a/src/varcov.cpp +++ b/src/varcov.cpp @@ -1,6 +1,6 @@ /* Genome-wide Efficient Mixed Model Association (GEMMA) - Copyright (C) 2011 Xiang Zhou + Copyright (C) 2011-2017 Xiang Zhou This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -51,12 +51,8 @@ #include "mathfunc.h" #endif - using namespace std; - - - void VARCOV::CopyFromParam (PARAM &cPar) { d_pace=cPar.d_pace; @@ -79,17 +75,14 @@ void VARCOV::CopyFromParam (PARAM &cPar) return; } - void VARCOV::CopyToParam (PARAM &cPar) { cPar.time_opt=time_opt; return; } - - -//chr rs ps n_idv allele1 allele0 af var window_size r2 (r2_11,n_11,r2_12,n_12...r2_1m,n_1m) -void VARCOV::WriteCov (const int flag, const vector &snpInfo_sub, const vector > &Cov_mat) +void VARCOV::WriteCov (const int flag, const vector &snpInfo_sub, + const vector > &Cov_mat) { string file_cov; file_cov=path_out+"/"+file_out; @@ -134,11 +127,6 @@ void VARCOV::WriteCov (const int flag, const vector &snpInfo_sub, const return; } - - - -// sort SNPs first based on chromosomes then based on bp (or cm, if bp is not available) -//if chr1=chr2 and bp1=bp2, then return with the same order bool CompareSNPinfo (const SNPINFO &snpInfo1, const SNPINFO &snpInfo2) { int c_chr=snpInfo1.chr.compare(snpInfo2.chr); @@ -160,12 +148,10 @@ bool CompareSNPinfo (const SNPINFO &snpInfo1, const SNPINFO &snpInfo2) } -// do not sort SNPs (because gzip files do not support random access) -// then calculate n_nb, the number of neighbours, for each snp +// Do not sort SNPs (because gzip files do not support random access) +// then calculate n_nb, the number of neighbours, for each snp. void VARCOV::CalcNB (vector &snpInfo_sort) { - // stable_sort(snpInfo_sort.begin(), snpInfo_sort.end(), CompareSNPinfo); - size_t t2=0, n_nb=0; for (size_t t=0; t &snpInfo_sort) return; } - - -//vector double is centered to have mean 0 +// Vector double is centered to have mean 0. void Calc_Cor(vector > &X_mat, vector &cov_vec) { cov_vec.clear(); @@ -215,94 +199,22 @@ void Calc_Cor(vector > &X_mat, vector &cov_vec) return; } -/* -//somehow this can produce nan for some snps; perhaps due to missing values? -//vector int is not centered, and have 0/1/2 values only -//missing value is -9; to calculate covariance, these values are replaced by -void Calc_Cor(const vector > &X_mat, vector &cov_vec) -{ - cov_vec.clear(); - - int d1, d2, m1, m2, n1, n2, n12; - double m1d, m2d, m12d, v1d, v2d, v; - - vector x_vec=X_mat[0]; - - //calculate m2 - m2=0; n2=0; - for (size_t j=0; j snpInfo_sub; CalcNB(snpInfo); @@ -327,9 +239,9 @@ void VARCOV::AnalyzeBimbam () int n_nb=0; for (size_t t=0; t=2) {break;} if (X_mat.size()==0) { n_nb=snpInfo[t].n_nb+1; @@ -340,7 +252,7 @@ void VARCOV::AnalyzeBimbam () for (int i=0; i snpInfo_sub; CalcNB(snpInfo); @@ -421,9 +330,9 @@ void VARCOV::AnalyzePlink () int n_nb=0; for (size_t t=0; t=2) {break;} if (X_mat.size()==0) { n_nb=snpInfo[t].n_nb+1; @@ -434,7 +343,7 @@ void VARCOV::AnalyzePlink () for (int i=0; i &snpInfo_sort); - void WriteCov (const int flag, const vector &snpInfo_sub, const vector > &Cov_mat); + void WriteCov (const int flag, const vector &snpInfo_sub, + const vector > &Cov_mat); void AnalyzeBimbam (); void AnalyzePlink (); }; -- cgit v1.2.3