annotate rDiff/src/variance/estimate_variance_nonparametric.m @ 2:233c30f91d66

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