From 6e6482db14c3840328d786c551feea6e34a3ef06 Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 28 Apr 2016 18:42:20 +0000 Subject: Added option to export permutation results for mapping page Added data_scale to dataset objects and basic stats table will now check data scale when calculating range Made interval analyst results table work with datatables Changed the appearance of the basic stats table some by giving it a border --- wqflask/base/data_set.py | 74 +--------------------- .../wqflask/marker_regression/marker_regression.py | 12 +++- wqflask/wqflask/show_trait/show_trait.py | 1 + .../wqflask/static/new/javascript/show_trait.js | 4 +- .../wqflask/templates/marker_regression_gn1.html | 31 ++++++++- wqflask/wqflask/templates/show_trait.html | 1 - .../wqflask/templates/show_trait_statistics.html | 2 +- wqflask/wqflask/views.py | 23 +++++++ 8 files changed, 68 insertions(+), 80 deletions(-) mode change 100755 => 100644 wqflask/base/data_set.py diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py old mode 100755 new mode 100644 index e37a838f..379e5906 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -509,6 +509,7 @@ class DataSet(object): self.shortname = None self.fullname = None self.type = None + self.data_scale = None #ZS: For example log2 self.setup() @@ -569,8 +570,8 @@ class DataSet(object): self.name, self.name)) - self.id, self.name, self.fullname, self.shortname, self.tissue = g.db.execute(""" - SELECT ProbeSetFreeze.Id, ProbeSetFreeze.Name, ProbeSetFreeze.FullName, ProbeSetFreeze.ShortName, Tissue.Name + self.id, self.name, self.fullname, self.shortname, self.data_scale, self.tissue = g.db.execute(""" + SELECT ProbeSetFreeze.Id, ProbeSetFreeze.Name, ProbeSetFreeze.FullName, ProbeSetFreeze.ShortName, ProbeSetFreeze.DataScale, Tissue.Name FROM ProbeSetFreeze, ProbeFreeze, Tissue WHERE ProbeSetFreeze.public > %s AND ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id AND @@ -1035,75 +1036,6 @@ class MrnaAssayDataSet(DataSet): #print("After retrieve_sample_data") return trait_data - #def get_trait_data(self): - # self.samplelist = self.group.samplelist + self.group.parlist + self.group.f1list - # query = """ - # SELECT Strain.Name, Strain.Id FROM Strain, Species - # WHERE Strain.Name IN {} - # and Strain.SpeciesId=Species.Id - # and Species.name = '{}' - # """.format(create_in_clause(self.samplelist), *mescape(self.group.species)) - # results = dict(g.db.execute(query).fetchall()) - # sample_ids = [results[item] for item in self.samplelist] - # - # # MySQL limits the number of tables that can be used in a join to 61, - # # so we break the sample ids into smaller chunks - # # Postgres doesn't have that limit, so we can get rid of this after we transition - # chunk_size = 50 - # number_chunks = int(math.ceil(len(sample_ids) / chunk_size)) - # trait_sample_data = [] - # for sample_ids_step in chunks.divide_into_chunks(sample_ids, number_chunks): - # - # #XZ, 09/24/2008: build one temporary table that only contains the records associated with the input GeneId - # #tempTable = None - # #if GeneId and db.type == "ProbeSet": - # # if method == "3": - # # tempTable = self.getTempLiteratureTable(species=species, - # # input_species_geneid=GeneId, - # # returnNumber=returnNumber) - # # - # # if method == "4" or method == "5": - # # tempTable = self.getTempTissueCorrTable(primaryTraitSymbol=GeneSymbol, - # # TissueProbeSetFreezeId=tissueProbeSetFreezeId, - # # method=method, - # # returnNumber=returnNumber) - # - # temp = ['T%s.value' % item for item in sample_ids_step] - # query = "SELECT {}.Name,".format(escape(self.type)) - # data_start_pos = 1 - # query += string.join(temp, ', ') - # query += ' FROM ({}, {}XRef, {}Freeze) '.format(*mescape(self.type, - # self.type, - # self.type)) - # - # for item in sample_ids_step: - # query += """ - # left join {}Data as T{} on T{}.Id = {}XRef.DataId - # and T{}.StrainId={}\n - # """.format(*mescape(self.type, item, item, self.type, item, item)) - # - # query += """ - # WHERE {}XRef.{}FreezeId = {}Freeze.Id - # and {}Freeze.Name = '{}' - # and {}.Id = {}XRef.{}Id - # order by {}.Id - # """.format(*mescape(self.type, self.type, self.type, self.type, - # self.name, self.type, self.type, self.type, self.type)) - # results = g.db.execute(query).fetchall() - # trait_sample_data.append(results) - # - # trait_count = len(trait_sample_data[0]) - # self.trait_data = collections.defaultdict(list) - # - # # put all of the separate data together into a dictionary where the keys are - # # trait names and values are lists of sample values - # for trait_counter in range(trait_count): - # trait_name = trait_sample_data[0][trait_counter][0] - # for chunk_counter in range(int(number_chunks)): - # self.trait_data[trait_name] += ( - # trait_sample_data[chunk_counter][trait_counter][data_start_pos:]) - - def get_trait_info(self, trait_list=None, species=''): # Note: setting trait_list to [] is probably not a great idea. diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index fa439b55..c0bfd70b 100644 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -79,6 +79,8 @@ class MarkerRegression(object): self.pair_scan = False # Initializing this since it is checked in views to determine which template to use self.score_type = "LRS" #ZS: LRS or LOD self.mapping_scale = "physic" + self.num_perm = 0 + self.perm_output = [] self.bootstrap_results = [] #ZS: This is passed to GN1 code for single chr mapping @@ -125,13 +127,14 @@ class MarkerRegression(object): try: if int(start_vars['num_perm']) > 0: self.num_perm = int(start_vars['num_perm']) - else: - self.num_perm = 0 except: self.num_perm = 0 self.LRSCheck = self.score_type - self.permCheck = "ON" + if self.num_perm > 0: + self.permCheck = "ON" + else: + self.permCheck = False self.showSNP = "ON" self.showGenes = "ON" self.viewLegend = "ON" @@ -278,6 +281,8 @@ class MarkerRegression(object): mapping_scale = self.mapping_scale, chromosomes = chromosome_mb_lengths, qtl_results = self.qtl_results, + num_perm = self.num_perm, + perm_results = self.perm_output, ) @@ -683,6 +688,7 @@ class MarkerRegression(object): self.perm_output = genotype.permutation(strains = trimmed_samples, trait = trimmed_values, nperm=self.num_perm) self.suggestive = self.perm_output[int(self.num_perm*0.37-1)] self.significant = self.perm_output[int(self.num_perm*0.95-1)] + self.highly_significant = self.perm_output[int(self.num_perm*0.99-1)] self.json_data['suggestive'] = self.suggestive self.json_data['significant'] = self.significant diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 2d4c952a..156510bb 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -153,6 +153,7 @@ class ShowTrait(object): self.trait_table_width = get_trait_table_width(self.sample_groups) js_data = dict(dataset_type = self.dataset.type, + data_scale = self.dataset.data_scale, sample_group_types = self.sample_group_types, sample_lists = sample_lists, attribute_names = self.sample_groups[0].attributes, diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 9d418e9b..9e249c28 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -190,9 +190,9 @@ } row_line = "