annotate rDiff/src/rdiff.m @ 0:0f80a5141704

version 0.3 uploaded
author vipints
date Thu, 14 Feb 2013 23:38:36 -0500
parents
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 []=rdiff(ARGS)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
2 % rdiff()
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
3 %
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5 if isempty(ARGS)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6 usage() ;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7 exit(-1) ;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9 %ARGS=[ARGS ':.:.'] ;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11 %%% Add paths %%%
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12 fprintf('Set the paths\n')
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13 CFG.paths = set_rdiff_paths();
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 %%% Read configuration file %%%
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17 fprintf('Load configuration\n')
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18 CFG = configure_rdiff(CFG);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19 CFG = process_command_line_args(CFG,ARGS);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20 CFG = process_configure_rdiff(CFG);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22 %%% Get read counts %%%
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24 %load the gene structure
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25 load(CFG.genes_path , 'genes');
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
26
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
27 % mask the regions which overlap with other genes
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
28 fprintf('Compute regions common to multiple genes\n')
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
29 [genes]=detect_overlapping_regions(genes);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
30
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
31 %Precompute testing regions
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
32 fprintf('Compute alternative regions\n')
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
33 [genes]=compute_testing_region(CFG,genes);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
34
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
35 %Get the gene expression
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
36 if CFG.estimate_gene_expression
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
37 fprintf('Measure gene expression\n')
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
38 get_read_counts(CFG,genes);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
39 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
40
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
41 %%% Estimate variance function %%%
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
42 if CFG.perform_nonparametric
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
43 variance_function_nonparametric_1=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
44 variance_function_nonparametric_2=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
45 [variance_function_nonparametric_1, variance_function_nonparametric_2]=estimate_variance_nonparametric(CFG,genes);
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 if CFG.perform_poisson
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
49 variance_function_parametric_1=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
50 variance_function_parametric_2=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
51 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
52 if CFG.perform_parametric
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
53 variance_function_parametric_1=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
54 variance_function_parametric_2=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
55 [variance_function_parametric_1, variance_function_parametric_2]=estimate_variance_parametric(CFG,genes);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
56 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
57
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
58 %If only gene expression is needed, stop here
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
59 if CFG.only_gene_expression
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
60 return
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
61 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
62
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
63
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
64 %%% Perform tests & Write output %%%
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
65
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
66 %Run the prametric tests
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
67 if or(CFG.perform_parametric,CFG.perform_poisson)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
68 perform_parametric_tests(CFG,genes,variance_function_parametric_1, variance_function_parametric_2)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
69 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
70 %Run the nonparametric tests
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
71 if or(CFG.perform_nonparametric,CFG.perform_mmd)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
72 perform_nonparametric_tests(CFG,genes,variance_function_nonparametric_1, variance_function_nonparametric_2)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
73 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
74
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
75 return
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
76
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
77
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
78