annotate rDiff/src/tests/comp_nbin_p_value_mean_variance.m @ 2:233c30f91d66

updated python based GFF parsing module which will handle GTF/GFF/GFF3 file types
author vipints <vipin@cbio.mskcc.org>
date Tue, 08 Oct 2013 07:15:44 -0400
parents 0f80a5141704
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
1 function [P_VALUE,FLAG_ERR]=comp_nbin_p_value_mean_variance(MEAN1,MEAN2,SIGMA1,SIGMA2,COUNTS1,COUNTS2)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
2 %This function computes the p_value for a negative binomial
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
3 %hypothesis test given the mean and variance of two nbin
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4 %distributions and counts from the respective distributions
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6 FLAG_ERR=0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7 r1=(MEAN1^2)/(SIGMA1-MEAN1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8 p1=1-(MEAN1/(SIGMA1));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9 r2=(MEAN2^2)/(SIGMA2-MEAN2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10 p2=1-(MEAN2/(SIGMA2));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12 P_OBS=calcl_nbin_pdf(COUNTS1,r1,1-p1)*calcl_nbin_pdf(COUNTS2,r2,1-p2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
14
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
15 P_A=calcl_nbin_pdf(0:(COUNTS1+COUNTS2),r1,1-p1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
16 P_B=calcl_nbin_pdf((COUNTS1+COUNTS2):(-1):0,r2,1-p2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17 P_COMB=sort(P_A.*P_B);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19 if sum(P_COMB)>0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20 POS= find(P_COMB<=P_OBS,1,'last');
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21 if isempty(POS)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22 P_VALUE=min(P_COMB);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23 else
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24 P_VALUE=sum(P_COMB(1:POS))/sum(P_COMB);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
26 else
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
27 P_VALUE=1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
28 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
29
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
30
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
31