From 66c6bbfcbbd5fb23145ec09956f4809e5f701bec Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 5 Jun 2019 13:01:36 -0500 Subject: Fixed issue that caused interval mapping to not work because the python implementation of the reaper Dataset object doesn't include the addinterval method (so for those situations I still use reaper) Fixed issue where the last chromosome wasn't displayed for mapping results (though still need to fix issue where points are drawn too far to the right when a specific range is viewed) --- wqflask/base/data_set.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'wqflask/base/data_set.py') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index b324ac74..1fd1792e 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -384,7 +384,7 @@ class DatasetGroup(object): [result.extend(l) for l in lists if l] return result - def read_genotype_file(self): + def read_genotype_file(self, use_reaper=False): '''Read genotype from .geno file instead of database''' #genotype_1 is Dataset Object without parents and f1 #genotype_2 is Dataset Object with parents and f1 (not for intercross) @@ -396,9 +396,12 @@ class DatasetGroup(object): full_filename = str(locate(self.genofile, 'genotype')) else: full_filename = str(locate(self.name + '.geno', 'genotype')) - #genotype_1.read(full_filename) - genotype_1 = gen_geno_ob.genotype(full_filename) + if use_reaper: + genotype_1 = reaper.Dataset() + genotype_1.read(full_filename) + else: + genotype_1 = gen_geno_ob.genotype(full_filename) if genotype_1.type == "group" and self.parlist: genotype_2 = genotype_1.add(Mat=self.parlist[0], Pat=self.parlist[1]) #, F1=_f1) -- cgit v1.2.3 From 172bf33d20d6f42650b415571c1185af4cbd22c5 Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 18 Jun 2019 15:39:36 -0500 Subject: Fixed issue with sorting involving 0's on trait page Fixed links to dataset info pages in search results and correlation results pages --- wqflask/base/data_set.py | 41 ++++++++++++++--------- wqflask/wqflask/templates/correlation_page.html | 4 +-- wqflask/wqflask/templates/search_result_page.html | 2 +- wqflask/wqflask/templates/show_trait.html | 4 +-- 4 files changed, 31 insertions(+), 20 deletions(-) (limited to 'wqflask/base/data_set.py') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 1fd1792e..4fee5c7a 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -289,7 +289,6 @@ class DatasetGroup(object): self.parlist = None self.get_f1_parent_strains() - self.accession_id = self.get_accession_id() self.mapping_id, self.mapping_names = self.get_mapping_methods() self.species = webqtlDatabaseFunction.retrieve_species(self.name) @@ -299,20 +298,6 @@ class DatasetGroup(object): self._datasets = None self.genofile = None - def get_accession_id(self): - results = g.db.execute("""select InfoFiles.GN_AccesionId from InfoFiles, PublishFreeze, InbredSet where - InbredSet.Name = %s and - PublishFreeze.InbredSetId = InbredSet.Id and - InfoFiles.InfoPageName = PublishFreeze.Name and - PublishFreeze.public > 0 and - PublishFreeze.confidentiality < 1 order by - PublishFreeze.CreateTime desc""", (self.name)).fetchone() - - if results != None: - return str(results[0]) - else: - return "None" - def get_mapping_methods(self): mapping_id = g.db.execute("select MappingMethodId from InbredSet where Name= '%s'" % self.name).fetchone()[0] @@ -510,6 +495,7 @@ class DataSet(object): self.check_confidentiality() self.retrieve_other_names() self.group = DatasetGroup(self) # sets self.group and self.group_id and gets genotype + self.accession_id = self.get_accession_id() if get_samplelist == True: self.group.get_samplelist() self.species = species.TheSpecies(self) @@ -524,6 +510,31 @@ class DataSet(object): def riset(): Weve_Renamed_This_As_Group + def get_accession_id(self): + if self.type == "Publish": + results = g.db.execute("""select InfoFiles.GN_AccesionId from InfoFiles, PublishFreeze, InbredSet where + InbredSet.Name = %s and + PublishFreeze.InbredSetId = InbredSet.Id and + InfoFiles.InfoPageName = PublishFreeze.Name and + PublishFreeze.public > 0 and + PublishFreeze.confidentiality < 1 order by + PublishFreeze.CreateTime desc""", (self.group.name)).fetchone() + elif self.type == "Geno": + results = g.db.execute("""select InfoFiles.GN_AccesionId from InfoFiles, GenoFreeze, InbredSet where + InbredSet.Name = %s and + GenoFreeze.InbredSetId = InbredSet.Id and + InfoFiles.InfoPageName = GenoFreeze.ShortName and + GenoFreeze.public > 0 and + GenoFreeze.confidentiality < 1 order by + GenoFreeze.CreateTime desc""", (self.group.name)).fetchone() + else: + results = None + + if results != None: + return str(results[0]) + else: + return "None" + def retrieve_other_names(self): """This method fetches the the dataset names in search_result. diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 7cc998bb..32f5e774 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -12,8 +12,8 @@
-

Values of record {{ this_trait.name }} in the {{ dataset.fullname }} - dataset were compared to all records in the {{ target_dataset.fullname }} +

Values of record {{ this_trait.name }} in the {{ dataset.fullname }} + dataset were compared to all records in the {{ target_dataset.fullname }} dataset. The top {{ return_number }} correlations ranked by the {{ formatted_corr_type }} are displayed. You can resort this list by clicking the headers. Select the Record ID to open the trait data and analysis page. diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index 61a533f7..374347bd 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -13,7 +13,7 @@

-

We searched {{ dataset.fullname }} +

We searched {{ dataset.fullname }} to find all records {% for word in search_terms %} {% if word.key|lower == "rif" %} diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index 378f91b1..d5473bca 100644 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -183,10 +183,10 @@ var x = getValue(a); var y = getValue(b); - if (x == 'x' || x == '') { + if (x == 'x' || x === '') { return 1; } - else if (y == 'x' || y == '') { + else if (y == 'x' || y === '') { return -1; } else { -- cgit v1.2.3 From 4a7c35204863066dc387637bd0f8af7d274cde55 Mon Sep 17 00:00:00 2001 From: zsloan Date: Mon, 24 Jun 2019 12:09:35 -0500 Subject: Got non-LOCO GEMMA mapping working with gemma-wrapper (so caching should work for that now) Fixed position digits and row highlighting on interval analyst table Updated default MAF to 0.05 Updated footer text --- wqflask/base/data_set.py | 2 +- .../marker_regression/display_mapping_results.py | 10 +-- wqflask/wqflask/marker_regression/gemma_mapping.py | 73 +++++++++++----------- wqflask/wqflask/show_trait/show_trait.py | 2 +- wqflask/wqflask/templates/base.html | 42 ++++++++----- wqflask/wqflask/templates/mapping_results.html | 8 ++- 6 files changed, 74 insertions(+), 63 deletions(-) (limited to 'wqflask/base/data_set.py') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 4fee5c7a..d766e284 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -433,7 +433,7 @@ def datasets(group_name, this_group = None): and InbredSet.Name like %s and ProbeSetFreeze.public > %s and ProbeSetFreeze.confidentiality < 1 - ORDER BY Tissue.Name) + ORDER BY Tissue.Name, ProbeSetFreeze.OrderList DESC) ''' % (group_name, webqtlConfig.PUBLICTHRESH, group_name, webqtlConfig.PUBLICTHRESH, "'" + group_name + "'", webqtlConfig.PUBLICTHRESH)) diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py index cafbf38c..41cdf819 100644 --- a/wqflask/wqflask/marker_regression/display_mapping_results.py +++ b/wqflask/wqflask/marker_regression/display_mapping_results.py @@ -2127,7 +2127,7 @@ class DisplayMappingResults(object): tableIterationsCnt = tableIterationsCnt + 1 this_row = [] #container for the cells of each row - selectCheck = HT.Input(type="checkbox", name="searchResult", value=theGO["GeneSymbol"], Class="checkbox trait_checkbox") #checkbox for each row + selectCheck = HT.Input(type="checkbox", name="selectCheck", value=theGO["GeneSymbol"], Class="checkbox trait_checkbox") #checkbox for each row geneLength = (theGO["TxEnd"] - theGO["TxStart"])*1000.0 tenPercentLength = geneLength*0.0001 @@ -2213,7 +2213,7 @@ class DisplayMappingResults(object): elif self.dataset.group.species == 'rat': for gIndex, theGO in enumerate(geneCol): this_row = [] #container for the cells of each row - selectCheck = HT.Input(type="checkbox", name="searchResult", Class="checkbox", onClick="highlight(this)").__str__() #checkbox for each row + selectCheck = HT.Input(type="checkbox", name="selectCheck", Class="checkbox trait_checkbox").__str__() #checkbox for each row #ZS: May want to get this working again later #webqtlSearch = HT.Href(os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE)+"?cmd=sch&gene=%s&alias=1&species=rat" % theGO["GeneSymbol"], ">>", target="_blank").__str__() @@ -2240,14 +2240,14 @@ class DisplayMappingResults(object): #Mouse Gene if theGO['mouseGene']: mouseChr = theGO['mouseGene']["Chromosome"] - mouseTxStart = theGO['mouseGene']["TxStart"] + mouseTxStart = "%0.6f" % theGO['mouseGene']["TxStart"] else: mouseChr = mouseTxStart = "" #the chromosomes for human 1 are 1qXX.XX if theGO['humanGene']: humanChr = theGO['humanGene']["Chromosome"] - humanTxStart = theGO['humanGene']["TxStart"] + humanTxStart = "%0.6f" % theGO['humanGene']["TxStart"] else: humanChr = humanTxStart = "" @@ -2258,7 +2258,7 @@ class DisplayMappingResults(object): this_row = [selectCheck.__str__(), str(gIndex+1), geneSymbolNCBI, - theGO["TxStart"], + "%0.6f" % theGO["TxStart"], HT.Href(geneLengthURL, "%0.3f" % (geneLength*1000.0)).__str__(), avgExprVal, mouseChr, diff --git a/wqflask/wqflask/marker_regression/gemma_mapping.py b/wqflask/wqflask/marker_regression/gemma_mapping.py index 0f37e711..4e3c203d 100644 --- a/wqflask/wqflask/marker_regression/gemma_mapping.py +++ b/wqflask/wqflask/marker_regression/gemma_mapping.py @@ -73,50 +73,51 @@ def run_gemma(this_trait, this_dataset, samples, vals, covariates, use_loco, maf gwa_output_filename) else: - generate_k_command = GEMMA_COMMAND + ' ' + GEMMAOPTS + ' -g %s/%s_geno.txt -p %s/gn2/%s.txt -a %s/%s_snps.txt -gk -outdir %s/gn2/ -o %s' % (flat_files('genotype/bimbam'), - genofile_name, - TEMPDIR, - trait_filename, - flat_files('genotype/bimbam'), - genofile_name, - TEMPDIR, - k_output_filename) - #generate_k_command = GEMMA_WRAPPER_COMMAND + ' --json -- ' + GEMMAOPTS + ' -g %s/%s_geno.txt -p %s/%s.txt -a %s/%s_snps.txt -gk > %s/gn2/%s.json' % (flat_files('genotype/bimbam'), - # genofile_name, - # flat_files('genotype/bimbam'), - # trait_filename, - # flat_files('genotype/bimbam'), - # genofile_name, - # TEMPDIR, - # k_output_filename) + # generate_k_command = GEMMA_COMMAND + ' ' + GEMMAOPTS + ' -g %s/%s_geno.txt -p %s/gn2/%s.txt -a %s/%s_snps.txt -gk -outdir %s/gn2/ -o %s' % (flat_files('genotype/bimbam'), + # genofile_name, + # TEMPDIR, + # trait_filename, + # flat_files('genotype/bimbam'), + # genofile_name, + # TEMPDIR, + # k_output_filename) + generate_k_command = GEMMA_WRAPPER_COMMAND + ' --json -- ' + GEMMAOPTS + ' -g %s/%s_geno.txt -p %s/gn2/%s.txt -a %s/%s_snps.txt -gk > %s/gn2/%s.json' % (flat_files('genotype/bimbam'), + genofile_name, + TEMPDIR, + trait_filename, + flat_files('genotype/bimbam'), + genofile_name, + TEMPDIR, + k_output_filename) logger.debug("k_command:" + generate_k_command) os.system(generate_k_command) - gemma_command = GEMMA_COMMAND + ' ' + GEMMAOPTS + ' -g %s/%s_geno.txt -p %s/gn2/%s.txt -a %s/%s_snps.txt -k %s/gn2/%s.cXX.txt -lmm 2 -maf %s' % (flat_files('genotype/bimbam'), - genofile_name, - TEMPDIR, - trait_filename, - flat_files('genotype/bimbam'), - genofile_name, - TEMPDIR, - k_output_filename, - maf) + # gemma_command = GEMMA_COMMAND + ' ' + GEMMAOPTS + ' -g %s/%s_geno.txt -p %s/gn2/%s.txt -a %s/%s_snps.txt -k %s/gn2/%s.cXX.txt -lmm 2 -maf %s' % (flat_files('genotype/bimbam'), + # genofile_name, + # TEMPDIR, + # trait_filename, + # flat_files('genotype/bimbam'), + # genofile_name, + # TEMPDIR, + # k_output_filename, + # maf) - #gemma_command = GEMMA_WRAPPER_COMMAND + ' --json --input %s/gn2/%s.json -- ' % (TEMPDIR, k_output_filename) + GEMMAOPTS + ' -g %s/%s_geno.txt -p %s/%s_pheno.txt' % (flat_files('genotype/bimbam'), - # genofile_name, - # flat_files('genotype/bimbam'), - # genofile_name) + gemma_command = GEMMA_WRAPPER_COMMAND + ' --json --input %s/gn2/%s.json -- ' % (TEMPDIR, k_output_filename) + GEMMAOPTS + ' -lmm 2 -g %s/%s_geno.txt -p %s/gn2/%s.txt' % (flat_files('genotype/bimbam'), + genofile_name, + TEMPDIR, + trait_filename) if covariates != "": - gemma_command += ' -c %s/%s_covariates.txt -outdir %s -o %s_output' % (flat_files('mapping'), - this_dataset.group.name, - webqtlConfig.GENERATED_IMAGE_DIR, - genofile_name) - else: - gemma_command += ' -outdir %s -o %s_output' % (webqtlConfig.GENERATED_IMAGE_DIR, - genofile_name) + gemma_command += ' -c %s/%s_covariates.txt' % (flat_files('mapping'), this_dataset.group.name) + # gemma_command += ' -c %s/%s_covariates.txt -outdir %s -o %s_output' % (flat_files('mapping'), + # this_dataset.group.name, + # webqtlConfig.GENERATED_IMAGE_DIR, + # genofile_name) + # else: + # gemma_command += ' -outdir %s -o %s_output' % (webqtlConfig.GENERATED_IMAGE_DIR, + # genofile_name) logger.debug("gemma_command:" + gemma_command) diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index e10b31c0..5178ece8 100644 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -168,7 +168,7 @@ class ShowTrait(object): hddn['control_marker'] = self.nearest_marker #hddn['control_marker'] = self.nearest_marker1+","+self.nearest_marker2 hddn['do_control'] = False - hddn['maf'] = 0.01 + hddn['maf'] = 0.05 hddn['compare_traits'] = [] hddn['export_data'] = "" hddn['export_format'] = "excel" diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index 21fc99d3..3fd9faf5 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -127,27 +127,35 @@ JOSS


-

GeneNetwork is supported by:

-