Mercurial > repos > vipints > rdiff
comparison rDiff/src/variance/estimate_variance_parametric.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_parametric(CFG,genes) | |
2 | |
3 fprintf('Estimating variance function for rDiff.parametric\n') | |
4 | |
5 VARIANCE1=[]; | |
6 VARIANCE2=[]; | |
7 | |
8 %Get the gene expression | |
9 fprintf('Loading gene expression\n') | |
10 if isempty(CFG.Counts_gene_expression) | |
11 EXPR_TAB_FILENAME=[CFG.out_base 'Gene_expression.tab']; | |
12 else | |
13 EXPR_TAB_FILENAME=CFG.Counts_gene_expression; | |
14 end | |
15 | |
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_parametric) | |
27 IN_FILENAME=[CFG.out_base 'Alternative_region_counts.mat']; | |
28 load(IN_FILENAME,'Counts_rDiff_parametric') | |
29 else | |
30 IN_FILENAME=[CFG.out_base CFG.Counts_rDiff_parametric]; | |
31 load(IN_FILENAMEc,'Counts_rDiff_parametric') | |
32 end | |
33 | |
34 %Iterate over the functions to be generated | |
35 %compute means and variances | |
36 | |
37 if CFG.compute_variance_function_1 | |
38 fprintf('estimating variance function for sample 1\n') | |
39 %Get the samples to use for the for estimation the variance function | |
40 if CFG.merge_sample1 | |
41 SAMPLE_IX=find(CFG.SAMPLES); | |
42 else | |
43 SAMPLE_IX=find(CFG.SAMPLES==1); | |
44 end | |
45 VARIANCE1=estimate_variance_helper(CFG,SAMPLE_IX,Counts_rDiff_parametric,Gene_expression.data); | |
46 if not(isempty(CFG.save_variance_function_1)) | |
47 VARIANCE_FUNTION_OUTPATH=[CFG.out_base CFG.save_variance_function_1]; | |
48 save(VARIANCE_FUNTION_OUTPATH,'VARIANCE1'); | |
49 else | |
50 %Use previously estimated variance function | |
51 if not(isempty(CFG.variance_function_1)) | |
52 try | |
53 VARIANCE_FUNTION_INPATH=[CFG.out_base CFG.variance_function_1]; | |
54 VARIANCE1=load(VARIANCE_FUNTION_INPATH); | |
55 catch | |
56 error(['Could not load variance function for sample 1 from: ' VARIANCE_FUNTION_INPATH]) | |
57 end | |
58 end | |
59 end | |
60 end | |
61 | |
62 if CFG.compute_variance_function_2 | |
63 fprintf('estimating variance function for sample 2\n') | |
64 %Get the samples to use for the for estimation the variance function | |
65 if CFG.merge_sample2 | |
66 SAMPLE_IX=find(CFG.SAMPLES); | |
67 else | |
68 SAMPLE_IX=find(CFG.SAMPLES==2); | |
69 end | |
70 VARIANCE2=estimate_variance_helper(CFG,SAMPLE_IX,Counts_rDiff_parametric,Gene_expression.data); | |
71 if not(isempty(CFG.save_variance_function_2)) | |
72 VARIANCE_FUNTION_OUTPATH=[CFG.out_base CFG.save_variance_function_2]; | |
73 save(VARIANCE_FUNTION_OUTPATH,'VARIANCE2'); | |
74 else | |
75 %Use previously estimated variance function | |
76 if not(isempty(CFG.variance_function_2)) | |
77 try | |
78 VARIANCE_FUNTION_INPATH=[CFG.out_base CFG.variance_function_2]; | |
79 VARIANCE2=load(VARIANCE_FUNTION_INPATH); | |
80 catch | |
81 error(['Could not load variance function for sample 2 from: ' VARIANCE_FUNTION_INPATH]) | |
82 end | |
83 end | |
84 end | |
85 end | |
86 | |
87 | |
88 |