src/hg/instinct/lib/hgStatsLib.c 1.12
1.12 2009/03/17 22:50:58 jsanborn
added signed fishers
Index: src/hg/instinct/lib/hgStatsLib.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/lib/hgStatsLib.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -b -B -U 4 -r1.11 -r1.12
--- src/hg/instinct/lib/hgStatsLib.c 3 Mar 2009 18:53:48 -0000 1.11
+++ src/hg/instinct/lib/hgStatsLib.c 17 Mar 2009 22:50:58 -0000 1.12
@@ -472,8 +472,43 @@
*prob = log(chdtrc(logSumCount*2,logSum))/log(10)*-1;
return 1;
}
+boolean fishersMetaSigned(struct slDouble *data, float *chi2, float *prob)
+/* Fisher's MetaAnalysis (Signed)
+ * return 0 if failed, return 1 if successfully executed */
+{
+if (data == NULL)
+ return 0;
+
+float logSum = 0;
+float sign = 0.0;
+int logSumCount = 0;
+struct slDouble *currVal = data;
+while(currVal)
+ {
+ sign = 1.0;
+ if (currVal->val < 0.0)
+ sign = -1.0;
+ float pVal = pow(10,-1*fabs(currVal->val));
+ if(pVal > 0 && pVal <= 1)
+ {
+ logSum += sign*log(pVal);
+ logSumCount++; // only count the ones we can actually use
+ }
+ currVal = currVal->next;
+ }
+sign = 1.0;
+if (logSum > 0.0)
+ sign = -1.0;
+logSum = 2.0*fabs(logSum);
+*chi2 = logSum; // probably won't need this ever, but keep it around for consistancy with t-test
+
+// signed fishers
+*prob = -1.0*sign*log(chdtrc(logSumCount*2,logSum))/log(10.0);
+return 1;
+}
+
boolean stoufferMeta(struct slDouble *data, float *norm, float *prob)
/* stouffer's MetaAnalysis
* return 0 if failed, return 1 if successfully executed */
{