annotate rDiff/src/tests/get_mean_variance_seg.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 [COMB_MEAN,COMB_VARIANCE]=get_mean_variance_seg(gene_expression_1,gene_expression_2,region_counts_1,region_counts_2,variance_function_parametric_1, variance_function_parametric_2)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
2
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
3
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4 COMB_READS_PER_EXON=[region_counts_1;region_counts_2];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5 GENE_EXPRESSION=[gene_expression_1';gene_expression_2'];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6 IX_SAMPLE1=1:length(gene_expression_1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7 IX_SAMPLE2=(1+length(gene_expression_1)):(length(gene_expression_1)+length(gene_expression_2));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9 COMB_VARIANCE=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10 COMB_MEAN=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11 for i=1:size(region_counts_1,2)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12 INTEN1=region_counts_1(:,i);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13 INTEN2=region_counts_2(:,i);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
14 INTENSITY=[INTEN1;INTEN2];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
15
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
16 SR_VECT=GENE_EXPRESSION;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18 %Are there any counts at all in the region?
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19 if sum(INTENSITY)>0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20 %Compute the means under the null hypothesis
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21 Q=(INTENSITY./SR_VECT)/sum(SR_VECT>0);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23 if sum(isnan(SR_VECT))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24 MEAN1=0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25 MEAN2=0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
26 else
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
27 MEAN1=mean(sum(Q)*SR_VECT(IX_SAMPLE1));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
28 MEAN2=mean(sum(Q)*SR_VECT(IX_SAMPLE2));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
29 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
30
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
31 COMB_MEAN=[COMB_MEAN,[MEAN1;MEAN2]];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
32 else
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
33 COMB_MEAN=[COMB_MEAN,[0;0]];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
34 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
35
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
36 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
37
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
38 VARIANCE1= predict_variance(COMB_MEAN(1,:)',variance_function_parametric_1)';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
39 VARIANCE2= predict_variance(COMB_MEAN(2,:)',variance_function_parametric_2)';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
40
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
41 COMB_VARIANCE=[VARIANCE1;VARIANCE2];