aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorzsloan2016-03-29 20:56:56 +0000
committerzsloan2016-03-29 20:56:56 +0000
commitcfb59d81eaa49dbfc61835af320ac024736eb6d8 (patch)
treeff4303e45f2eb503f440e7603a33dae0f14ab4e2 /wqflask
parent1173cfb9ff03c24d20db012e10f56e41906a9bcd (diff)
downloadgenenetwork2-cfb59d81eaa49dbfc61835af320ac024736eb6d8.tar.gz
Additive effect option now works for GN1 mapping figure
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/marker_regression/marker_regression.py18
-rw-r--r--wqflask/wqflask/marker_regression/marker_regression_gn1.py149
-rw-r--r--wqflask/wqflask/templates/marker_regression_gn1.html1
-rw-r--r--wqflask/wqflask/views.py1
4 files changed, 91 insertions, 78 deletions
diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py
index 9f61ee3c..85404f58 100644
--- a/wqflask/wqflask/marker_regression/marker_regression.py
+++ b/wqflask/wqflask/marker_regression/marker_regression.py
@@ -144,7 +144,15 @@ class MarkerRegression(object):
self.num_perm = 0
else:
self.num_perm = int(start_vars['num_perm'])
- self.additive = False
+
+ if "startMb" in start_vars: #ZS: Check if first time page loaded, so it can default to ON
+ if "additiveCheck" in start_vars:
+ self.additiveCheck = start_vars['additiveCheck']
+ else:
+ self.additiveCheck = False
+ else:
+ self.additiveCheck = "ON"
+
self.control = start_vars['control_marker']
self.do_control = start_vars['do_control']
results = self.gen_reaper_results()
@@ -666,8 +674,8 @@ class MarkerRegression(object):
self.json_data['pos'] = []
self.json_data['lod.hk'] = []
self.json_data['markernames'] = []
- if self.additive:
- self.json_data['additive'] = []
+ #if self.additive:
+ # self.json_data['additive'] = []
#Need to convert the QTL objects that qtl reaper returns into a json serializable dictionary
qtl_results = []
@@ -681,8 +689,8 @@ class MarkerRegression(object):
self.json_data['pos'].append(reaper_locus.Mb)
self.json_data['lod.hk'].append(qtl.lrs)
self.json_data['markernames'].append(reaper_locus.name)
- if self.additive:
- self.json_data['additive'].append(qtl.additive)
+ #if self.additive:
+ # self.json_data['additive'].append(qtl.additive)
locus = {"name":reaper_locus.name, "chr":reaper_locus.chr, "cM":reaper_locus.cM, "Mb":reaper_locus.Mb}
qtl = {"lrs_value": qtl.lrs, "chr":converted_chr, "Mb":reaper_locus.Mb,
"cM":reaper_locus.cM, "name":reaper_locus.name, "additive":qtl.additive, "dominance":qtl.dominance}
diff --git a/wqflask/wqflask/marker_regression/marker_regression_gn1.py b/wqflask/wqflask/marker_regression/marker_regression_gn1.py
index b53d5b1e..e3466bef 100644
--- a/wqflask/wqflask/marker_regression/marker_regression_gn1.py
+++ b/wqflask/wqflask/marker_regression/marker_regression_gn1.py
@@ -121,10 +121,10 @@ class MarkerRegression(object):
SIGNIFICANT_WIDTH = 5
SUGGESTIVE_WIDTH = 5
ADDITIVE_COLOR_POSITIVE = pid.green
- ADDITIVE_COLOR_NEGATIVE = pid.red
+ ADDITIVE_COLOR_NEGATIVE = pid.orange
ADDITIVE_COLOR = ADDITIVE_COLOR_POSITIVE
DOMINANCE_COLOR_POSITIVE = pid.darkviolet
- DOMINANCE_COLOR_NEGATIVE = pid.orange
+ DOMINANCE_COLOR_NEGATIVE = pid.red
## BEGIN HaplotypeAnalyst
HAPLOTYPE_POSITIVE = pid.green
@@ -279,11 +279,14 @@ class MarkerRegression(object):
self.graphHeight = self.GRAPH_DEFAULT_HEIGHT
self.manhattan_plot = start_vars['manhattan_plot']
- self.additiveChecked = False
self.dominanceChecked = False
self.LRS_LOD = start_vars['score_type']
self.cutoff = start_vars['cutoff']
self.intervalAnalystChecked = False
+ if 'additiveCheck' in start_vars.keys():
+ self.additiveChecked = start_vars['additiveCheck']
+ else:
+ self.additiveChecked = False
if 'viewLegend' in start_vars.keys():
self.legendChecked = start_vars['viewLegend']
else:
@@ -585,8 +588,8 @@ class MarkerRegression(object):
################################################################
btminfo = HT.Paragraph(Id="smallsize") #Small('More information about this graph is available here.')
- if (self.additiveChecked):
- btminfo.append(HT.BR(), 'A positive additive coefficient (', HT.Font('green', color='green'), ' line) indicates that %s alleles increase trait values. In contrast, a negative additive coefficient (' % fd.ppolar, HT.Font('red', color='red'), ' line) indicates that %s alleles increase trait values.' % fd.mpolar)
+ #if (self.additiveChecked):
+ # btminfo.append(HT.BR(), 'A positive additive coefficient (', HT.Font('green', color='green'), ' line) indicates that %s alleles increase trait values. In contrast, a negative additive coefficient (' % fd.ppolar, HT.Font('red', color='red'), ' line) indicates that %s alleles increase trait values.' % fd.mpolar)
if self.traitList and self.traitList[0].dataset and self.traitList[0].dataset.type == 'Geno':
btminfo.append(HT.BR(), 'Mapping using genotype data as a trait will result in infinity LRS at one locus. In order to display the result properly, all LRSs higher than 100 are capped at 100.')
@@ -1920,7 +1923,7 @@ class MarkerRegression(object):
if self.multipleInterval:
lrsEdgeWidth = 1
else:
- #additiveMax = max(map(lambda X : abs(X.additive), self.qtlresults[0]))
+ additiveMax = max(map(lambda X : abs(X['additive']), self.qtlresults))
#if INTERCROSS:
# dominanceMax = max(map(lambda X : abs(X.dominance), self.qtlresults[0]))
#else:
@@ -1993,77 +1996,77 @@ class MarkerRegression(object):
else:
LRSCoordXY.append((Xc, Yc))
- #if not self.multipleInterval and self.additiveChecked:
- # if additiveMax == 0.0:
- # additiveMax = 0.000001
- # Yc = yZero - qtlresult[m].additive*AdditiveHeightThresh/additiveMax
- # AdditiveCoordXY.append((Xc, Yc))
- #if not self.multipleInterval and INTERCROSS and self.additiveChecked:
- # Yc = yZero - qtlresult[m].dominance*DominanceHeightThresh/dominanceMax
- # DominanceCoordXY.append((Xc, Yc))
+ if not self.multipleInterval and self.additiveChecked:
+ if additiveMax == 0.0:
+ additiveMax = 0.000001
+ Yc = yZero - qtlresult['additive']*AdditiveHeightThresh/additiveMax
+ AdditiveCoordXY.append((Xc, Yc))
+ # if not self.multipleInterval and INTERCROSS and self.additiveChecked:
+ # Yc = yZero - qtlresult['dominance']*DominanceHeightThresh/dominanceMax
+ # DominanceCoordXY.append((Xc, Yc))
m += 1
#canvas.drawPolygon(LRSCoordXY,edgeColor=thisLRSColor,closed=0, edgeWidth=lrsEdgeWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- lineWidth = 1
- if not self.multipleInterval and self.additiveChecked:
- plusColor = self.ADDITIVE_COLOR_POSITIVE
- minusColor = self.ADDITIVE_COLOR_NEGATIVE
- for k, aPoint in enumerate(AdditiveCoordXY):
- if k > 0:
- Xc0, Yc0 = AdditiveCoordXY[k-1]
- Xc, Yc = aPoint
- if (Yc0-yZero)*(Yc-yZero) < 0:
- if Xc == Xc0: #genotype , locus distance is 0
- Xcm = Xc
- else:
- Xcm = (yZero-Yc0)/((Yc-Yc0)/(Xc-Xc0)) +Xc0
- if Yc0 < yZero:
- canvas.drawLine(Xc0, Yc0, Xcm, yZero, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- canvas.drawLine(Xcm, yZero, Xc, yZero-(Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- else:
- canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xcm, yZero, color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- canvas.drawLine(Xcm, yZero, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- elif (Yc0-yZero)*(Yc-yZero) > 0:
- if Yc < yZero:
- canvas.drawLine(Xc0, Yc0, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- else:
- canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xc, yZero - (Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- else:
- minYc = min(Yc-yZero, Yc0-yZero)
- if minYc < 0:
- canvas.drawLine(Xc0, Yc0, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- else:
- canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xc, yZero - (Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- if not self.multipleInterval and INTERCROSS and self.dominanceChecked:
- plusColor = self.DOMINANCE_COLOR_POSITIVE
- minusColor = self.DOMINANCE_COLOR_NEGATIVE
- for k, aPoint in enumerate(DominanceCoordXY):
- if k > 0:
- Xc0, Yc0 = DominanceCoordXY[k-1]
- Xc, Yc = aPoint
- if (Yc0-yZero)*(Yc-yZero) < 0:
- if Xc == Xc0: #genotype , locus distance is 0
- Xcm = Xc
- else:
- Xcm = (yZero-Yc0)/((Yc-Yc0)/(Xc-Xc0)) +Xc0
- if Yc0 < yZero:
- canvas.drawLine(Xc0, Yc0, Xcm, yZero, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- canvas.drawLine(Xcm, yZero, Xc, yZero-(Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- else:
- canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xcm, yZero, color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- canvas.drawLine(Xcm, yZero, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- elif (Yc0-yZero)*(Yc-yZero) > 0:
- if Yc < yZero:
- canvas.drawLine(Xc0, Yc0, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- else:
- canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xc, yZero - (Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- else:
- minYc = min(Yc-yZero, Yc0-yZero)
- if minYc < 0:
- canvas.drawLine(Xc0, Yc0, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
- else:
- canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xc, yZero - (Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ lineWidth = 1
+ if not self.multipleInterval and self.additiveChecked:
+ plusColor = self.ADDITIVE_COLOR_POSITIVE
+ minusColor = self.ADDITIVE_COLOR_NEGATIVE
+ for k, aPoint in enumerate(AdditiveCoordXY):
+ if k > 0:
+ Xc0, Yc0 = AdditiveCoordXY[k-1]
+ Xc, Yc = aPoint
+ if (Yc0-yZero)*(Yc-yZero) < 0:
+ if Xc == Xc0: #genotype , locus distance is 0
+ Xcm = Xc
+ else:
+ Xcm = (yZero-Yc0)/((Yc-Yc0)/(Xc-Xc0)) +Xc0
+ if Yc0 < yZero:
+ canvas.drawLine(Xc0, Yc0, Xcm, yZero, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ canvas.drawLine(Xcm, yZero, Xc, yZero-(Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ else:
+ canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xcm, yZero, color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ canvas.drawLine(Xcm, yZero, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ elif (Yc0-yZero)*(Yc-yZero) > 0:
+ if Yc < yZero:
+ canvas.drawLine(Xc0, Yc0, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ else:
+ canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xc, yZero - (Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ else:
+ minYc = min(Yc-yZero, Yc0-yZero)
+ if minYc < 0:
+ canvas.drawLine(Xc0, Yc0, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ else:
+ canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xc, yZero - (Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ if not self.multipleInterval and INTERCROSS and self.dominanceChecked:
+ plusColor = self.DOMINANCE_COLOR_POSITIVE
+ minusColor = self.DOMINANCE_COLOR_NEGATIVE
+ for k, aPoint in enumerate(DominanceCoordXY):
+ if k > 0:
+ Xc0, Yc0 = DominanceCoordXY[k-1]
+ Xc, Yc = aPoint
+ if (Yc0-yZero)*(Yc-yZero) < 0:
+ if Xc == Xc0: #genotype , locus distance is 0
+ Xcm = Xc
+ else:
+ Xcm = (yZero-Yc0)/((Yc-Yc0)/(Xc-Xc0)) +Xc0
+ if Yc0 < yZero:
+ canvas.drawLine(Xc0, Yc0, Xcm, yZero, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ canvas.drawLine(Xcm, yZero, Xc, yZero-(Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ else:
+ canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xcm, yZero, color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ canvas.drawLine(Xcm, yZero, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ elif (Yc0-yZero)*(Yc-yZero) > 0:
+ if Yc < yZero:
+ canvas.drawLine(Xc0, Yc0, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ else:
+ canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xc, yZero - (Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ else:
+ minYc = min(Yc-yZero, Yc0-yZero)
+ if minYc < 0:
+ canvas.drawLine(Xc0, Yc0, Xc, Yc, color=plusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
+ else:
+ canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xc, yZero - (Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth))
if self.manhattan_plot != True:
diff --git a/wqflask/wqflask/templates/marker_regression_gn1.html b/wqflask/wqflask/templates/marker_regression_gn1.html
index 3be9ad01..550173fc 100644
--- a/wqflask/wqflask/templates/marker_regression_gn1.html
+++ b/wqflask/wqflask/templates/marker_regression_gn1.html
@@ -68,6 +68,7 @@
</table>
</div>
<div class="col-xs-4" style="padding: 0px;">
+ <input type="checkbox" name="additiveCheck" class="checkbox" style="display: inline; margin-top: 0px;" {% if additiveChecked|upper == "ON" %}value="ON" checked{% endif %}> <span style="font-size: 12px;">Allele Effects<br>
<input type="checkbox" name="showGenes" class="checkbox" style="display: inline; margin-top: 0px;" {% if geneChecked|upper == "ON" %}value="ON" checked{% endif %}> <span style="font-size: 12px;">Gene Track </span> <span style="color:red;">*</span><br>
<input type="checkbox" name="viewLegend" class="checkbox" style="display: inline; margin-top: 0px;" {% if legendChecked|upper == "ON" %}value="ON" checked{% endif %}> <span style="font-size: 12px;">Legend </span><br>
<input type="checkbox" name="haplotypeAnalystCheck" class="checkbox" style="display: inline; margin-top: 0px;" {% if haplotypeAnalystChecked|upper == "ON" %}value="ON" checked{% endif %}> <span style="font-size: 12px;">Haplotype Analyst </span> <span style="color:red;">*</span>
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index de04a758..98c75710 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -357,6 +357,7 @@ def marker_regression_page():
'startMb',
'endMb',
'graphWidth',
+ 'additiveCheck',
'showGenes',
'viewLegend',
'haplotypeAnalystCheck',