annotate rDiff/src/tests/rDiff_parametric.m @ 1:08d3a6143873

Deleted selected files
author vipints
date Tue, 08 Oct 2013 06:54:25 -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, RET_STRUCT]= rDiff_parametric(CFG,gene,Counts_rDiff_parametric,Gene_expression,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 % Calculates the p-Values of a negative binomial test on each
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4 % alternative regions and combines the p-values using Bonferroni's correction
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7 %Initialize gene.name
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8 NR_OF_TRANS=size(gene.transcripts,2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9 if NR_OF_TRANS<=1
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10 RET_STRUCT='NR_OF_TRANS too small';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11 P_VALUE=1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12 return
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
14
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
15
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
16 %get the samples that are expressed (have more than 10 reads)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17 TEMP_SAMPLE1=and(CFG.SAMPLES==1,Gene_expression>=10);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18 TEMP_SAMPLE2=and(CFG.SAMPLES==2,Gene_expression>=10);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19 SAMPLE1=find(TEMP_SAMPLE1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20 SAMPLE2=find(TEMP_SAMPLE2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22 %Check wether Counts_rDiff_parametric is nonempty
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23 for j=1:length(TEMP_SAMPLE1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24 TEMP_SAMPLE1(j)=and(not(isempty(Counts_rDiff_parametric{j})),TEMP_SAMPLE1(j));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
26 for j=1:length(TEMP_SAMPLE2)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
27 TEMP_SAMPLE2(j)=and(not(isempty(Counts_rDiff_parametric{j})),TEMP_SAMPLE2(j));
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 SAMPLE1=find(TEMP_SAMPLE1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
31 SAMPLE2=find(TEMP_SAMPLE2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
32
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
33
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
34 SAMPLE_LENGTH1=length(SAMPLE1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
35 SAMPLE_LENGTH2=length(SAMPLE2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
36
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
37 if min(SAMPLE_LENGTH1,SAMPLE_LENGTH2)==0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
38 RET_STRUCT='SAMPLE_LENGTH too small';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
39 P_VALUE=1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
40 return
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
41 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
42
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
43 % Get the region counts
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
44 region_counts_1=zeros(SAMPLE_LENGTH1,length(Counts_rDiff_parametric{1,1}));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
45 for j=1:SAMPLE_LENGTH1
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
46 region_counts_1(j,:)=Counts_rDiff_parametric{1,SAMPLE1(j)};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
47 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
48 region_counts_2=zeros(SAMPLE_LENGTH2,length(Counts_rDiff_parametric{1,1}));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
49 for j=1:SAMPLE_LENGTH2
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
50 region_counts_2(j,:)=Counts_rDiff_parametric{1,SAMPLE2(j)};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
51 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
52
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
53 % Get the gene expression
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
54 gene_expression_1=Gene_expression(SAMPLE1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
55 gene_expression_2=Gene_expression(SAMPLE2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
56
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
57 % compute the expected mean and the variance under the null
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
58 % hypothesis
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
59 [EXPECTED_MEAN,EXPECTED_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
60
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
61 %compute the p-values
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
62 OBSERVED_COUNTS=round([mean(region_counts_1,1);mean(region_counts_2,1)]);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
63
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
64 P_LIST=ones(1,size(EXPECTED_MEAN,2));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
65 %Iterate over the regions
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
66 SKIPPED_TESTS=0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
67 for i=1:length(P_LIST)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
68 if sum(OBSERVED_COUNTS(:,i))==0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
69 SKIPPED_TESTS=SKIPPED_TESTS+1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
70 continue
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
71 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
72
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
73 [P_VALUE,FL]=comp_nbin_p_value_mean_variance(EXPECTED_MEAN(1,i),EXPECTED_MEAN(2,i),EXPECTED_VARIANCE(1,i),EXPECTED_VARIANCE(2,i),OBSERVED_COUNTS(1,i),OBSERVED_COUNTS(2,i));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
74 P_LIST(i)=P_VALUE;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
75 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
76 if length(P_LIST)-SKIPPED_TESTS<=0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
77 P_VALUE=1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
78 else
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
79 P_VALUE=min(P_LIST)*(length(P_LIST)-SKIPPED_TESTS);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
80 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
81 RET_STRUCT={};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
82 return