From e14f913da79111c3db8d6faced45d92281865cb1 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Fri, 1 Mar 2019 10:30:52 -0600
Subject: Added more information to the top-right corner of the mapping results
Fixed sorting issues on correlation page
---
.../marker_regression/display_mapping_results.py | 67 ++++++++++++++--------
wqflask/wqflask/templates/correlation_page.html | 56 ++++++++----------
wqflask/wqflask/views.py | 7 ++-
3 files changed, 70 insertions(+), 60 deletions(-)
diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py
index fa20e8ad..2d0ed1d7 100644
--- a/wqflask/wqflask/marker_regression/display_mapping_results.py
+++ b/wqflask/wqflask/marker_regression/display_mapping_results.py
@@ -24,7 +24,7 @@
#
# Last updated by Zach 12/14/2010
-import time
+import datetime
import string
from math import *
import piddle as pid
@@ -146,6 +146,7 @@ class DisplayMappingResults(object):
self.dataset = start_vars['dataset']
self.this_trait = start_vars['this_trait']
+ self.n_samples = len(start_vars['vals'])
self.species = start_vars['species']
if 'genofile_string' in start_vars:
self.genofile_string = start_vars['genofile_string']
@@ -474,10 +475,10 @@ class DisplayMappingResults(object):
#calculating margins
xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset
if self.multipleInterval:
- yTopOffset = max(80, yTopOffset)
+ yTopOffset = max(90, yTopOffset)
else:
if self.legendChecked:
- yTopOffset = max(80, yTopOffset)
+ yTopOffset = max(90, yTopOffset)
else:
pass
@@ -879,52 +880,68 @@ class DisplayMappingResults(object):
labelFont = pid.Font(ttf="verdana",size=12*fontZoom)
labelColor = pid.black
- if self.selectedChr == -1:
- string1 = 'Mapping for Dataset: %s, mapping on All Chromosomes' % self.dataset.group.name
+ if self.dataset.type == "Publish" or self.dataset.type == "Geno":
+ dataset_label = self.dataset.fullname
else:
- string1 = 'Mapping for Dataset: %s, mapping on Chromosome %s' % (self.dataset.group.name, self.ChrList[self.selectedChr][0])
+ dataset_label = "%s - %s" % (self.dataset.group.name, self.dataset.fullname)
- string3 = ''
+ string1 = 'Dataset: %s' % (dataset_label)
+
+ string2 = 'Using Genotype File: %s' % self.genofile_string
+
+ string4 = ''
if self.mapping_method == "gemma" or self.mapping_method == "gemma_bimbam":
if self.use_loco == "True":
- string2 = 'Using GEMMA mapping method with LOCO and '
+ string3 = 'Using GEMMA mapping method with LOCO and '
else:
- string2 = 'Using GEMMA mapping method with '
+ string3 = 'Using GEMMA mapping method with '
if self.covariates != "":
- string2 += 'the cofactors below:'
+ string3 += 'the cofactors below:'
cofactor_names = ", ".join([covar.split(":")[0] for covar in self.covariates.split(",")])
- string3 = cofactor_names
+ string4 = cofactor_names
else:
- string2 += 'no cofactors'
+ string3 += 'no cofactors'
elif self.mapping_method == "rqtl_plink" or self.mapping_method == "rqtl_geno":
- string2 = 'Using R/qtl mapping method with '
+ string3 = 'Using R/qtl mapping method with '
if self.controlLocus and self.doControl != "false":
- string2 += '%s as control' % self.controlLocus
+ string3 += '%s as control' % self.controlLocus
else:
- string2 += 'no control for other QTLs'
- elif self.mapping_method == "plink":
- string2 = 'Using PLINK mapping method with no control for other QTLs'
+ string3 += 'no control for other QTLs'
else:
- string2 = 'Using Haldane mapping function with '
+ string3 = 'Using Haldane mapping function with '
if self.controlLocus and self.doControl != "false":
- string2 += '%s as control' % self.controlLocus
+ string3 += '%s as control' % self.controlLocus
else:
- string2 += 'no control for other QTLs'
+ string3 += 'no control for other QTLs'
if self.this_trait.name:
+ if self.selectedChr == -1:
+ identification = "Mapping on All Chromosomes for "
+ else:
+ identification = "Mapping on Chromosome %s for " % (self.ChrList[self.selectedChr][0])
+
if self.this_trait.symbol:
- identification = "Trait ID: %s : %s : %s" % (self.this_trait.symbol, self.dataset.fullname, self.this_trait.name)
+ identification += "Trait: %s - %s" % (self.this_trait.name, self.this_trait.symbol)
+ elif self.this_trait.post_publication_abbreviation:
+ identification += "Trait: %s - %s" % (self.this_trait.name, self.this_trait.post_publication_abbreviation)
+ elif self.this_trait.pre_publication_abbreviation:
+ identification += "Trait: %s - %s" % (self.this_trait.name, self.this_trait.pre_publication_abbreviation)
else:
- identification = "Trait ID: %s : %s" % (self.dataset.fullname, self.this_trait.name)
+ identification += "Trait: %s" % (self.this_trait.name)
+ identification += " with %s samples" % (self.n_samples)
+
d = 4+ max(canvas.stringWidth(identification, font=labelFont), canvas.stringWidth(string1, font=labelFont), canvas.stringWidth(string2, font=labelFont))
canvas.drawString(identification,canvas.size[0] - xRightOffset-d,20*fontZoom,font=labelFont,color=labelColor)
else:
d = 4+ max(canvas.stringWidth(string1, font=labelFont), canvas.stringWidth(string2, font=labelFont))
canvas.drawString(string1,canvas.size[0] - xRightOffset-d,35*fontZoom,font=labelFont,color=labelColor)
canvas.drawString(string2,canvas.size[0] - xRightOffset-d,50*fontZoom,font=labelFont,color=labelColor)
- if string3 != '':
- canvas.drawString(string3,canvas.size[0] - xRightOffset-d,65*fontZoom,font=labelFont,color=labelColor)
-
+ canvas.drawString(string3,canvas.size[0] - xRightOffset-d,65*fontZoom,font=labelFont,color=labelColor)
+ if string4 != '':
+ canvas.drawString(string4,canvas.size[0] - xRightOffset-d,80*fontZoom,font=labelFont,color=labelColor)
+ canvas.drawString("Created at: " + str(datetime.datetime.now()).split('.')[0], canvas.size[0] - xRightOffset-d,95*fontZoom,font=labelFont,color=labelColor)
+ else:
+ canvas.drawString("Created at: " + str(datetime.datetime.now()).split('.')[0], canvas.size[0] - xRightOffset-d,80*fontZoom,font=labelFont,color=labelColor)
def drawGeneBand(self, canvas, gifmap, plotXScale, offset= (40, 120, 80, 10), zoom = 1, startMb = None, endMb = None):
if self.plotScale != 'physic' or self.selectedChr == -1 or not self.geneCol:
diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html
index 76513c82..2b5a7f33 100644
--- a/wqflask/wqflask/templates/correlation_page.html
+++ b/wqflask/wqflask/templates/correlation_page.html
@@ -229,42 +229,36 @@
+
+