From 4622a72a183864d8d085206f948bb67d94602982 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Tue, 7 Feb 2017 16:40:03 +0100 Subject: Adding a new panel to hold the upcomming PheWAS tools --- wqflask/wqflask/templates/show_trait.html | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index 59e0185e..e5500a7e 100644 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -92,12 +92,25 @@
-
+
+

+ PheWAS +

+
+
+
+ {% include 'show_trait_PheWAS_tools.html' %} +
+
+
+
+
+

Review and Edit Data

-
+
{% include 'show_trait_edit_data.html' %}
-- cgit v1.2.3 From 155b8d8f675d73bdd5b1850af8b67a8e57065fa2 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Tue, 7 Feb 2017 16:40:59 +0100 Subject: Initial empty file, this will hold the PheWAS tools at a later point in time --- wqflask/wqflask/templates/show_trait_PheWAS_tools.html | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 wqflask/wqflask/templates/show_trait_PheWAS_tools.html diff --git a/wqflask/wqflask/templates/show_trait_PheWAS_tools.html b/wqflask/wqflask/templates/show_trait_PheWAS_tools.html new file mode 100644 index 00000000..d3635e0d --- /dev/null +++ b/wqflask/wqflask/templates/show_trait_PheWAS_tools.html @@ -0,0 +1,3 @@ +
+PheWAS !!!! +
-- cgit v1.2.3 From 0fac25087a862c1b64505b247bf82c9cb48df5dc Mon Sep 17 00:00:00 2001 From: DannyArends Date: Tue, 7 Feb 2017 17:12:25 +0100 Subject: Adding an initial new trait page for a tabbed pane holding PheWAS, ePheWAS and Mediation --- .../wqflask/templates/show_trait_PheWAS_tools.html | 92 +++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/wqflask/wqflask/templates/show_trait_PheWAS_tools.html b/wqflask/wqflask/templates/show_trait_PheWAS_tools.html index d3635e0d..06922f05 100644 --- a/wqflask/wqflask/templates/show_trait_PheWAS_tools.html +++ b/wqflask/wqflask/templates/show_trait_PheWAS_tools.html @@ -1,3 +1,93 @@
-PheWAS !!!! +
+
+ + +
+
-- cgit v1.2.3 From 492a35ef6a94f04f0792ac2e9b2f90e8ad9af24a Mon Sep 17 00:00:00 2001 From: DannyArends Date: Tue, 7 Feb 2017 18:47:09 +0100 Subject: Templated html to show the PheWAS analysis input options on the trait page --- wqflask/wqflask/templates/show_trait_PheWAS_tools.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wqflask/wqflask/templates/show_trait_PheWAS_tools.html b/wqflask/wqflask/templates/show_trait_PheWAS_tools.html index 06922f05..ee4c5f5a 100644 --- a/wqflask/wqflask/templates/show_trait_PheWAS_tools.html +++ b/wqflask/wqflask/templates/show_trait_PheWAS_tools.html @@ -40,7 +40,7 @@
-
-- cgit v1.2.3 From 4b70f5d556824fd342090359968bce12496a0299 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Tue, 7 Feb 2017 18:47:29 +0100 Subject: Added a new route for the PheWAS results --- wqflask/wqflask/views.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 33fab84d..935304da 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -246,6 +246,11 @@ def wcgna_results(): result = wgcna.process_results(wgcnaA) # After the analysis is finished store the result return render_template("wgcna_results.html", **result) # Display them using the template +@app.route("/phewas", methods=('POST',)) +def phewas(): + logger.info("In phewas, request.form is:", request.form) # We are going to get additional user input for the analysis + return render_template("phewas_analysis.html", **request.form) # Display them using the template + @app.route("/ctl_setup", methods=('POST',)) def ctl_setup(): logger.info("In ctl, request.form is:", request.form) # We are going to get additional user input for the analysis -- cgit v1.2.3 From 9956fcf4dde07131756ff4eb3269a1e94d805235 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Tue, 7 Feb 2017 18:48:07 +0100 Subject: Inital python code to do PheWAS analysis from R --- wqflask/wqflask/phewas/phewas.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 wqflask/wqflask/phewas/phewas.py diff --git a/wqflask/wqflask/phewas/phewas.py b/wqflask/wqflask/phewas/phewas.py new file mode 100644 index 00000000..399e056c --- /dev/null +++ b/wqflask/wqflask/phewas/phewas.py @@ -0,0 +1,40 @@ +# PheWAS analysis for GN2 +# Author / Maintainer: Li Hao & Danny Arends +import sys +from numpy import * +import scipy as sp # SciPy +import rpy2.robjects as ro # R Objects +import rpy2.rinterface as ri + +from base.webqtlConfig import GENERATED_IMAGE_DIR +from utility import webqtlUtil # Random number for the image +from utility import genofile_parser # genofile_parser + +import base64 +import array +import csv +import itertools + +from base import data_set +from base import trait as TRAIT + +from utility import helper_functions +from utility.tools import locate + +from rpy2.robjects.packages import importr +utils = importr("utils") + +class PheWAS(object): + def __init__(self): + print("Initialization of PheWAS") + print("Initialization of PheWAS done !") + + def run_analysis(self, requestform): + print("Starting PheWAS analysis on dataset") + print("Initialization of PheWAS done !") + + def process_results(self, results): + print("Processing PheWAS output") + template_vars = {} + return(dict(template_vars)) + -- cgit v1.2.3 From 87c5711dc12a62974838b5e4dbd4393356b4dcb2 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Tue, 7 Feb 2017 18:48:33 +0100 Subject: empty output template to show the results from PheWAS analysis --- wqflask/wqflask/templates/phewas_analysis.html | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 wqflask/wqflask/templates/phewas_analysis.html diff --git a/wqflask/wqflask/templates/phewas_analysis.html b/wqflask/wqflask/templates/phewas_analysis.html new file mode 100644 index 00000000..ac163b43 --- /dev/null +++ b/wqflask/wqflask/templates/phewas_analysis.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} +{% block title %}CTL analysis{% endblock %} + +{% block content %} +
+ YAY ! We have our own route +
+{% endblock %} -- cgit v1.2.3 From 317eb5cfb23b3cb5979eb1eb516cacf086b09a44 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Wed, 8 Feb 2017 09:31:38 +0100 Subject: Adding stub display templates for all 3 analysis tools --- wqflask/wqflask/auwerx/ephewas.py | 40 ++++++++++++++++++++++ wqflask/wqflask/auwerx/mediation.py | 40 ++++++++++++++++++++++ wqflask/wqflask/auwerx/phewas.py | 40 ++++++++++++++++++++++ wqflask/wqflask/phewas/phewas.py | 40 ---------------------- wqflask/wqflask/templates/ephewas_analysis.html | 9 +++++ wqflask/wqflask/templates/mediation_analysis.html | 9 +++++ wqflask/wqflask/templates/phewas_analysis.html | 3 +- .../wqflask/templates/show_trait_PheWAS_tools.html | 8 ++--- 8 files changed, 144 insertions(+), 45 deletions(-) create mode 100644 wqflask/wqflask/auwerx/ephewas.py create mode 100644 wqflask/wqflask/auwerx/mediation.py create mode 100644 wqflask/wqflask/auwerx/phewas.py delete mode 100644 wqflask/wqflask/phewas/phewas.py create mode 100644 wqflask/wqflask/templates/ephewas_analysis.html create mode 100644 wqflask/wqflask/templates/mediation_analysis.html diff --git a/wqflask/wqflask/auwerx/ephewas.py b/wqflask/wqflask/auwerx/ephewas.py new file mode 100644 index 00000000..edfb2801 --- /dev/null +++ b/wqflask/wqflask/auwerx/ephewas.py @@ -0,0 +1,40 @@ +# PheWAS analysis for GN2 +# Author / Maintainer: Li Hao & Danny Arends +import sys +from numpy import * +import scipy as sp # SciPy +import rpy2.robjects as ro # R Objects +import rpy2.rinterface as ri + +from base.webqtlConfig import GENERATED_IMAGE_DIR +from utility import webqtlUtil # Random number for the image +from utility import genofile_parser # genofile_parser + +import base64 +import array +import csv +import itertools + +from base import data_set +from base import trait as TRAIT + +from utility import helper_functions +from utility.tools import locate + +from rpy2.robjects.packages import importr +utils = importr("utils") + +class EPheWAS(object): + def __init__(self): + print("Initialization of ePheWAS") + print("Initialization of ePheWAS done !") + + def run_analysis(self, requestform): + print("Starting ePheWAS analysis on dataset") + print("Initialization of ePheWAS done !") + + def process_results(self, results): + print("Processing ePheWAS output") + template_vars = {} + return(dict(template_vars)) + diff --git a/wqflask/wqflask/auwerx/mediation.py b/wqflask/wqflask/auwerx/mediation.py new file mode 100644 index 00000000..48d02dc2 --- /dev/null +++ b/wqflask/wqflask/auwerx/mediation.py @@ -0,0 +1,40 @@ +# PheWAS analysis for GN2 +# Author / Maintainer: Li Hao & Danny Arends +import sys +from numpy import * +import scipy as sp # SciPy +import rpy2.robjects as ro # R Objects +import rpy2.rinterface as ri + +from base.webqtlConfig import GENERATED_IMAGE_DIR +from utility import webqtlUtil # Random number for the image +from utility import genofile_parser # genofile_parser + +import base64 +import array +import csv +import itertools + +from base import data_set +from base import trait as TRAIT + +from utility import helper_functions +from utility.tools import locate + +from rpy2.robjects.packages import importr +utils = importr("utils") + +class Mediation(object): + def __init__(self): + print("Initialization of Mediation") + print("Initialization of Mediation done !") + + def run_analysis(self, requestform): + print("Starting Mediation analysis on dataset") + print("Initialization of Mediation done !") + + def process_results(self, results): + print("Processing Mediation output") + template_vars = {} + return(dict(template_vars)) + diff --git a/wqflask/wqflask/auwerx/phewas.py b/wqflask/wqflask/auwerx/phewas.py new file mode 100644 index 00000000..399e056c --- /dev/null +++ b/wqflask/wqflask/auwerx/phewas.py @@ -0,0 +1,40 @@ +# PheWAS analysis for GN2 +# Author / Maintainer: Li Hao & Danny Arends +import sys +from numpy import * +import scipy as sp # SciPy +import rpy2.robjects as ro # R Objects +import rpy2.rinterface as ri + +from base.webqtlConfig import GENERATED_IMAGE_DIR +from utility import webqtlUtil # Random number for the image +from utility import genofile_parser # genofile_parser + +import base64 +import array +import csv +import itertools + +from base import data_set +from base import trait as TRAIT + +from utility import helper_functions +from utility.tools import locate + +from rpy2.robjects.packages import importr +utils = importr("utils") + +class PheWAS(object): + def __init__(self): + print("Initialization of PheWAS") + print("Initialization of PheWAS done !") + + def run_analysis(self, requestform): + print("Starting PheWAS analysis on dataset") + print("Initialization of PheWAS done !") + + def process_results(self, results): + print("Processing PheWAS output") + template_vars = {} + return(dict(template_vars)) + diff --git a/wqflask/wqflask/phewas/phewas.py b/wqflask/wqflask/phewas/phewas.py deleted file mode 100644 index 399e056c..00000000 --- a/wqflask/wqflask/phewas/phewas.py +++ /dev/null @@ -1,40 +0,0 @@ -# PheWAS analysis for GN2 -# Author / Maintainer: Li Hao & Danny Arends -import sys -from numpy import * -import scipy as sp # SciPy -import rpy2.robjects as ro # R Objects -import rpy2.rinterface as ri - -from base.webqtlConfig import GENERATED_IMAGE_DIR -from utility import webqtlUtil # Random number for the image -from utility import genofile_parser # genofile_parser - -import base64 -import array -import csv -import itertools - -from base import data_set -from base import trait as TRAIT - -from utility import helper_functions -from utility.tools import locate - -from rpy2.robjects.packages import importr -utils = importr("utils") - -class PheWAS(object): - def __init__(self): - print("Initialization of PheWAS") - print("Initialization of PheWAS done !") - - def run_analysis(self, requestform): - print("Starting PheWAS analysis on dataset") - print("Initialization of PheWAS done !") - - def process_results(self, results): - print("Processing PheWAS output") - template_vars = {} - return(dict(template_vars)) - diff --git a/wqflask/wqflask/templates/ephewas_analysis.html b/wqflask/wqflask/templates/ephewas_analysis.html new file mode 100644 index 00000000..d5e71fa7 --- /dev/null +++ b/wqflask/wqflask/templates/ephewas_analysis.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} +{% block title %}ePheWAS analysis{% endblock %} + +{% block content %} +
+

ePheWAS analysis results

+ YAY ! We have our own route +
+{% endblock %} diff --git a/wqflask/wqflask/templates/mediation_analysis.html b/wqflask/wqflask/templates/mediation_analysis.html new file mode 100644 index 00000000..ee5a5016 --- /dev/null +++ b/wqflask/wqflask/templates/mediation_analysis.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} +{% block title %}Mediation analysis{% endblock %} + +{% block content %} +
+

Mediation analysis results

+ YAY ! We have our own route +
+{% endblock %} diff --git a/wqflask/wqflask/templates/phewas_analysis.html b/wqflask/wqflask/templates/phewas_analysis.html index ac163b43..2b04d85b 100644 --- a/wqflask/wqflask/templates/phewas_analysis.html +++ b/wqflask/wqflask/templates/phewas_analysis.html @@ -1,8 +1,9 @@ {% extends "base.html" %} -{% block title %}CTL analysis{% endblock %} +{% block title %}PheWAS analysis{% endblock %} {% block content %}
+

PheWAS analysis results

YAY ! We have our own route
{% endblock %} diff --git a/wqflask/wqflask/templates/show_trait_PheWAS_tools.html b/wqflask/wqflask/templates/show_trait_PheWAS_tools.html index ee4c5f5a..d8193652 100644 --- a/wqflask/wqflask/templates/show_trait_PheWAS_tools.html +++ b/wqflask/wqflask/templates/show_trait_PheWAS_tools.html @@ -40,7 +40,7 @@
-
@@ -59,7 +59,7 @@
-
@@ -78,13 +78,13 @@
-
-
+
-- cgit v1.2.3 From 7315884db2675b2375d1c53587f58089c28d490d Mon Sep 17 00:00:00 2001 From: DannyArends Date: Wed, 8 Feb 2017 09:31:57 +0100 Subject: Adding routes for all 3 analysis tools --- wqflask/wqflask/views.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 935304da..91e2ffb2 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -251,6 +251,16 @@ def phewas(): logger.info("In phewas, request.form is:", request.form) # We are going to get additional user input for the analysis return render_template("phewas_analysis.html", **request.form) # Display them using the template +@app.route("/ephewas", methods=('POST',)) +def ephewas(): + logger.info("In ephewas, request.form is:", request.form) # We are going to get additional user input for the analysis + return render_template("ephewas_analysis.html", **request.form) # Display them using the template + +@app.route("/mediation", methods=('POST',)) +def mediation(): + logger.info("In mediation, request.form is:", request.form) # We are going to get additional user input for the analysis + return render_template("mediation_analysis.html", **request.form) # Display them using the template + @app.route("/ctl_setup", methods=('POST',)) def ctl_setup(): logger.info("In ctl, request.form is:", request.form) # We are going to get additional user input for the analysis -- cgit v1.2.3 From 3af320e379c7053b6a5232a895193c1d058192c3 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Wed, 8 Feb 2017 09:33:12 +0100 Subject: Deadly Sin #1 changing the javascript without touching the coffeescript which generates this javascript, since we're down the rabbit hole aready I'm just gonna join. CHristian will try n figure out how deep the rabbit hole goes. --- .../static/new/javascript/show_trait_mapping_tools.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js index e9db0a12..a02fdb32 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js +++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js @@ -220,6 +220,25 @@ }; })(this)); + + $("#phewas_compute").on("click", (function(_this) { + return function() { + return submit_special("/phewas"); + }; + })(this)); + + $("#ephewas_compute").on("click", (function(_this) { + return function() { + return submit_special("/ephewas"); + }; + })(this)); + + $("#mediation_compute").on("click", (function(_this) { + return function() { + return submit_special("/mediation"); + }; + })(this)); + $("#gemma_compute").on("click", (function(_this) { return function() { var form_data, url; -- cgit v1.2.3 From e17ad8ac7b41ae79da2d4081d52686cef0e287b3 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Wed, 8 Feb 2017 09:47:47 +0100 Subject: Renamed the analysis code files to include the word analysis to not conflict with the routes in views.py --- wqflask/wqflask/auwerx/__init__.py | 0 wqflask/wqflask/auwerx/ephewas.py | 40 ---------------------------- wqflask/wqflask/auwerx/ephewas_analysis.py | 40 ++++++++++++++++++++++++++++ wqflask/wqflask/auwerx/mediation.py | 40 ---------------------------- wqflask/wqflask/auwerx/mediation_analysis.py | 40 ++++++++++++++++++++++++++++ wqflask/wqflask/auwerx/phewas.py | 40 ---------------------------- wqflask/wqflask/auwerx/phewas_analysis.py | 40 ++++++++++++++++++++++++++++ wqflask/wqflask/views.py | 6 ++++- 8 files changed, 125 insertions(+), 121 deletions(-) create mode 100644 wqflask/wqflask/auwerx/__init__.py delete mode 100644 wqflask/wqflask/auwerx/ephewas.py create mode 100644 wqflask/wqflask/auwerx/ephewas_analysis.py delete mode 100644 wqflask/wqflask/auwerx/mediation.py create mode 100644 wqflask/wqflask/auwerx/mediation_analysis.py delete mode 100644 wqflask/wqflask/auwerx/phewas.py create mode 100644 wqflask/wqflask/auwerx/phewas_analysis.py diff --git a/wqflask/wqflask/auwerx/__init__.py b/wqflask/wqflask/auwerx/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/wqflask/wqflask/auwerx/ephewas.py b/wqflask/wqflask/auwerx/ephewas.py deleted file mode 100644 index edfb2801..00000000 --- a/wqflask/wqflask/auwerx/ephewas.py +++ /dev/null @@ -1,40 +0,0 @@ -# PheWAS analysis for GN2 -# Author / Maintainer: Li Hao & Danny Arends -import sys -from numpy import * -import scipy as sp # SciPy -import rpy2.robjects as ro # R Objects -import rpy2.rinterface as ri - -from base.webqtlConfig import GENERATED_IMAGE_DIR -from utility import webqtlUtil # Random number for the image -from utility import genofile_parser # genofile_parser - -import base64 -import array -import csv -import itertools - -from base import data_set -from base import trait as TRAIT - -from utility import helper_functions -from utility.tools import locate - -from rpy2.robjects.packages import importr -utils = importr("utils") - -class EPheWAS(object): - def __init__(self): - print("Initialization of ePheWAS") - print("Initialization of ePheWAS done !") - - def run_analysis(self, requestform): - print("Starting ePheWAS analysis on dataset") - print("Initialization of ePheWAS done !") - - def process_results(self, results): - print("Processing ePheWAS output") - template_vars = {} - return(dict(template_vars)) - diff --git a/wqflask/wqflask/auwerx/ephewas_analysis.py b/wqflask/wqflask/auwerx/ephewas_analysis.py new file mode 100644 index 00000000..edfb2801 --- /dev/null +++ b/wqflask/wqflask/auwerx/ephewas_analysis.py @@ -0,0 +1,40 @@ +# PheWAS analysis for GN2 +# Author / Maintainer: Li Hao & Danny Arends +import sys +from numpy import * +import scipy as sp # SciPy +import rpy2.robjects as ro # R Objects +import rpy2.rinterface as ri + +from base.webqtlConfig import GENERATED_IMAGE_DIR +from utility import webqtlUtil # Random number for the image +from utility import genofile_parser # genofile_parser + +import base64 +import array +import csv +import itertools + +from base import data_set +from base import trait as TRAIT + +from utility import helper_functions +from utility.tools import locate + +from rpy2.robjects.packages import importr +utils = importr("utils") + +class EPheWAS(object): + def __init__(self): + print("Initialization of ePheWAS") + print("Initialization of ePheWAS done !") + + def run_analysis(self, requestform): + print("Starting ePheWAS analysis on dataset") + print("Initialization of ePheWAS done !") + + def process_results(self, results): + print("Processing ePheWAS output") + template_vars = {} + return(dict(template_vars)) + diff --git a/wqflask/wqflask/auwerx/mediation.py b/wqflask/wqflask/auwerx/mediation.py deleted file mode 100644 index 48d02dc2..00000000 --- a/wqflask/wqflask/auwerx/mediation.py +++ /dev/null @@ -1,40 +0,0 @@ -# PheWAS analysis for GN2 -# Author / Maintainer: Li Hao & Danny Arends -import sys -from numpy import * -import scipy as sp # SciPy -import rpy2.robjects as ro # R Objects -import rpy2.rinterface as ri - -from base.webqtlConfig import GENERATED_IMAGE_DIR -from utility import webqtlUtil # Random number for the image -from utility import genofile_parser # genofile_parser - -import base64 -import array -import csv -import itertools - -from base import data_set -from base import trait as TRAIT - -from utility import helper_functions -from utility.tools import locate - -from rpy2.robjects.packages import importr -utils = importr("utils") - -class Mediation(object): - def __init__(self): - print("Initialization of Mediation") - print("Initialization of Mediation done !") - - def run_analysis(self, requestform): - print("Starting Mediation analysis on dataset") - print("Initialization of Mediation done !") - - def process_results(self, results): - print("Processing Mediation output") - template_vars = {} - return(dict(template_vars)) - diff --git a/wqflask/wqflask/auwerx/mediation_analysis.py b/wqflask/wqflask/auwerx/mediation_analysis.py new file mode 100644 index 00000000..48d02dc2 --- /dev/null +++ b/wqflask/wqflask/auwerx/mediation_analysis.py @@ -0,0 +1,40 @@ +# PheWAS analysis for GN2 +# Author / Maintainer: Li Hao & Danny Arends +import sys +from numpy import * +import scipy as sp # SciPy +import rpy2.robjects as ro # R Objects +import rpy2.rinterface as ri + +from base.webqtlConfig import GENERATED_IMAGE_DIR +from utility import webqtlUtil # Random number for the image +from utility import genofile_parser # genofile_parser + +import base64 +import array +import csv +import itertools + +from base import data_set +from base import trait as TRAIT + +from utility import helper_functions +from utility.tools import locate + +from rpy2.robjects.packages import importr +utils = importr("utils") + +class Mediation(object): + def __init__(self): + print("Initialization of Mediation") + print("Initialization of Mediation done !") + + def run_analysis(self, requestform): + print("Starting Mediation analysis on dataset") + print("Initialization of Mediation done !") + + def process_results(self, results): + print("Processing Mediation output") + template_vars = {} + return(dict(template_vars)) + diff --git a/wqflask/wqflask/auwerx/phewas.py b/wqflask/wqflask/auwerx/phewas.py deleted file mode 100644 index 399e056c..00000000 --- a/wqflask/wqflask/auwerx/phewas.py +++ /dev/null @@ -1,40 +0,0 @@ -# PheWAS analysis for GN2 -# Author / Maintainer: Li Hao & Danny Arends -import sys -from numpy import * -import scipy as sp # SciPy -import rpy2.robjects as ro # R Objects -import rpy2.rinterface as ri - -from base.webqtlConfig import GENERATED_IMAGE_DIR -from utility import webqtlUtil # Random number for the image -from utility import genofile_parser # genofile_parser - -import base64 -import array -import csv -import itertools - -from base import data_set -from base import trait as TRAIT - -from utility import helper_functions -from utility.tools import locate - -from rpy2.robjects.packages import importr -utils = importr("utils") - -class PheWAS(object): - def __init__(self): - print("Initialization of PheWAS") - print("Initialization of PheWAS done !") - - def run_analysis(self, requestform): - print("Starting PheWAS analysis on dataset") - print("Initialization of PheWAS done !") - - def process_results(self, results): - print("Processing PheWAS output") - template_vars = {} - return(dict(template_vars)) - diff --git a/wqflask/wqflask/auwerx/phewas_analysis.py b/wqflask/wqflask/auwerx/phewas_analysis.py new file mode 100644 index 00000000..399e056c --- /dev/null +++ b/wqflask/wqflask/auwerx/phewas_analysis.py @@ -0,0 +1,40 @@ +# PheWAS analysis for GN2 +# Author / Maintainer: Li Hao & Danny Arends +import sys +from numpy import * +import scipy as sp # SciPy +import rpy2.robjects as ro # R Objects +import rpy2.rinterface as ri + +from base.webqtlConfig import GENERATED_IMAGE_DIR +from utility import webqtlUtil # Random number for the image +from utility import genofile_parser # genofile_parser + +import base64 +import array +import csv +import itertools + +from base import data_set +from base import trait as TRAIT + +from utility import helper_functions +from utility.tools import locate + +from rpy2.robjects.packages import importr +utils = importr("utils") + +class PheWAS(object): + def __init__(self): + print("Initialization of PheWAS") + print("Initialization of PheWAS done !") + + def run_analysis(self, requestform): + print("Starting PheWAS analysis on dataset") + print("Initialization of PheWAS done !") + + def process_results(self, results): + print("Processing PheWAS output") + template_vars = {} + return(dict(template_vars)) + diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 91e2ffb2..047982bf 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -49,6 +49,7 @@ from wqflask.correlation_matrix import show_corr_matrix from wqflask.correlation import corr_scatter_plot from wqflask.wgcna import wgcna_analysis from wqflask.ctl import ctl_analysis +from wqflask.auwerx import phewas_analysis from utility import temp_data from utility.tools import SQL_URI,TEMPDIR,USE_REDIS,USE_GN_SERVER,GN_SERVER_URL @@ -249,7 +250,10 @@ def wcgna_results(): @app.route("/phewas", methods=('POST',)) def phewas(): logger.info("In phewas, request.form is:", request.form) # We are going to get additional user input for the analysis - return render_template("phewas_analysis.html", **request.form) # Display them using the template + phewasO = phewas_analysis.PheWAS() # Start R, load the package and pointers and create the analysis + phewasA = phewasO.run_analysis(request.form) + result = phewasO.process_results(phewasA) # After the analysis is finished store the result + return render_template("phewas_analysis.html", **result) # Display them using the template @app.route("/ephewas", methods=('POST',)) def ephewas(): -- cgit v1.2.3 From c3e000f8a36e501fdaefa997105cdf30f21eba81 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Wed, 8 Feb 2017 12:11:33 +0100 Subject: Adding the analysis structure of the PheWAS analysis in the python code, it's all stubs not working and crashing atm --- wqflask/wqflask/auwerx/phewas_analysis.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/wqflask/wqflask/auwerx/phewas_analysis.py b/wqflask/wqflask/auwerx/phewas_analysis.py index 399e056c..c69326ed 100644 --- a/wqflask/wqflask/auwerx/phewas_analysis.py +++ b/wqflask/wqflask/auwerx/phewas_analysis.py @@ -21,16 +21,30 @@ from base import trait as TRAIT from utility import helper_functions from utility.tools import locate -from rpy2.robjects.packages import importr -utils = importr("utils") +r_library = ro.r["library"] # Map the library function +r_options = ro.r["options"] # Map the options function class PheWAS(object): def __init__(self): print("Initialization of PheWAS") + r_library("auwerx") # Load the auwerx package - Should only be done once, since it is quite expensive + r_options(stringsAsFactors = False) + # Create the aligners + r_download_BXD_geno = ro.r["download.BXD.geno"] # Map the create.Pheno_aligner function + r_create_Pheno_aligner = ro.r["create.Pheno_aligner"] # Map the create.Pheno_aligner function + r_create_SNP_aligner = ro.r["create.SNP_aligner"] # Map the create.SNP_aligner function + r_calculate_all_pvalue_parallel = ro.r["calculate.all.pvalue.parallel"] # Map the calculate.all.pvalue.parallel function + r_PheWASManhattan = ro.r["PheWASManhattan"] # Map the PheWASManhattan function print("Initialization of PheWAS done !") def run_analysis(self, requestform): print("Starting PheWAS analysis on dataset") + bxdgeno = r_download_BXD_geno() + snpaligner = r_create_SNP_aligner(bxdgeno) + phenoaligner = r_create_Pheno_aligner() + allpvalues = r_calculate_all_pvalue_parallel() # This needs some magic to work I think + # trait chromosome and trait positions should come from the user input + r_PheWASManhattan(None, allpvalues, phenoaligner, snpaligner, None, trait_chr, trait_pos, trait_pos ) print("Initialization of PheWAS done !") def process_results(self, results): -- cgit v1.2.3 From 2a95956dcb8aaef7d5f8668c5c226f139dc832c8 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Thu, 9 Feb 2017 14:03:19 +0100 Subject: Initial code that allows us to run the PheWAS tool, using pre-computed data, still a lot of TODO's left --- wqflask/wqflask/auwerx/phewas_analysis.py | 52 ++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/wqflask/wqflask/auwerx/phewas_analysis.py b/wqflask/wqflask/auwerx/phewas_analysis.py index c69326ed..061d2bc8 100644 --- a/wqflask/wqflask/auwerx/phewas_analysis.py +++ b/wqflask/wqflask/auwerx/phewas_analysis.py @@ -23,32 +23,56 @@ from utility.tools import locate r_library = ro.r["library"] # Map the library function r_options = ro.r["options"] # Map the options function +r_load = ro.r["load"] # Map the load function +r_write_table = ro.r["write.table"] # Map the write.table function +r_head = ro.r["head"] # Map the head function +r_colnames = ro.r["colnames"] # Map the colnames function +r_list = ro.r["list"] # Map the list function +r_c = ro.r["c"] # Map the c (combine) function +r_rep = ro.r["rep"] # Map the rep (repeat) function class PheWAS(object): def __init__(self): print("Initialization of PheWAS") - r_library("auwerx") # Load the auwerx package - Should only be done once, since it is quite expensive - r_options(stringsAsFactors = False) - # Create the aligners - r_download_BXD_geno = ro.r["download.BXD.geno"] # Map the create.Pheno_aligner function - r_create_Pheno_aligner = ro.r["create.Pheno_aligner"] # Map the create.Pheno_aligner function - r_create_SNP_aligner = ro.r["create.SNP_aligner"] # Map the create.SNP_aligner function - r_calculate_all_pvalue_parallel = ro.r["calculate.all.pvalue.parallel"] # Map the calculate.all.pvalue.parallel function - r_PheWASManhattan = ro.r["PheWASManhattan"] # Map the PheWASManhattan function + # TODO: Loading the package should only be done once, since it is quite expensive + print(r_library("auwerx")) # Load the auwerx package + self.r_download_BXD_geno = ro.r["download.BXD.geno"] # Map the create.Pheno_aligner function + self.r_create_Pheno_aligner = ro.r["create.Pheno_aligner"] # Map the create.Pheno_aligner function + self.r_create_SNP_aligner = ro.r["create.SNP_aligner"] # Map the create.SNP_aligner function + self.r_calculate_all_pvalue_parallel = ro.r["calculate.all.pvalue.parallel"] # Map the calculate.all.pvalue.parallel function + self.r_PheWASManhattan = ro.r["PheWASManhattan"] # Map the PheWASManhattan function print("Initialization of PheWAS done !") def run_analysis(self, requestform): print("Starting PheWAS analysis on dataset") - bxdgeno = r_download_BXD_geno() - snpaligner = r_create_SNP_aligner(bxdgeno) - phenoaligner = r_create_Pheno_aligner() - allpvalues = r_calculate_all_pvalue_parallel() # This needs some magic to work I think - # trait chromosome and trait positions should come from the user input - r_PheWASManhattan(None, allpvalues, phenoaligner, snpaligner, None, trait_chr, trait_pos, trait_pos ) + genofilelocation = locate("BXD.geno", "genotype") # Get the location of the BXD genotypes + precompfilelocation = locate("PheWAS_pval_EMMA_norm.RData", "auwerx") # Get the location of the pre-computed EMMA results + + parser = genofile_parser.ConvertGenoFile(genofilelocation) + parser.process_csv() + snpinfo = [] + for marker in parser.markers: + snpinfo.append(marker["name"]); + snpinfo.append(marker["chr"]); + snpinfo.append(marker["Mb"]); + + rnames = r_rep(1, len(parser.markers)) + # Create the snp aligner object out of the BXD genotypes + snpaligner = ro.r.matrix(snpinfo, nrow=len(parser.markers), dimnames = r_list(rnames, r_c("SNP", "Chr", "Pos")), ncol = 3, byrow=True) + # Create the phenotype aligner object using R + phenoaligner = self.r_create_Pheno_aligner() + + r_load(precompfilelocation) # Load the pre-computed EMMA results into R + allpvalues = ro.r['pval_all'] # Get a pointer to the pre-computed results + + # Create the PheWAS plot (The gene/probe name, chromosome and gene/probe positions should come from the user input) + # TODO: generate the PDF in the temp folder, with a unique name + self.r_PheWASManhattan("1:25", allpvalues, phenoaligner, snpaligner, "1:25", 1, 25, 25 ) print("Initialization of PheWAS done !") def process_results(self, results): print("Processing PheWAS output") + # TODO: get the PDF in the temp folder, and display it to the user template_vars = {} return(dict(template_vars)) -- cgit v1.2.3 From 5da1eab7ccbc1f6913032cf510ca93e4ecfce5b1 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Fri, 10 Feb 2017 11:47:58 +0100 Subject: Working PheWAS in GN2, only for chromosome 1 on 25 megabases, but it's a start --- wqflask/wqflask/auwerx/phewas_analysis.py | 39 ++++++++++++++++++++------ wqflask/wqflask/templates/phewas_analysis.html | 8 +++++- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/wqflask/wqflask/auwerx/phewas_analysis.py b/wqflask/wqflask/auwerx/phewas_analysis.py index 061d2bc8..db12ad98 100644 --- a/wqflask/wqflask/auwerx/phewas_analysis.py +++ b/wqflask/wqflask/auwerx/phewas_analysis.py @@ -23,24 +23,24 @@ from utility.tools import locate r_library = ro.r["library"] # Map the library function r_options = ro.r["options"] # Map the options function -r_load = ro.r["load"] # Map the load function r_write_table = ro.r["write.table"] # Map the write.table function r_head = ro.r["head"] # Map the head function +r_load = ro.r["load"] # Map the head function r_colnames = ro.r["colnames"] # Map the colnames function r_list = ro.r["list"] # Map the list function r_c = ro.r["c"] # Map the c (combine) function -r_rep = ro.r["rep"] # Map the rep (repeat) function +r_seq = ro.r["seq"] # Map the rep (repeat) function class PheWAS(object): def __init__(self): print("Initialization of PheWAS") # TODO: Loading the package should only be done once, since it is quite expensive print(r_library("auwerx")) # Load the auwerx package - self.r_download_BXD_geno = ro.r["download.BXD.geno"] # Map the create.Pheno_aligner function self.r_create_Pheno_aligner = ro.r["create.Pheno_aligner"] # Map the create.Pheno_aligner function - self.r_create_SNP_aligner = ro.r["create.SNP_aligner"] # Map the create.SNP_aligner function self.r_calculate_all_pvalue_parallel = ro.r["calculate.all.pvalue.parallel"] # Map the calculate.all.pvalue.parallel function self.r_PheWASManhattan = ro.r["PheWASManhattan"] # Map the PheWASManhattan function + self.r_Stop = ro.r["throwStopError"] # Map the PheWASManhattan function + self.r_PyLoadData = ro.r["PyLoadData"] # Map the load function print("Initialization of PheWAS done !") def run_analysis(self, requestform): @@ -56,23 +56,46 @@ class PheWAS(object): snpinfo.append(marker["chr"]); snpinfo.append(marker["Mb"]); - rnames = r_rep(1, len(parser.markers)) + rnames = r_seq(1, len(parser.markers)) # Create the snp aligner object out of the BXD genotypes snpaligner = ro.r.matrix(snpinfo, nrow=len(parser.markers), dimnames = r_list(rnames, r_c("SNP", "Chr", "Pos")), ncol = 3, byrow=True) + r_write_table(snpaligner, "~/snpaligner_GN2.txt", row_names=False) + # Create the phenotype aligner object using R phenoaligner = self.r_create_Pheno_aligner() - r_load(precompfilelocation) # Load the pre-computed EMMA results into R - allpvalues = ro.r['pval_all'] # Get a pointer to the pre-computed results + #r_load(precompfilelocation) # Load the pre-computed EMMA results into R + #allpvalues = ro.r['pval_small'] # Get a pointer to the pre-computed results + self.results = {} + self.results['imgurl1'] = webqtlUtil.genRandStr("phewas_") + ".png" + self.results['imgloc1'] = GENERATED_IMAGE_DIR + self.results['imgurl1'] + print("IMAGE AT:", self.results['imgurl1'] ) + print("IMAGE AT:", self.results['imgloc1'] ) # Create the PheWAS plot (The gene/probe name, chromosome and gene/probe positions should come from the user input) # TODO: generate the PDF in the temp folder, with a unique name - self.r_PheWASManhattan("1:25", allpvalues, phenoaligner, snpaligner, "1:25", 1, 25, 25 ) + self.r_PheWASManhattan("Test", precompfilelocation, phenoaligner, snpaligner, "None", 1, 25, 25, self.results['imgloc1'] ) + #self.r_PheWASManhattan(allpvalues) + #self.r_Stop() + print("Initialization of PheWAS done !") + 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[name] = bytesarray + + def render_image(self, results): + self.loadImage("imgloc1", "imgdata1") + def process_results(self, results): print("Processing PheWAS output") # TODO: get the PDF in the temp folder, and display it to the user template_vars = {} + template_vars["results"] = self.results + self.render_image(self.results) return(dict(template_vars)) diff --git a/wqflask/wqflask/templates/phewas_analysis.html b/wqflask/wqflask/templates/phewas_analysis.html index 2b04d85b..f72564ae 100644 --- a/wqflask/wqflask/templates/phewas_analysis.html +++ b/wqflask/wqflask/templates/phewas_analysis.html @@ -4,6 +4,12 @@ {% block content %}

PheWAS analysis results

- YAY ! We have our own route + YAY ! We have our own route
+ + Embedded Image
{% endblock %} -- cgit v1.2.3 From 08837f2688602fb1bae231d3794eac3d87184e86 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Thu, 16 Feb 2017 19:01:05 +0100 Subject: Phewas output table code in python --- wqflask/wqflask/auwerx/phewas_analysis.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wqflask/wqflask/auwerx/phewas_analysis.py b/wqflask/wqflask/auwerx/phewas_analysis.py index db12ad98..a745b12d 100644 --- a/wqflask/wqflask/auwerx/phewas_analysis.py +++ b/wqflask/wqflask/auwerx/phewas_analysis.py @@ -59,14 +59,11 @@ class PheWAS(object): rnames = r_seq(1, len(parser.markers)) # Create the snp aligner object out of the BXD genotypes snpaligner = ro.r.matrix(snpinfo, nrow=len(parser.markers), dimnames = r_list(rnames, r_c("SNP", "Chr", "Pos")), ncol = 3, byrow=True) - r_write_table(snpaligner, "~/snpaligner_GN2.txt", row_names=False) + #r_write_table(snpaligner, "~/snpaligner_GN2.txt", row_names=False) # Create the phenotype aligner object using R phenoaligner = self.r_create_Pheno_aligner() - #r_load(precompfilelocation) # Load the pre-computed EMMA results into R - #allpvalues = ro.r['pval_small'] # Get a pointer to the pre-computed results - self.results = {} self.results['imgurl1'] = webqtlUtil.genRandStr("phewas_") + ".png" self.results['imgloc1'] = GENERATED_IMAGE_DIR + self.results['imgurl1'] @@ -74,7 +71,11 @@ class PheWAS(object): print("IMAGE AT:", self.results['imgloc1'] ) # Create the PheWAS plot (The gene/probe name, chromosome and gene/probe positions should come from the user input) # TODO: generate the PDF in the temp folder, with a unique name - self.r_PheWASManhattan("Test", precompfilelocation, phenoaligner, snpaligner, "None", 1, 25, 25, self.results['imgloc1'] ) + phewasres = self.r_PheWASManhattan("Test", precompfilelocation, phenoaligner, snpaligner, "None", 1, 25, 25, self.results['imgloc1'] ) + self.results['phewas1'] = phewasres[0] + self.results['phewas2'] = phewasres[1] + self.results['phewas3'] = phewasres[2] + #self.r_PheWASManhattan(allpvalues) #self.r_Stop() -- cgit v1.2.3 From c809fd831a49ea666ba61e84a44172e8468f48c5 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Thu, 16 Feb 2017 19:01:31 +0100 Subject: Updated templates to show a table for GN2 --- wqflask/wqflask/templates/ephewas_analysis.html | 10 ++++++++-- wqflask/wqflask/templates/mediation_analysis.html | 10 ++++++++-- wqflask/wqflask/templates/phewas_analysis.html | 24 ++++++++++++++++++++++- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/wqflask/wqflask/templates/ephewas_analysis.html b/wqflask/wqflask/templates/ephewas_analysis.html index d5e71fa7..f49ec44f 100644 --- a/wqflask/wqflask/templates/ephewas_analysis.html +++ b/wqflask/wqflask/templates/ephewas_analysis.html @@ -1,9 +1,15 @@ {% extends "base.html" %} -{% block title %}ePheWAS analysis{% endblock %} +{% block title %}PheWAS analysis{% endblock %} {% block content %}

ePheWAS analysis results

- YAY ! We have our own route +

Top 10 ePheWAS hits

+ + + +
PhenotypePhenosomeAdditionalLODLODBH
Phenotype 1Phenosome 1Additional 1LOD 1BH 1
+

Download all ePheWAS results

+ Download CSV Download RData
{% endblock %} diff --git a/wqflask/wqflask/templates/mediation_analysis.html b/wqflask/wqflask/templates/mediation_analysis.html index ee5a5016..2804a14f 100644 --- a/wqflask/wqflask/templates/mediation_analysis.html +++ b/wqflask/wqflask/templates/mediation_analysis.html @@ -1,9 +1,15 @@ {% extends "base.html" %} -{% block title %}Mediation analysis{% endblock %} +{% block title %}PheWAS analysis{% endblock %} {% block content %}

Mediation analysis results

- YAY ! We have our own route +

Top 10 Mediation hits

+ + + +
WithPhenosomeAdditionalLODLODBH
PhenotypePhenosomeAdditional 1LOD 1BH 1Mediate
+

Download all Mediation results

+ Download CSV Download RData
{% endblock %} diff --git a/wqflask/wqflask/templates/phewas_analysis.html b/wqflask/wqflask/templates/phewas_analysis.html index f72564ae..fbe7c364 100644 --- a/wqflask/wqflask/templates/phewas_analysis.html +++ b/wqflask/wqflask/templates/phewas_analysis.html @@ -4,7 +4,29 @@ {% block content %}

PheWAS analysis results

- YAY ! We have our own route
+

Top 5 PheWAS hits

+ + + {% for r in range(5) %} + + {% for c in range(results['phewas3']|length) %} + + {%- endfor %} + {%- endfor %} + +
GN IDPhenotypePhenosomeLOD
+ {% if c == 4 %} + {{results['phewas3'][c][r]|float|round(2)}} + {% else %} + {{results['phewas3'][c][r]}} + {% endif %} +
+ +

Download PheWAS results

+ Download CSV Download RData +

PheWAS manhattan plot

Embedded Image

PheWAS analysis results

+

R debug log

+ {% for i in range(results['R_debuglog']|length) %} + {{ results['R_debuglog'][i]}}
+ {%- endfor %}

Top 5 PheWAS hits

{% for r in range(5) %} - {% for c in range(results['phewas3']|length) %} + {% for c in range(results['tabulardata']|length) %} {%- endfor %} -- cgit v1.2.3 From c465eb3e4b17a3cd3c9ce20d330295c5d1d44567 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Fri, 17 Feb 2017 21:30:41 +0100 Subject: Connecting p.adjust parameters, and updating the region size parameter --- wqflask/wqflask/auwerx/phewas_analysis.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wqflask/wqflask/auwerx/phewas_analysis.py b/wqflask/wqflask/auwerx/phewas_analysis.py index ed2df01f..b9789404 100644 --- a/wqflask/wqflask/auwerx/phewas_analysis.py +++ b/wqflask/wqflask/auwerx/phewas_analysis.py @@ -55,6 +55,8 @@ class PheWAS(object): self.trait_id = requestform["trait_id"] self.datasetname = requestform["dataset"] self.dataset = data_set.create_dataset(self.datasetname) + self.region = int(requestform["num_region"]) + self.mtadjust = str(requestform["sel_mtadjust"]) # Print some debug print "self.trait_id:" + self.trait_id + "\n" @@ -70,7 +72,7 @@ class PheWAS(object): self.mb = int(self.this_trait.mb); # print some debug - print "location:" + self.chr + ":" + str(self.mb) + "\n" + print "location:" + self.chr + ":" + str(self.mb) + "+/-" + str(self.region) + "\n" # Load in the genotypes file *sigh* to make the markermap parser = genofile_parser.ConvertGenoFile(genofilelocation) @@ -92,11 +94,12 @@ class PheWAS(object): self.results = {} self.results['imgurl1'] = webqtlUtil.genRandStr("phewas_") + ".png" self.results['imgloc1'] = GENERATED_IMAGE_DIR + self.results['imgurl1'] + self.results['mtadjust'] = self.mtadjust print("IMAGE AT:", self.results['imgurl1'] ) print("IMAGE AT:", self.results['imgloc1'] ) # Create the PheWAS plot (The gene/probe name, chromosome and gene/probe positions should come from the user input) # TODO: generate the PDF in the temp folder, with a unique name - phewasres = self.r_PheWASManhattan("Test", precompfile, phenoaligner, snpaligner, "None", self.chr, self.mb, self.mb, self.results['imgloc1'] ) + phewasres = self.r_PheWASManhattan("Test", precompfile, phenoaligner, snpaligner, "None", self.chr, self.mb, self.region, self.results['imgloc1'] , self.mtadjust) self.results['phewas1'] = phewasres[0] self.results['phewas2'] = phewasres[1] self.results['tabulardata'] = phewasres[2] -- cgit v1.2.3 From 0c9ec1de388359916abc7386154093fd0d76dbf0 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Fri, 17 Feb 2017 21:31:09 +0100 Subject: Cleaning up the templates, adding the LOC adjusted column --- wqflask/wqflask/templates/phewas_analysis.html | 4 ++-- wqflask/wqflask/templates/show_trait_PheWAS_tools.html | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/wqflask/wqflask/templates/phewas_analysis.html b/wqflask/wqflask/templates/phewas_analysis.html index 4dbc071f..91c47a10 100644 --- a/wqflask/wqflask/templates/phewas_analysis.html +++ b/wqflask/wqflask/templates/phewas_analysis.html @@ -10,12 +10,12 @@ {%- endfor %}

Top 5 PheWAS hits

GN IDPhenotypePhenosomeLOD
- {% if c == 4 %} - {{results['phewas3'][c][r]|float|round(2)}} + {% if c == 3 %} + {{results['tabulardata'][c][r]|float|round(2)}} {% else %} - {{results['phewas3'][c][r]}} + {{results['tabulardata'][c][r]}} {% endif %}
- + {% for r in range(5) %} {% for c in range(results['tabulardata']|length) %}
GN IDPhenotypePhenosomeLOD
GN IDPhenotypePhenosomeLODLOD( {{ results['mtadjust'] }} )
- {% if c == 3 %} + {% if c >= 3 %} {{results['tabulardata'][c][r]|float|round(2)}} {% else %} {{results['tabulardata'][c][r]}} diff --git a/wqflask/wqflask/templates/show_trait_PheWAS_tools.html b/wqflask/wqflask/templates/show_trait_PheWAS_tools.html index d8193652..d4e9ae66 100644 --- a/wqflask/wqflask/templates/show_trait_PheWAS_tools.html +++ b/wqflask/wqflask/templates/show_trait_PheWAS_tools.html @@ -17,24 +17,30 @@

PheWAS options: +
- +
- +
-- cgit v1.2.3 From e729dfe1c3f984d83d5ec6f5760a961fbb74babe Mon Sep 17 00:00:00 2001 From: DannyArends Date: Fri, 17 Feb 2017 21:37:48 +0100 Subject: Polishing, adding the help at the side, PheWAS integrated fully (untill I can talk to Hao) --- wqflask/wqflask/templates/show_trait_PheWAS_tools.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wqflask/wqflask/templates/show_trait_PheWAS_tools.html b/wqflask/wqflask/templates/show_trait_PheWAS_tools.html index d4e9ae66..c284c456 100644 --- a/wqflask/wqflask/templates/show_trait_PheWAS_tools.html +++ b/wqflask/wqflask/templates/show_trait_PheWAS_tools.html @@ -96,4 +96,14 @@
+
+
+
Phewas
+
PLaceholder.
+
ePhewas
+
PLaceholder.
+
Mediation
+
PLaceholder.
+
+
-- cgit v1.2.3 From 1d1c7dd0b4a186df6d71ea7b2859e8ea9b12d38e Mon Sep 17 00:00:00 2001 From: DannyArends Date: Sat, 4 Mar 2017 10:50:03 +0100 Subject: Minor update to the comments --- wqflask/wqflask/auwerx/phewas_analysis.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wqflask/wqflask/auwerx/phewas_analysis.py b/wqflask/wqflask/auwerx/phewas_analysis.py index b9789404..e9455fba 100644 --- a/wqflask/wqflask/auwerx/phewas_analysis.py +++ b/wqflask/wqflask/auwerx/phewas_analysis.py @@ -31,7 +31,7 @@ r_load = ro.r["load"] # Map the head function r_colnames = ro.r["colnames"] # Map the colnames function r_list = ro.r["list"] # Map the list function r_c = ro.r["c"] # Map the c (combine) function -r_print = ro.r["print"] # Map the c (combine) function +r_print = ro.r["print"] # Map the print function r_seq = ro.r["seq"] # Map the rep (repeat) function class PheWAS(object): @@ -86,7 +86,6 @@ class PheWAS(object): rnames = r_seq(1, len(parser.markers)) # Create the snp aligner object out of the BXD genotypes snpaligner = ro.r.matrix(snpinfo, nrow=len(parser.markers), dimnames = r_list(rnames, r_c("SNP", "Chr", "Pos")), ncol = 3, byrow=True) - #r_write_table(snpaligner, "~/snpaligner_GN2.txt", row_names=False) # Create the phenotype aligner object using R phenoaligner = self.r_create_Pheno_aligner() -- cgit v1.2.3 From 81c47ad8bc5a0bfe3b8a5f23a599894b24a5da48 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Sat, 4 Mar 2017 10:50:21 +0100 Subject: Starting integration of the ePheWas tool --- wqflask/wqflask/auwerx/ephewas_analysis.py | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/wqflask/wqflask/auwerx/ephewas_analysis.py b/wqflask/wqflask/auwerx/ephewas_analysis.py index edfb2801..2f6d6061 100644 --- a/wqflask/wqflask/auwerx/ephewas_analysis.py +++ b/wqflask/wqflask/auwerx/ephewas_analysis.py @@ -24,13 +24,56 @@ from utility.tools import locate from rpy2.robjects.packages import importr utils = importr("utils") +r_library = ro.r["library"] # Map the library function +r_options = ro.r["options"] # Map the options function +r_write_table = ro.r["write.table"] # Map the write.table function +r_head = ro.r["head"] # Map the head function +r_load = ro.r["load"] # Map the head function +r_colnames = ro.r["colnames"] # Map the colnames function +r_list = ro.r["list"] # Map the list function +r_c = ro.r["c"] # Map the c (combine) function +r_print = ro.r["print"] # Map the print function +r_seq = ro.r["seq"] # Map the rep (repeat) function + class EPheWAS(object): def __init__(self): print("Initialization of ePheWAS") + print(r_library("auwerx")) # Load the auwerx package + self.r_create_Pheno_aligner = ro.r["create.Pheno_aligner"] # Map the create.Pheno_aligner function + self.r_data_gatherer = ro.r["data.gatherer"] # Map the data.gatherer function print("Initialization of ePheWAS done !") def run_analysis(self, requestform): print("Starting ePheWAS analysis on dataset") + genofilelocation = locate("BXD.geno", "genotype") # Get the location of the BXD genotypes + tissuealignerloc = locate("Tissue_color_aligner.csv", "auwerx") # Get the location of the Tissue_color_aligner + + # Get user parameters, trait_id and dataset, and store/update them in self + self.trait_id = requestform["trait_id"] + self.datasetname = requestform["dataset"] + self.dataset = data_set.create_dataset(self.datasetname) + + # Print some debug + print "self.trait_id:" + self.trait_id + "\n" + print "self.datasetname:" + self.datasetname + "\n" + print "self.dataset.type:" + self.dataset.type + "\n" + + # Load in the genotypes file *sigh* to make the markermap + parser = genofile_parser.ConvertGenoFile(genofilelocation) + parser.process_csv() + snpinfo = [] + for marker in parser.markers: + snpinfo.append(marker["name"]); + snpinfo.append(marker["chr"]); + snpinfo.append(marker["Mb"]); + + rnames = r_seq(1, len(parser.markers)) + # Create the snp aligner object out of the BXD genotypes + snpaligner = ro.r.matrix(snpinfo, nrow=len(parser.markers), dimnames = r_list(rnames, r_c("SNP", "Chr", "Pos")), ncol = 3, byrow=True) + + # Create the phenotype aligner object using R + phenoaligner = self.r_create_Pheno_aligner() + print("Initialization of ePheWAS done !") def process_results(self, results): -- cgit v1.2.3 From 1c9914b07559fa3706f469c94112806455053613 Mon Sep 17 00:00:00 2001 From: DannyArends Date: Sat, 4 Mar 2017 10:50:44 +0100 Subject: Creating the EPheWas object in python --- wqflask/wqflask/views.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 047982bf..b49f32d2 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -50,6 +50,7 @@ from wqflask.correlation import corr_scatter_plot from wqflask.wgcna import wgcna_analysis from wqflask.ctl import ctl_analysis from wqflask.auwerx import phewas_analysis +from wqflask.auwerx import ephewas_analysis from utility import temp_data from utility.tools import SQL_URI,TEMPDIR,USE_REDIS,USE_GN_SERVER,GN_SERVER_URL @@ -258,6 +259,7 @@ def phewas(): @app.route("/ephewas", methods=('POST',)) def ephewas(): logger.info("In ephewas, request.form is:", request.form) # We are going to get additional user input for the analysis + ephewasO = ephewas_analysis.EPheWAS() # Start R, load the package and pointers and create the analysis return render_template("ephewas_analysis.html", **request.form) # Display them using the template @app.route("/mediation", methods=('POST',)) -- cgit v1.2.3