about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--wqflask/wqflask/templates/wgcna_results.html2
-rw-r--r--wqflask/wqflask/wgcna/wgcna_analysis.py27
2 files changed, 21 insertions, 8 deletions
diff --git a/wqflask/wqflask/templates/wgcna_results.html b/wqflask/wqflask/templates/wgcna_results.html
index 5d654e94..77de3604 100644
--- a/wqflask/wqflask/templates/wgcna_results.html
+++ b/wqflask/wqflask/templates/wgcna_results.html
@@ -4,7 +4,7 @@
 {% block content %} <!-- Start of body -->
   <div>
     <h1>WGCNA Results</h1>
-    {{result}}
+    Phenotypes used as input: {% for k in result %} {{k[0].name}} {% endfor %}
   </div>
 {% endblock %}
 
diff --git a/wqflask/wqflask/wgcna/wgcna_analysis.py b/wqflask/wqflask/wgcna/wgcna_analysis.py
index 5b6c1c1b..c9709781 100644
--- a/wqflask/wqflask/wgcna/wgcna_analysis.py
+++ b/wqflask/wqflask/wgcna/wgcna_analysis.py
@@ -8,6 +8,8 @@ import scipy as sp                            # SciPy
 import rpy2.robjects as ro                    # R Objects
 import pandas.rpy.common as com               # R common functions
 
+from utility import helper_functions
+
 from rpy2.robjects.packages import importr
 utils = importr("utils")
 
@@ -34,21 +36,32 @@ class WGCNA(object):
         r_library("WGCNA")                            # Load WGCNA - Should only be done once, since it is quite expensive
         r_options(stringsAsFactors = False)
         print("Initialization of WGCNA done, package loaded in R session")
-        r_enableWGCNAThreads    = ro.r["enableWGCNAThreads"]        # Map the enableWGCNAThreads function
-        r_pickSoftThreshold     = ro.r["pickSoftThreshold"]         # Map the pickSoftThreshold function
-        r_blockwiseModules      = ro.r["blockwiseModules"]          # Map the blockwiseModules function
-        r_labels2colors         = ro.r["labels2colors"]             # Map the labels2colors function
-        r_plotDendroAndColors   = ro.r["plotDendroAndColors"]       # Map the plotDendroAndColors function
+        self.r_enableWGCNAThreads    = ro.r["enableWGCNAThreads"]        # Map the enableWGCNAThreads function
+        self.r_pickSoftThreshold     = ro.r["pickSoftThreshold"]         # Map the pickSoftThreshold function
+        self.r_blockwiseModules      = ro.r["blockwiseModules"]          # Map the blockwiseModules function
+        self.r_labels2colors         = ro.r["labels2colors"]             # Map the labels2colors function
+        self.r_plotDendroAndColors   = ro.r["plotDendroAndColors"]       # Map the plotDendroAndColors function
         print("Obtained pointers to WGCNA functions")
 
     def run_analysis(self, requestform):
         print("Starting WGCNA analysis on dataset")
-        results = {}
+        self.r_enableWGCNAThreads()                                      # Enable multi threading
+        self.trait_db_list = [trait.strip() for trait in requestform['trait_list'].split(',')]
+        print("Retrieved phenotype data from database", requestform['trait_list'])
+        helper_functions.get_trait_db_obs(self, self.trait_db_list)
+        self.results = {}
+        for t in self.trait_list:
+            strains = []
+            for s in t[0].data:
+                strains.append(s)
+            self.results[t]  = strains
+
+        print("Retrieved phenotype data from database")
 
     def process_results(self, results):
         print("Processing WGCNA output")
         template_vars = {}
-        template_vars["result"] = "OK"
+        template_vars["result"] = self.results
         #r_sink(type = "message")                                   # This restores R output to the stdout/stderr
         #r_sink()                                                   # We should end the Rpy session more or less
         return(dict(template_vars))