comparison rDiff/src/variance/estimate_variance_nonparametric.m @ 0:0f80a5141704

version 0.3 uploaded
author vipints
date Thu, 14 Feb 2013 23:38:36 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0f80a5141704
1 function [VARIANCE1, VARIANCE2]=estimate_variance_nonparametric(CFG,genes)
2
3 fprintf('Estimating variance function for rDiff.nonparametric\n')
4
5 VARIANCE1=[];
6 VARIANCE2=[];
7
8 %Getthe gene expression
9 fprintf('Loading gene expression\n')
10
11 if isempty(CFG.Counts_gene_expression)
12 EXPR_TAB_FILENAME=[CFG.out_base 'Gene_expression.tab'];
13 else
14 EXPR_TAB_FILENAME=CFG.Counts_gene_expression;
15 end
16 try
17 Gene_expression=importdata(EXPR_TAB_FILENAME,'\t',1);
18 catch
19 error(['Could not open: ' EXPR_TAB_FILENAME])
20 end
21 %C=importdata('../out/release_test/Gene_expression.tab','\t',1);
22
23
24 %Get the counts
25 fprintf('Loading alternative region counts\n')
26 if isempty(CFG.Counts_rDiff_nonparametric)
27 IN_FILENAME=[CFG.out_base 'Nonparametric_region_counts.mat'];
28 load(IN_FILENAME,'Counts_rDiff_nonparametric')
29 else
30 IN_FILENAME=[CFG.out_base CFG.Counts_rDiff_nonparametric];
31 load(IN_FILENAMEc,'Counts_rDiff_nonparametric')
32 end
33
34
35
36 %Iterate over the functions to be generated
37 %compute means and variances
38
39 if CFG.compute_variance_function_1
40 fprintf('estimating variance function for sample 1\n')
41 %Get the samples to use for the for estimation the variance function
42 if CFG.merge_sample1
43 SAMPLE_IX=find(CFG.SAMPLES);
44 else
45 SAMPLE_IX=find(CFG.SAMPLES==1);
46 end
47 VARIANCE1=estimate_variance_helper(CFG,SAMPLE_IX,Counts_rDiff_nonparametric,Gene_expression.data);
48 if not(isempty(CFG.save_variance_function_1))
49 VARIANCE_FUNTION_OUTPATH=[CFG.out_base CFG.save_variance_function_1];
50 save(VARIANCE_FUNTION_OUTPATH,'VARIANCE1');
51 else
52 %Use previously estimated variance function
53 if not(isempty(CFG.variance_function_1))
54 try
55 VARIANCE_FUNTION_INPATH=[CFG.out_base CFG.variance_function_1];
56 VARIANCE1=load(VARIANCE_FUNTION_INPATH);
57 catch
58 error(['Could not load variance function for sample 1 from: ' VARIANCE_FUNTION_INPATH])
59 end
60 end
61 end
62 end
63
64 if CFG.compute_variance_function_2
65 fprintf('estimating variance function for sample 2\n')
66 %Get the samples to use for the for estimation the variance function
67 if CFG.merge_sample2
68 SAMPLE_IX=find(CFG.SAMPLES)
69 else
70 SAMPLE_IX=find(CFG.SAMPLES==2);
71 end
72 VARIANCE2=estimate_variance_helper(CFG,SAMPLE_IX,Counts_rDiff_nonparametric,Gene_expression.data);
73 if not(isempty(CFG.save_variance_function_2))
74 VARIANCE_FUNTION_OUTPATH=[CFG.out_base CFG.save_variance_function_2];
75 save(VARIANCE_FUNTION_OUTPATH,'VARIANCE2');
76 else
77 %Use previously estimated variance function
78 if not(isempty(CFG.variance_function_2))
79 try
80 VARIANCE_FUNTION_INPATH=[CFG.out_base CFG.variance_function_2];
81 VARIANCE2=load(VARIANCE_FUNTION_INPATH);
82 catch
83 error(['Could not load variance function for sample 2 from: ' VARIANCE_FUNTION_INPATH])
84 end
85 end
86 end
87 end
88
89
90