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