def execute_coverageStats_fromTable(self,analysis_id_I): '''Calculate coverage statistics''' # get the analysis_info analysis_rows = []; # get the data data_O = []; for cnt,analysis in analysis_rows: # get the sample_names experiment_id = analysis['experiment_id']; sn = analysis['sample_name']; # get chromosomes chromosomes = []; for chromosome in chromosomes: # get strands strands = [] for strand in strands: # get the indices/reads and other information start,stop = None,None; data_indices,data_reads = [],[]; # calculate the descriptive statistics data_TTest = {}; data_TTest = self.r_calc.calculate_oneSampleTTest(data_reads, alternative_I = "two.sided", mu_I = 0, paired_I="FALSE", var_equal_I = "TRUE", ci_level_I = 0.95, padjusted_method_I = "bonferroni"); # calculate the interquartile range min_O, max_O, median_O, iq_1_O, iq_3_O = None, None, None, None, None; min_O, max_O, median_O, iq_1_O, iq_3_O=calculate_interface.calculate_interquartiles(data_reads); # record data for data_O.append({ 'analysis_id':analysis_id, 'experiment_id':experiment_id, 'sample_name':sn, 'genome_chromosome':chromosome, 'genome_strand':strand, 'strand_start':start, 'strand_stop':stop, 'reads_min':min_O, 'reads_max':max_O, 'reads_lb':data_TTest['ci_lb'], 'reads_ub':data_TTest['ci_ub'], 'reads_iq1':iq_1_O, 'reads_iq3':iq_3_O, 'reads_median':median_O, 'reads_mean':data_TTest['mean'], 'reads_var':data_TTest['var'], 'reads_n':len(data_reads) }) self.add_dataStage01ResequencingCoverageStats(data_O);
def execute_amplificationStats_fromTable(self, #analysis_id_I, experiment_id_I, sample_names_I=[]): '''Calculate coverage statistics''' # get the data data_O = []; ## get the analysis_info #analysis_rows = []; ## query information from amplification table #for cnt,analysis in analysis_rows: # # get the sample_names # experiment_id = analysis['experiment_id']; # sn = analysis['sample_name']; # get the sample_names experiment_id = experiment_id_I; if sample_names_I: sample_names = sample_names_I; else: sample_names = []; sample_names = self.get_sampleNames_experimentID_dataStage01ResequencingAmplifications(experiment_id_I); for cnt,sn in enumerate(sample_names): # get chromosomes chromosomes = []; chromosomes = self.get_chromosomes_experimentIDAndSampleName_dataStage01ResequencingAmplifications(experiment_id_I,sn); for chromosome in chromosomes: # get strands strands = [] strands = self.get_strands_experimentIDAndSampleNameAndChromosome_dataStage01ResequencingAmplifications(experiment_id_I,sn,chromosome); # remove visualization regions strands = [s for s in strands if not 'mean' in s]; for strand in strands: # get the start and stop of the indices genomic_starts,genomic_stops = [],[] genomic_starts,genomic_stops = self.get_startAndStops_experimentIDAndSampleNameAndChromosomeAndStrand_dataStage01ResequencingAmplifications(experiment_id_I,sn,chromosome,strand); # get the start and stop regions starts,stops = [],[] starts,stops = self.get_amplificationRegions_experimentIDAndSampleNameAndChromosomeAndStrand_dataStage01ResequencingAmplifications(experiment_id_I,sn,chromosome,strand); # get the indices/reads and other information for start_cnt,start in enumerate(starts): data_indices,data_reads = [],[]; data_indices,data_reads = self.get_genomeIndexAndReads_experimentIDAndSampleNameAndChromosomeAndStrandAndAmplificationRegions_dataStage01ResequencingAmplifications(experiment_id_I,sn,chromosome,strand,start,stops[start_cnt]); # calculate using scipy data_ave_O, data_var_O, data_lb_O, data_ub_O = calculate_interface.calculate_ave_var(data_reads,confidence_I = 0.95); # calculate the interquartile range min_O, max_O, median_O, iq_1_O, iq_3_O = None, None, None, None, None; min_O, max_O, median_O, iq_1_O, iq_3_O=calculate_interface.calculate_interquartiles(data_reads); # record data for data_O.append({ #'analysis_id':analysis_id, 'experiment_id':experiment_id_I, 'sample_name':sn, 'genome_chromosome':chromosome, 'genome_strand':strand, 'strand_start':genomic_starts[0], 'strand_stop':genomic_stops[0], 'reads_min':min_O, 'reads_max':max_O, #'reads_lb':data_TTest['ci_lb'], #'reads_ub':data_TTest['ci_ub'], 'reads_lb':data_lb_O, 'reads_ub':data_ub_O, 'reads_iq1':iq_1_O, 'reads_iq3':iq_3_O, 'reads_median':median_O, #'reads_mean':data_TTest['mean'], #'reads_var':data_TTest['var'], 'reads_mean':data_ave_O, 'reads_var':data_var_O, 'reads_n':len(data_reads), 'amplification_start':start, 'amplification_stop':stops[start_cnt], 'used_':True, 'comment_':None }) # add data to the DB self.add_dataStage01ResequencingAmplificationStats(data_O);