annotate rDiff/src/get_parametric_tests_caller.m @ 3:29a698dc5c7e default tip

Merge multiple heads.
author Dave Bouvier <dave@bx.psu.edu>
date Mon, 27 Jan 2014 14:15:36 -0500
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 []=get_parametric_tests_caller(PAR)
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 CFG = PAR.CFG;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5 genes = PAR.genes;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6 OUT_STR='';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8 % add paths
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9 addpath(CFG.paths);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10 %load local variables
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11 data_dir=CFG.data_dir;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12 OUT_STR=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
14 variance_function_parametric_1=PAR.variance_function_parametric_1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
15 variance_function_parametric_2=PAR.variance_function_parametric_2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
16
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17 Counts_rDiff_parametric=PAR.Counts_rDiff_parametric;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18 Gene_expression=PAR.Gene_expression;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20 %clear variabe PAR
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21 clear PAR;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23 NUMBER_OF_TESTS_PER_GENE=(CFG.perform_parametric+CFG.perform_poisson);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24 if NUMBER_OF_TESTS_PER_GENE==0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25 return
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
26 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
27 P_VALS=cell(size(genes,2),NUMBER_OF_TESTS_PER_GENE+12);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
28
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
29
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
30 %iterate over genes
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
31 for i=1:size(genes,2)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
32 %TEMP_COUNT contains the counts for the current gene
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
33 TEMP_COUNT=cell(1,3);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
34 gene = genes(i);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
35
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
36
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
37 OLD_OUT_STR=OUT_STR;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
38 OUT_STR=['Current gene: ' gene.name ' '];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
39 %print progress
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
40 if CFG.use_rproc
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
41 fprintf([OUT_STR '\n'])
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
42 else
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
43 % Erase old progress
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
44 fprintf(repmat('\b',1,length(OLD_OUT_STR)));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
45 fprintf([OUT_STR])
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
46 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
47
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
48 %set default return values
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
49 P_VALS{i,1}=gene.name;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
50
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
51 %check that the gene has exons defined
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
52 if isempty(gene.exons)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
53 P_VALS{i,4}='Exons field empty in gene structure';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
54 continue;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
55 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
56
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
57 %check that the gene is longer than the Reads. Otherwise the
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
58 %definition of regions does not makes sense
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
59 if gene.stop-gene.start<CFG.sequenced_length+3
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
60 P_VALS{i,4}='Gene to short';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
61 continue;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
62 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
63 %perform
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
64 COUNTER=2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
65 if CFG.perform_parametric
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
66 [PV, INFO]= rDiff_parametric(CFG,gene,Counts_rDiff_parametric(i,:),Gene_expression(i,:),variance_function_parametric_1, variance_function_parametric_2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
67 P_VALS{i,COUNTER}={PV, INFO};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
68 COUNTER=COUNTER+1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
69 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
70
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
71 if CFG.perform_poisson
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
72 [PV, INFO]= rDiff_poisson(CFG,gene,Counts_rDiff_parametric(i,:),Gene_expression(i,:));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
73 P_VALS{i,COUNTER}={PV, INFO};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
74 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
75
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
76 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
77
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
78 fprintf('\n')
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
79 %Save the p-values
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
80 OUT_FILENAME=[CFG.outfile_prefix '.mat'];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
81 save(OUT_FILENAME,'P_VALS')
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
82