[Genabel-commits] r1400 - in pkg/GenABEL/src: GAlib ITERlib
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Nov 19 17:01:41 CET 2013
Author: maksim
Date: 2013-11-19 17:01:40 +0100 (Tue, 19 Nov 2013)
New Revision: 1400
Modified:
pkg/GenABEL/src/GAlib/dometa.cpp
pkg/GenABEL/src/GAlib/export_plink.cpp
pkg/GenABEL/src/GAlib/interactions_rare_recesive_alleles.cpp
pkg/GenABEL/src/GAlib/merge.snp.data.cpp
pkg/GenABEL/src/GAlib/reg1.h
pkg/GenABEL/src/ITERlib/iterator_functions.cpp
Log:
Fixed warnings reported by compiler. Mostly: deleted variables which were declared by not used and fixed comparisons between int and unsigned int
Modified: pkg/GenABEL/src/GAlib/dometa.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/dometa.cpp 2013-11-19 15:22:56 UTC (rev 1399)
+++ pkg/GenABEL/src/GAlib/dometa.cpp 2013-11-19 16:01:40 UTC (rev 1400)
@@ -48,9 +48,10 @@
unsigned num_el = *num;
-double se_set1, se_set2, wt2_set1, wt2_set2, invsumwt2;
+double wt2_set1, wt2_set2, invsumwt2;
+
double *lambda_set1, *lambda_set2;
if(lambda_set1_ == NULL)
@@ -76,8 +77,11 @@
for(unsigned i=0 ; i<num_el ; i++)
{
- se_set1 = sqrt(sebeta_set1[i]*sebeta_set1[i]*lambda_set1[i]);
- se_set2 = sqrt(sebeta_set2[i]*sebeta_set2[i]*lambda_set2[i]);
+ //static double se_set1;
+ //static double se_set2;
+
+ //se_set1 = sqrt(sebeta_set1[i]*sebeta_set1[i]*lambda_set1[i]);
+ //se_set2 = sqrt(sebeta_set2[i]*sebeta_set2[i]*lambda_set2[i]);
wt2_set1 = 1./(sebeta_set1[i]*sebeta_set1[i]);
wt2_set2 = 1./(sebeta_set2[i]*sebeta_set2[i]);
Modified: pkg/GenABEL/src/GAlib/export_plink.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/export_plink.cpp 2013-11-19 15:22:56 UTC (rev 1399)
+++ pkg/GenABEL/src/GAlib/export_plink.cpp 2013-11-19 16:01:40 UTC (rev 1400)
@@ -23,10 +23,15 @@
{
int from = INTEGER(From)[0];
int to = INTEGER(To)[0];
- std::vector<unsigned short int> sex;
+
+
+ if(from <1 || from > to) {error("The function SEXP export_plink(SEXP Ids, SEXP Snpdata, SEXP Nsnps, SEXP NidsTotal,... reports: the variable FROM should be >=1 and less then the variable TO.");} //Maksim
+
+
+ std::vector<unsigned short int> sex;
sex.clear();
unsigned short int sx;
- for(unsigned int i=(from - 1); i<to; i++) {
+ for(int i=(from - 1); i<to; i++) {
sx = INTEGER(Male)[i];
if (sx==0) sx=2;
//Rprintf("%d %d\n",i,sx);
@@ -62,7 +67,7 @@
//char gtMatrix[nids][nsnps];
char **gtMatrix = new (std::nothrow) char*[nids];
- for (unsigned int i=0; i<nids; i++) {
+ for (int i=0; i<nids; i++) {
gtMatrix[i] = new (std::nothrow) char[nsnps];
}
Modified: pkg/GenABEL/src/GAlib/interactions_rare_recesive_alleles.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/interactions_rare_recesive_alleles.cpp 2013-11-19 15:22:56 UTC (rev 1399)
+++ pkg/GenABEL/src/GAlib/interactions_rare_recesive_alleles.cpp 2013-11-19 16:01:40 UTC (rev 1400)
@@ -102,7 +102,7 @@
//__________________________________________________________________________________________
int snp_snp_interaction_results::push_chi2(float chi2, unsigned central_snp_position, unsigned window_snp_position)
{
-static int window_current;
+static unsigned int window_current;
window_current = snp_number - central_snp_position;
if(window_current > window) window_current=window;
@@ -141,7 +141,7 @@
//__________________________________________________________________________________________
unsigned snp_snp_interaction_results::get_current_window(unsigned central_snp_position)
{
-static int window_current;
+static unsigned int window_current;
window_current = snp_number - central_snp_position - 1;
if(window_current > window) window_current=window;
@@ -161,7 +161,7 @@
//find first ellement which is not NA. If there is only NAs then return NA
//_____________________________________________
-for(int i = 0 ; i<number; i++)
+for(unsigned i = 0 ; i<number; i++)
{
if(ISNAN(array[i]))
{
@@ -178,7 +178,7 @@
//_____________________________________________
-for(int i = 1; i<number; i++)
+for(unsigned i = 1; i<number; i++)
{
if(ISNAN(array[i])) continue;
if(array[i] > max)
@@ -255,6 +255,8 @@
return chi2_test_yates(m);
}
+
+return -1;
}
@@ -309,7 +311,7 @@
}
}
-double independence_test_2x2(int *x1, int *x2, int* y, int N, unsigned snp1_position, unsigned snp2_position, INDEPENDENCE_TEST_NAME_ENUM test_name, int min_expected_cut_off)
+double independence_test_2x2(int *x1, int *x2, int* y, unsigned int N, unsigned snp1_position, unsigned snp2_position, INDEPENDENCE_TEST_NAME_ENUM test_name, int min_expected_cut_off)
{
static double matrix[2][2];
@@ -417,10 +419,10 @@
-int num_ids = INTEGER_VALUE(num_ids_);
-int num_snps = INTEGER_VALUE(num_snps_);
+unsigned num_ids = unsigned(INTEGER_VALUE(num_ids_));
+unsigned num_snps = unsigned(INTEGER_VALUE(num_snps_));
int *trait_binary = INTEGER(trait_binary_);
-int window = INTEGER_VALUE(window_);
+unsigned window = unsigned(INTEGER_VALUE(window_));
int min_expected_cut_off = INTEGER_VALUE(min_expected_cut_off_); // if observed value less then min_expected_cut_off then perform fisfer or yates
bool return_all_result = LOGICAL_VALUE(return_all_result_); //if true then returns vector with maximum chisq and for each snp and matrix with chi2s where each row corresponds to a snp and a column corresponds to a snp with which interaction is tested with
@@ -515,7 +517,7 @@
unsigned step=10000;
float chi2;
-int window_current=window;
+unsigned window_current=window;
//in this loop the tests between two snps within a window is done. In each iteration tests between a "central" snp and snp around (withn a window) are done.
for(unsigned snp_counter=0 ; snp_counter<num_snps-1 ; snp_counter++) //enumerate eache snp in genome
@@ -616,7 +618,8 @@
UNPROTECT(1);
-delete snp1, snp2;
+delete snp1;
+delete snp2;
return(results_R);
} //end of interaction_rare_recesive_allele_C_
Modified: pkg/GenABEL/src/GAlib/merge.snp.data.cpp
===================================================================
--- pkg/GenABEL/src/GAlib/merge.snp.data.cpp 2013-11-19 15:22:56 UTC (rev 1399)
+++ pkg/GenABEL/src/GAlib/merge.snp.data.cpp 2013-11-19 16:01:40 UTC (rev 1400)
@@ -188,7 +188,7 @@
*found_error_amount_snp = *snp_error_counter;
}
-if(*snp_error_counter >= *error_amount_)
+if(int(*snp_error_counter) >= *error_amount_)
{
Rprintf("ID:Error: Too many errors while merging sets (see error table). Change error_amount value to increase error-table size.\n");
*error_amount_=-1;
@@ -555,7 +555,7 @@
unsigned snp_error_counter=0; //this is counter for function recoding_snp_data_under_coding_and_strand
-for(int i=0 ; i<alleleID_amount_ ; i++)
+for(unsigned i=0 ; i<alleleID_amount_ ; i++)
{
coding_polymorphism_map[alleleID[i]] = alleleID_names[i];
}
@@ -566,7 +566,7 @@
//---------------------------------
std::map<char, char> alleleID_reverse;
-for(int i=0 ; i<*alleleID_amount ; i++)
+for(unsigned i=0 ; i<*alleleID_amount ; i++)
{
alleleID_reverse[alleleID[i]] = alleleID_reverse_array[i];
}
Modified: pkg/GenABEL/src/GAlib/reg1.h
===================================================================
--- pkg/GenABEL/src/GAlib/reg1.h 2013-11-19 15:22:56 UTC (rev 1399)
+++ pkg/GenABEL/src/GAlib/reg1.h 2013-11-19 16:01:40 UTC (rev 1400)
@@ -85,7 +85,7 @@
beta.put(log(prev/(1.-prev)),0,0);
mematrix<double> tX = transpose(rdata.X);
- double N;
+ //double N;
for (int iter=0;iter<maxiter;iter++)
{
@@ -108,7 +108,7 @@
mematrix<double> tmp = productMatrDiag(tX,W);
if (verbose) {Rprintf("tXW:\n");tmp.print();}
mematrix<double> tXWX = tmp*(rdata.X);
- N = tXWX.get(0,0);
+ //N = tXWX.get(0,0);
if (verbose) {Rprintf("tXWX:\n");tXWX.print();}
tXWX_i=invert(tXWX);
Modified: pkg/GenABEL/src/ITERlib/iterator_functions.cpp
===================================================================
--- pkg/GenABEL/src/ITERlib/iterator_functions.cpp 2013-11-19 15:22:56 UTC (rev 1399)
+++ pkg/GenABEL/src/ITERlib/iterator_functions.cpp 2013-11-19 16:01:40 UTC (rev 1400)
@@ -101,12 +101,12 @@
int nids = (*Nids);
int type = (*Type);
//int gt[nids];
- int i, j, cstr, igt, i1=1;
- int nbytes;
+ int i, j, cstr, igt=0;
+ //int nbytes;
int dgt;
double Ttotg, mx, bb;
double Tsg0, Tsg1, Tsg2;
- double u, v, u0, u1, u2, m0, m1, m2, v00, v02, v11, v12, v22, det;
+ double u, v, u0, u1, u2, m0, m1, m2, v00, v02, v11, v12, v22;//, det;
double * totg = new (std::nothrow) double [nstra];if (totg == NULL) {Rprintf("cannot allocate RAM");return;}
double * x2 = new (std::nothrow) double [nstra];if (x2 == NULL) {Rprintf("cannot allocate RAM");return;}
@@ -119,7 +119,7 @@
double * xg2 = new (std::nothrow) double [nstra];if (xg2 == NULL) {Rprintf("cannot allocate RAM");return;}
mx = -999.99;
- if ((nids % 4) == 0) nbytes = nids/4; else nbytes = ceil(1.*nids/4.);
+ //if ((nids % 4) == 0) nbytes = nids/4; else nbytes = ceil(1.*nids/4.);
// char chgt[nbytes];
/*
@@ -166,7 +166,7 @@
Tsg1 += sg1[j];
Tsg2 += sg2[j];
}
- chi2[igt+6*nsnps]=Ttotg;
+ chi2[igt+6*nsnps]=Ttotg; //What is it and why igt was never initilized? (Maksim)
if (Ttotg == 0) {
chi2[igt] = -999.99;
chi2[igt+nsnps] = -999.99;
@@ -215,7 +215,7 @@
chi2[igt+3*nsnps]=u/(Tsg1+4.*Tsg2-Ttotg*((Tsg1+2.*Tsg2)/Ttotg)*((Tsg1+2.*Tsg2)/Ttotg));
}
}
- det = v11*v22 - v12*v12;
+ // det = v11*v22 - v12*v12;
// double rho2 = v12*v12/(v11*v22);
// if (v00 <= 0. || v11<=0. || v22<=0. || rho2<1.e-16 || abs(det)<1.e-16) {
chi2[igt+nsnps] = -999.99;
More information about the Genabel-commits
mailing list