diff options
author | zsloan | 2016-03-23 20:14:19 +0000 |
---|---|---|
committer | zsloan | 2016-03-23 20:14:19 +0000 |
commit | 8e1a2728980c4f223a6ff8362b365d6d20010cd3 (patch) | |
tree | 9736cc784e89a1dbb5f989175eca944ce928b9fa | |
parent | a65a5e0ff16e033dd8a67808711663851afd0169 (diff) | |
download | genenetwork2-8e1a2728980c4f223a6ff8362b365d6d20010cd3.tar.gz |
Fixed GN1 mapping plots so that Y axis and the Y coordinates of manhattan plot points are correct
Table filters markers so it can always be displayed now (previously was too large for GEMMA)
-rw-r--r--[-rwxr-xr-x] | wqflask/wqflask/collect.py | 2 | ||||
-rw-r--r-- | wqflask/wqflask/marker_regression/gemma_mapping.py | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | wqflask/wqflask/marker_regression/marker_regression.py | 55 | ||||
-rw-r--r-- | wqflask/wqflask/marker_regression/marker_regression_gn1.py | 20 | ||||
-rw-r--r-- | wqflask/wqflask/templates/marker_regression_gn1.html | 8 | ||||
-rw-r--r--[-rwxr-xr-x] | wqflask/wqflask/views.py | 1 |
6 files changed, 38 insertions, 50 deletions
diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py index 750f4757..cd4c6fdc 100755..100644 --- a/wqflask/wqflask/collect.py +++ b/wqflask/wqflask/collect.py @@ -243,8 +243,6 @@ def list_collections(): ) except: return redirect(url_for('view_collection')) - #return render_template("collections/view_anonymous.html", - # params = params) @app.route("/collections/remove", methods=('POST',)) diff --git a/wqflask/wqflask/marker_regression/gemma_mapping.py b/wqflask/wqflask/marker_regression/gemma_mapping.py index 997b692d..cfcd4783 100644 --- a/wqflask/wqflask/marker_regression/gemma_mapping.py +++ b/wqflask/wqflask/marker_regression/gemma_mapping.py @@ -45,5 +45,5 @@ def parse_gemma_output(this_dataset): included_markers.append(line.split("\t")[1]) p_values.append(float(line.split("\t")[10])) - print("p_values: ", p_values) + #print("p_values: ", p_values) return included_markers, p_values
\ No newline at end of file diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index c50b9d78..7adc0a2e 100755..100644 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -176,6 +176,8 @@ class MarkerRegression(object): if ('lod_score' in marker.keys()) or ('lrs_value' in marker.keys()): self.qtl_results.append(marker) + self.trimmed_markers = trim_markers_for_table(results) + self.json_data['chr'] = [] self.json_data['pos'] = [] self.json_data['lod.hk'] = [] @@ -234,7 +236,7 @@ class MarkerRegression(object): self.dataset.group.name, self.dataset.group.name, self.dataset.group.name) - print("gemma_command:" + gemma_command) + #print("gemma_command:" + gemma_command) os.system(gemma_command) @@ -628,10 +630,10 @@ class MarkerRegression(object): self.json_data['suggestive'] = self.suggestive self.json_data['significant'] = self.significant - print("samples:", trimmed_samples) + #print("samples:", trimmed_samples) if self.control != "" and self.do_control == "true": - print("CONTROL IS:", self.control) + #print("CONTROL IS:", self.control) reaper_results = genotype.regression(strains = trimmed_samples, trait = trimmed_values, control = str(self.control)) @@ -749,7 +751,7 @@ class MarkerRegression(object): top_lod_scores = [] - print("self.num_perm:", self.num_perm) + #print("self.num_perm:", self.num_perm) for permutation in range(int(self.num_perm)): @@ -796,10 +798,10 @@ class MarkerRegression(object): if p_value < lowest_p_value: lowest_p_value = p_value - print("lowest_p_value:", lowest_p_value) + #print("lowest_p_value:", lowest_p_value) top_lod_scores.append(-math.log10(lowest_p_value)) - print("top_lod_scores:", top_lod_scores) + #print("top_lod_scores:", top_lod_scores) self.suggestive = np.percentile(top_lod_scores, 67) self.significant = np.percentile(top_lod_scores, 95) @@ -1012,6 +1014,21 @@ def create_snp_iterator_file(group): with gzip.open(snp_file_base, "wb") as fh: pickle.dump(data, fh, pickle.HIGHEST_PROTOCOL) +def trim_markers_for_table(markers): + num_markers = len(markers) + + if 'lod_score' in markers[0].keys(): + sorted_markers = sorted(markers, key=lambda k: k['lod_score'], reverse=True) + else: + sorted_markers = sorted(markers, key=lambda k: k['lrs_value'], reverse=True) + trimmed_sorted_markers = sorted_markers[:int(len(sorted_markers) * 0.001)] + + if len(trimmed_sorted_markers) < 50: + return sorted_markers + else: + return trimmed_sorted_markers + + def get_markers_from_csv(included_markers, p_values, group_name): marker_data_fh = open(os.path.join(webqtlConfig.PYLMM_PATH + group_name + '_markers.csv')) markers = [] @@ -1035,33 +1052,7 @@ def get_markers_from_csv(included_markers, p_values, group_name): markers.append(marker) break -# for line, p_value in itertools.izip(marker_data_fh, p_values): -# if not p_value or len(included_markers) < 1: -# continue -# splat = line.strip().split() -# if splat[0] in included_markers: -# marker = {} -# marker['name'] = splat[0] -# marker['chr'] = int(splat[1]) -# marker['Mb'] = float(splat[2]) -# marker['p_value'] = p_value -# if math.isnan(marker['p_value']) or (marker['p_value'] <= 0): -# marker['lod_score'] = 0 -# marker['lrs_value'] = 0 -# else: -# marker['lod_score'] = -math.log10(marker['p_value']) -# marker['lrs_value'] = -math.log10(marker['p_value']) * 4.61 -# markers.append(marker) -# else: -# continue - return markers - - -#if __name__ == '__main__': -# import cPickle as pickle -# import gzip -# create_snp_iterator_file("HLC") if __name__ == '__main__': import cPickle as pickle diff --git a/wqflask/wqflask/marker_regression/marker_regression_gn1.py b/wqflask/wqflask/marker_regression/marker_regression_gn1.py index 01cee4f4..37e67d71 100644 --- a/wqflask/wqflask/marker_regression/marker_regression_gn1.py +++ b/wqflask/wqflask/marker_regression/marker_regression_gn1.py @@ -24,7 +24,6 @@ # # Last updated by Zach 12/14/2010 - import time import string from math import * @@ -187,6 +186,7 @@ class MarkerRegression(object): self.pair_scan = start_vars['pair_scan'] self.js_data = start_vars['js_data'] + self.trimmed_markers = start_vars['trimmed_markers'] #Top markers to display in table #ZS: Think I can just get all this from dataset object now #RISet and Species @@ -210,6 +210,7 @@ class MarkerRegression(object): else: self._ucscDb = "" + ##################################### # Options ##################################### @@ -1838,17 +1839,17 @@ class MarkerRegression(object): #LRSTop is then defined to be above the LRSMax by enough to add one additional LRSScale increment. #if we are using a set-scale, then we set LRSTop to be the user's value, and LRSMax doesn't matter. - if self.LRS_LOD == 'LOD': + if self.LRS_LOD == 'LRS': lodm = self.LODFACTOR else: lodm = 1.0 if self.lrsMax <= 0: #sliding scale - if "lrs_value" in self.qtlresults[0]: - LRSMax = max([result['lrs_value'] for result in self.qtlresults]) + if "lod_score" in self.qtlresults[0]: + LRSMax = max([result['lod_score'] for result in self.qtlresults]) #LRSMax = max(map(max, self.qtlresults)).lrs_value else: - LRSMax = max([result['lod_score'] for result in self.qtlresults]) + LRSMax = max([result['lrs_value'] for result in self.qtlresults]) #LRSMax = max(map(max, self.qtlresults)).lod_score #genotype trait will give infinite LRS LRSMax = min(LRSMax, webqtlConfig.MAXLRS) @@ -1867,7 +1868,7 @@ class MarkerRegression(object): LRSScale = 2.5 else: LRSScale = 1.0 - + LRSAxisList = Plot.frange(LRSScale, LRSMax/lodm, LRSScale) #make sure the user's value appears on the y-axis #update by NL 6-21-2011: round the LOD value to 100 when LRSMax is equal to 460 @@ -2004,8 +2005,8 @@ class MarkerRegression(object): # Yc = yZero - qtlresult[m].dominance*DominanceHeightThresh/dominanceMax # DominanceCoordXY.append((Xc, Yc)) m += 1 - if self.manhattan_plot != True: - canvas.drawPolygon(LRSCoordXY,edgeColor=thisLRSColor,closed=0, edgeWidth=lrsEdgeWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth)) + + #canvas.drawPolygon(LRSCoordXY,edgeColor=thisLRSColor,closed=0, edgeWidth=lrsEdgeWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth)) lineWidth = 1 if not self.multipleInterval and self.additiveChecked: @@ -2068,7 +2069,8 @@ class MarkerRegression(object): canvas.drawLine(Xc0, yZero - (Yc0-yZero), Xc, yZero - (Yc-yZero), color=minusColor, width=lineWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth)) - #canvas.drawPolygon(LRSCoordXY,edgeColor=thisLRSColor,closed=0, edgeWidth=lrsEdgeWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth)) + if self.manhattan_plot != True: + canvas.drawPolygon(LRSCoordXY,edgeColor=thisLRSColor,closed=0, edgeWidth=lrsEdgeWidth, clipX=(xLeftOffset, xLeftOffset + plotWidth)) ###draw additive scale if not self.multipleInterval and self.additiveChecked: diff --git a/wqflask/wqflask/templates/marker_regression_gn1.html b/wqflask/wqflask/templates/marker_regression_gn1.html index 58478758..11989ae7 100644 --- a/wqflask/wqflask/templates/marker_regression_gn1.html +++ b/wqflask/wqflask/templates/marker_regression_gn1.html @@ -96,7 +96,6 @@ </div> </form> - {% if mapping_method != "gemma" %} <div style="width:48%;"> <h2> Results @@ -117,9 +116,7 @@ </tr> </thead> <tbody> - {% for marker in qtlresults %} - {% if (LRS_LOD == "LOD" and marker.lod_score|float > cutoff|float) or - (LRS_LOD == "LRS" and marker.lrs_value|float > cutoff|float) %} + {% for marker in trimmed_markers %} <tr> <td> <input type="checkbox" name="selectCheck" @@ -144,12 +141,10 @@ </a>--> </td> </tr> - {% endif %} {% endfor %} </tbody> </table> </div> - {% endif %} </div> <!-- End of body --> @@ -195,6 +190,7 @@ { "type": "natural" }, { "type": "natural", "sWidth": "30%"} ], + "order": [[1, "asc"]], "buttons": [ 'csv' ], diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 2af03f96..6f53a950 100755..100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -341,6 +341,7 @@ def marker_regression_page(): 'trait_id', 'dataset', 'method', + 'trimmed_markers', 'selected_chr', 'mapping_scale', 'score_type', |