diff options
author | DannyArends | 2016-03-28 18:32:27 +0200 |
---|---|---|
committer | Pjotr Prins | 2016-04-20 10:18:57 +0000 |
commit | 87a9aab9c830d267cb9c9adbb10856054e6e12cc (patch) | |
tree | 14e535479ea64ecab5e7ba3f0feb57bb812141b6 /wqflask | |
parent | 1053764068a50e2b95e0f0b07cb4111369ce8ff8 (diff) | |
download | genenetwork2-87a9aab9c830d267cb9c9adbb10856054e6e12cc.tar.gz |
Adding small figures per trait, so that users can see CTL and QTL for each individual phenotype
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/ctl/ctl_analysis.py | 35 | ||||
-rw-r--r-- | wqflask/wqflask/templates/ctl_results.html | 15 |
2 files changed, 39 insertions, 11 deletions
diff --git a/wqflask/wqflask/ctl/ctl_analysis.py b/wqflask/wqflask/ctl/ctl_analysis.py index 77e34143..45bc4c6e 100644 --- a/wqflask/wqflask/ctl/ctl_analysis.py +++ b/wqflask/wqflask/ctl/ctl_analysis.py @@ -69,9 +69,10 @@ class CTL(object): self.r_CTLscan = ro.r["CTLscan"] # Map the CTLscan function self.r_CTLsignificant = ro.r["CTLsignificant"] # Map the CTLsignificant function self.r_lineplot = ro.r["ctl.lineplot"] # Map the ctl.lineplot function + self.r_CTLsignificant = ro.r["CTLsignificant"] # Map the CTLsignificant function self.r_CTLnetwork = ro.r["CTLnetwork"] # Map the CTLnetwork function self.r_CTLprofiles = ro.r["CTLprofiles"] # Map the CTLprofiles function - self.r_CTLsignificant = ro.r["CTLsignificant"] # Map the CTLsignificant function + self.r_plotCTLobject = ro.r["plot.CTLobject"] # Map the CTLsignificant function print("Obtained pointers to CTL functions") def run_analysis(self, requestform): @@ -144,26 +145,44 @@ class CTL(object): # Create an image for output self.results = {} - self.results['imgurl'] = webqtlUtil.genRandStr("WGCNAoutput_") + ".png" - self.results['imgloc'] = GENERATED_IMAGE_DIR + self.results['imgurl'] + self.results['imgurl1'] = webqtlUtil.genRandStr("WGCNAoutput_") + ".png" + self.results['imgloc1'] = GENERATED_IMAGE_DIR + self.results['imgurl1'] + self.results['ctlresult'] = significant self.results['requestform'] = requestform # Store the user specified parameters for the output page # Create the lineplot - r_png(self.results['imgloc'], width=1000, height=600) + r_png(self.results['imgloc1'], width=1000, height=600) self.r_lineplot(res, significance = significance) r_dev_off() + n = 2 + for trait in self.trait_db_list: + # Create the QTL like CTL plots + self.results['imgurl' + str(n)] = webqtlUtil.genRandStr("WGCNAoutput_") + ".png" + self.results['imgloc' + str(n)] = GENERATED_IMAGE_DIR + self.results['imgurl' + str(n)] + r_png(self.results['imgloc' + str(n)], width=1000, height=600) + self.r_plotCTLobject(res, (n-1), significance = significance, main='Phenotype ' + trait) + r_dev_off() + n = n + 1 + # Flush any output from R sys.stdout.flush() - def render_image(self, results): - print("pre-loading imgage results:", self.results['imgloc']) - imgfile = open(self.results['imgloc'], 'rb') + def loadImage(self, path, name): + print("pre-loading imgage results:", self.results[path]) + imgfile = open(self.results[path], 'rb') imgdata = imgfile.read() imgB64 = imgdata.encode("base64") bytesarray = array.array('B', imgB64) - self.results['imgdata'] = bytesarray + self.results[name] = bytesarray + + def render_image(self, results): + self.loadImage("imgloc1", "imgdata1") + n = 2 + for trait in self.trait_db_list: + self.loadImage("imgloc" + str(n), "imgdata" + str(n)) + n = n + 1 def process_results(self, results): print("Processing CTL output") diff --git a/wqflask/wqflask/templates/ctl_results.html b/wqflask/wqflask/templates/ctl_results.html index 914c1d43..a5cb1c08 100644 --- a/wqflask/wqflask/templates/ctl_results.html +++ b/wqflask/wqflask/templates/ctl_results.html @@ -5,13 +5,22 @@ <div class="container"> <h1>CTL Results</h1> {{(request.form['trait_list'].split(',')|length -1)}} phenotypes as input<br> - <h3>Figure</h3> - <a href="/tmp/{{ results['imgurl'] }}"> + <h3>Network Figure</h3> + <a href="/tmp/{{ results['imgurl1'] }}"> <img alt="Embedded Image" src="data:image/png;base64, - {% for elem in results['imgdata'] -%} + {% for elem in results['imgdata1'] -%} {% print("%c"|format(elem)) %} {%- endfor %} " /></a> + <h3>CTL/QTL Plots for individual traits</h3> + {% for r in range(2, (request.form['trait_list'].split(',')|length +1)) %} + <a href="/tmp/{{ results['imgurl' + r|string] }}"> + <img width=100 height=100 alt="Embedded Image" src="data:image/png;base64, + {% for elem in results['imgdata' + r|string] -%} + {% print("%c"|format(elem)) %} + {%- endfor %} + " /></a> + {% endfor %} <h3>Tabular results</h3> <table width="80%"> <tr><th>trait</th><th>marker</th><th>trait</th><th>LOD</th><th>dCor</th></tr> |