From bb1f1608edb23d5e5be16b5c4573d7696d985aff Mon Sep 17 00:00:00 2001
From: BonfaceKilz
Date: Tue, 5 May 2020 15:17:52 +0300
Subject: Use GUIX javascript Datatables package
---
wqflask/wqflask/templates/admin/group_manager.html | 2 +-
wqflask/wqflask/templates/collections/list.html | 2 +-
wqflask/wqflask/templates/collections/view.html | 2 +-
wqflask/wqflask/templates/correlation_matrix.html | 2 +-
wqflask/wqflask/templates/correlation_page.html | 2 +-
wqflask/wqflask/templates/gsearch_gene.html | 2 +-
wqflask/wqflask/templates/gsearch_pheno.html | 2 +-
wqflask/wqflask/templates/mapping_results.html | 2 +-
wqflask/wqflask/templates/pair_scan_results.html | 2 +-
wqflask/wqflask/templates/search_result_page.html | 2 +-
10 files changed, 10 insertions(+), 10 deletions(-)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/templates/admin/group_manager.html b/wqflask/wqflask/templates/admin/group_manager.html
index ea9026a6..1c536cb2 100644
--- a/wqflask/wqflask/templates/admin/group_manager.html
+++ b/wqflask/wqflask/templates/admin/group_manager.html
@@ -46,7 +46,7 @@
{% block js %}
-
+
diff --git a/wqflask/wqflask/templates/collections/list.html b/wqflask/wqflask/templates/collections/list.html
index 3829b950..34224d68 100644
--- a/wqflask/wqflask/templates/collections/list.html
+++ b/wqflask/wqflask/templates/collections/list.html
@@ -66,7 +66,7 @@
{% block js %}
-
+
diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html
index 6639f46a..f7065cdb 100644
--- a/wqflask/wqflask/templates/collections/view.html
+++ b/wqflask/wqflask/templates/collections/view.html
@@ -166,7 +166,7 @@
-
+
diff --git a/wqflask/wqflask/templates/correlation_matrix.html b/wqflask/wqflask/templates/correlation_matrix.html
index 9af52021..2a207c80 100644
--- a/wqflask/wqflask/templates/correlation_matrix.html
+++ b/wqflask/wqflask/templates/correlation_matrix.html
@@ -135,7 +135,7 @@
-
+
-
+
diff --git a/wqflask/wqflask/templates/gsearch_gene.html b/wqflask/wqflask/templates/gsearch_gene.html
index 556d46d3..555f9aa1 100644
--- a/wqflask/wqflask/templates/gsearch_gene.html
+++ b/wqflask/wqflask/templates/gsearch_gene.html
@@ -48,7 +48,7 @@
{% block js %}
-
+
diff --git a/wqflask/wqflask/templates/gsearch_pheno.html b/wqflask/wqflask/templates/gsearch_pheno.html
index f6ffff47..ed892ec0 100644
--- a/wqflask/wqflask/templates/gsearch_pheno.html
+++ b/wqflask/wqflask/templates/gsearch_pheno.html
@@ -48,7 +48,7 @@
{% block js %}
-
+
diff --git a/wqflask/wqflask/templates/mapping_results.html b/wqflask/wqflask/templates/mapping_results.html
index 7e05be18..a1ea6d89 100644
--- a/wqflask/wqflask/templates/mapping_results.html
+++ b/wqflask/wqflask/templates/mapping_results.html
@@ -333,7 +333,7 @@
-
+
diff --git a/wqflask/wqflask/templates/pair_scan_results.html b/wqflask/wqflask/templates/pair_scan_results.html
index 1ccb2b27..38c0489c 100644
--- a/wqflask/wqflask/templates/pair_scan_results.html
+++ b/wqflask/wqflask/templates/pair_scan_results.html
@@ -65,7 +65,7 @@
-
+
diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html
index 0f5c39b0..3cd51e2e 100644
--- a/wqflask/wqflask/templates/search_result_page.html
+++ b/wqflask/wqflask/templates/search_result_page.html
@@ -152,7 +152,7 @@
-
+
--
cgit v1.2.3
From 8df6a19e487e31dfa4a184444e8eace11cda9b15 Mon Sep 17 00:00:00 2001
From: BonfaceKilz
Date: Wed, 6 May 2020 01:24:36 +0300
Subject: Replace CSS dependencies for datatables
---
wqflask/utility/tools.py | 2 +-
wqflask/wqflask/templates/collections/list.html | 2 +-
wqflask/wqflask/templates/collections/view.html | 2 +-
wqflask/wqflask/templates/corr_scatterplot.html | 2 +-
wqflask/wqflask/templates/correlation_matrix.html | 2 +-
wqflask/wqflask/templates/correlation_page.html | 2 +-
wqflask/wqflask/templates/gsearch_gene.html | 2 +-
wqflask/wqflask/templates/gsearch_pheno.html | 2 +-
wqflask/wqflask/templates/mapping_results.html | 2 +-
wqflask/wqflask/templates/pair_scan_results.html | 2 +-
wqflask/wqflask/templates/search_error.html | 2 +-
wqflask/wqflask/templates/search_result_page.html | 2 +-
wqflask/wqflask/templates/show_trait.html | 2 +-
wqflask/wqflask/templates/snp_browser.html | 2 +-
14 files changed, 14 insertions(+), 14 deletions(-)
(limited to 'wqflask')
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py
index 2914d354..89d88516 100644
--- a/wqflask/utility/tools.py
+++ b/wqflask/utility/tools.py
@@ -292,7 +292,7 @@ JS_GUIX_PATH = get_setting("JS_GUIX_PATH")
assert_dir(JS_GUIX_PATH)
assert_dir(JS_GUIX_PATH+'/cytoscape-panzoom')
-CSS_PATH = "UNKNOWN"
+CSS_PATH = JS_GUIX_PATH # The CSS is bundled together with the JS
# assert_dir(JS_PATH)
JS_TWITTER_POST_FETCHER_PATH = get_setting("JS_TWITTER_POST_FETCHER_PATH",js_path("javascript-twitter-post-fetcher"))
diff --git a/wqflask/wqflask/templates/collections/list.html b/wqflask/wqflask/templates/collections/list.html
index 34224d68..c8705c7d 100644
--- a/wqflask/wqflask/templates/collections/list.html
+++ b/wqflask/wqflask/templates/collections/list.html
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block title %}Your Collections{% endblock %}
{% block css %}
-
+
{% endblock %}
diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html
index f7065cdb..34734a01 100644
--- a/wqflask/wqflask/templates/collections/view.html
+++ b/wqflask/wqflask/templates/collections/view.html
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block title %}View Collection{% endblock %}
{% block css %}
-
+
{% endblock %}
diff --git a/wqflask/wqflask/templates/corr_scatterplot.html b/wqflask/wqflask/templates/corr_scatterplot.html
index ffc8244d..5877e367 100644
--- a/wqflask/wqflask/templates/corr_scatterplot.html
+++ b/wqflask/wqflask/templates/corr_scatterplot.html
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block css %}
-
+
diff --git a/wqflask/wqflask/templates/correlation_matrix.html b/wqflask/wqflask/templates/correlation_matrix.html
index 2a207c80..cb9fb815 100644
--- a/wqflask/wqflask/templates/correlation_matrix.html
+++ b/wqflask/wqflask/templates/correlation_matrix.html
@@ -1,6 +1,6 @@
{% extends "base.html" %}
{% block css %}
-
+
diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html
index c4782bb9..b696a3fa 100644
--- a/wqflask/wqflask/templates/correlation_page.html
+++ b/wqflask/wqflask/templates/correlation_page.html
@@ -1,6 +1,6 @@
{% extends "base.html" %}
{% block css %}
-
+
{% endblock %}
diff --git a/wqflask/wqflask/templates/gsearch_gene.html b/wqflask/wqflask/templates/gsearch_gene.html
index 555f9aa1..8c261eec 100644
--- a/wqflask/wqflask/templates/gsearch_gene.html
+++ b/wqflask/wqflask/templates/gsearch_gene.html
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block title %}Search Results{% endblock %}
{% block css %}
-
+
{% endblock %}
{% block content %}
diff --git a/wqflask/wqflask/templates/gsearch_pheno.html b/wqflask/wqflask/templates/gsearch_pheno.html
index ed892ec0..05b2f988 100644
--- a/wqflask/wqflask/templates/gsearch_pheno.html
+++ b/wqflask/wqflask/templates/gsearch_pheno.html
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block title %}Search Results{% endblock %}
{% block css %}
-
+
{% endblock %}
{% block content %}
diff --git a/wqflask/wqflask/templates/mapping_results.html b/wqflask/wqflask/templates/mapping_results.html
index a1ea6d89..8699343f 100644
--- a/wqflask/wqflask/templates/mapping_results.html
+++ b/wqflask/wqflask/templates/mapping_results.html
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block title %}Mapping Results{% endblock %}
{% block css %}
-
+
diff --git a/wqflask/wqflask/templates/pair_scan_results.html b/wqflask/wqflask/templates/pair_scan_results.html
index 38c0489c..b13b393f 100644
--- a/wqflask/wqflask/templates/pair_scan_results.html
+++ b/wqflask/wqflask/templates/pair_scan_results.html
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block title %}Pair Scan{% endblock %}
{% block css %}
-
+
diff --git a/wqflask/wqflask/templates/search_error.html b/wqflask/wqflask/templates/search_error.html
index 7399b377..df8d9dff 100644
--- a/wqflask/wqflask/templates/search_error.html
+++ b/wqflask/wqflask/templates/search_error.html
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block title %}Search Results{% endblock %}
{% block css %}
-
+
{% endblock %}
{% block content %}
diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html
index 3cd51e2e..767e3487 100644
--- a/wqflask/wqflask/templates/search_result_page.html
+++ b/wqflask/wqflask/templates/search_result_page.html
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block title %}Search Results{% endblock %}
{% block css %}
-
+
diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html
index 27c3e398..d29be30b 100644
--- a/wqflask/wqflask/templates/show_trait.html
+++ b/wqflask/wqflask/templates/show_trait.html
@@ -6,7 +6,7 @@
-
+
diff --git a/wqflask/wqflask/templates/snp_browser.html b/wqflask/wqflask/templates/snp_browser.html
index 4422ba73..88cb4d31 100644
--- a/wqflask/wqflask/templates/snp_browser.html
+++ b/wqflask/wqflask/templates/snp_browser.html
@@ -1,6 +1,6 @@
{% extends "base.html" %}
{% block css %}
-
+
--
cgit v1.2.3
From bcd0110bbf8d3e290023891852c21de3d5b7ebc6 Mon Sep 17 00:00:00 2001
From: Danny Arends
Date: Wed, 6 May 2020 12:06:40 -0500
Subject: Put in TODOs for MariaDB query and Design Matrix
---
wqflask/wqflask/marker_regression/rqtl_mapping.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/marker_regression/rqtl_mapping.py b/wqflask/wqflask/marker_regression/rqtl_mapping.py
index 152bb5be..4070e9f5 100644
--- a/wqflask/wqflask/marker_regression/rqtl_mapping.py
+++ b/wqflask/wqflask/marker_regression/rqtl_mapping.py
@@ -62,6 +62,7 @@ def run_rqtl_geno(vals, samples, dataset, method, model, permCheck, num_perm, pe
marker_covars = create_marker_covariates(control_marker, cross_object) # Create the additive covariate markers
logger.info("Marker covars done");
if cofactors != "":
+ logger.info("Cofactors: " + cofactors);
cross_object, trait_covars = add_cofactors(cross_object, dataset, cofactors, samples) # Create the covariates from selected traits
ro.r('all_covars <- cbind(marker_covars, trait_covars)')
else:
@@ -71,7 +72,6 @@ def run_rqtl_geno(vals, samples, dataset, method, model, permCheck, num_perm, pe
#logger.info("Saving Done");
covars = ro.r['all_covars']
#DEBUG to save the session object to file
- #ro.r('save.image(file = "/home/dannya/gn2-danny/all.RData")')
if pair_scan:
if do_control == "true":
logger.info("Using covariate"); result_data_frame = scantwo(cross_object, pheno = "the_pheno", addcovar = covars, model=model, method=method, n_cluster = 16)
@@ -274,7 +274,8 @@ def add_cofactors(cross, this_dataset, covariates, samples):
covar_name_string += ")"
covars_ob = pull_var("trait_covars", cross, covar_name_string)
-
+ # TODO: Pull in the types of the covars from MariaDB
+ # TODO: Iterate through the covar types and create a design matrix based on it
return cross, covars_ob
def create_marker_covariates(control_marker, cross):
@@ -287,7 +288,7 @@ def create_marker_covariates(control_marker, cross):
ro.r('covnames <- covnames[covInGeno]')
ro.r("cat('covnames (purged): ', covnames,'\n')")
ro.r('marker_covars <- genotypes[,covnames]') # Get the covariate matrix by using the marker name as index to the genotype file
-
+ # TODO: Create a design matrix from the marker covars for the markers in case of an F2, 4way, etc
return ro.r["marker_covars"]
def process_pair_scan_results(result):
--
cgit v1.2.3
From 74ddd3556a838fd48c425a73d76d504996fb3644 Mon Sep 17 00:00:00 2001
From: Danny Arends
Date: Tue, 12 May 2020 06:57:58 -0500
Subject: Mapping Rqtl using the correct way to use categorical covars
---
wqflask/wqflask/marker_regression/rqtl_mapping.py | 79 ++++++++++++++++++++---
1 file changed, 71 insertions(+), 8 deletions(-)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/marker_regression/rqtl_mapping.py b/wqflask/wqflask/marker_regression/rqtl_mapping.py
index 4070e9f5..f3d9a70e 100644
--- a/wqflask/wqflask/marker_regression/rqtl_mapping.py
+++ b/wqflask/wqflask/marker_regression/rqtl_mapping.py
@@ -1,16 +1,36 @@
import rpy2.robjects as ro
import rpy2.robjects.numpy2ri as np2r
import numpy as np
+import json
from base.webqtlConfig import TMPDIR
from base.trait import GeneralTrait
from base.data_set import create_dataset
from utility import webqtlUtil
from utility.tools import locate, TEMPDIR
+from flask import g
import utility.logger
logger = utility.logger.getLogger(__name__ )
+# Get a trait's type (numeric, categorical, etc) from the DB
+def get_trait_data_type(trait_db_string):
+ logger.info("get_trait_data_type");
+ the_query = "SELECT value FROM TraitMetadata WHERE type='trait_data_type'"
+ logger.info("the_query done");
+ results_json = g.db.execute(the_query).fetchone()
+ logger.info("the_query executed");
+ results_ob = json.loads(results_json[0])
+ logger.info("json results loaded");
+ if trait_db_string in results_ob:
+ logger.info("found");
+ return results_ob[trait_db_string]
+ else:
+ logger.info("not found");
+ return "numeric"
+
+
+# Run qtl mapping using R/qtl
def run_rqtl_geno(vals, samples, dataset, method, model, permCheck, num_perm, perm_strata_list, do_control, control_marker, manhattan_plot, pair_scan, cofactors):
logger.info("Start run_rqtl_geno");
## Get pointers to some common R functions
@@ -63,7 +83,7 @@ def run_rqtl_geno(vals, samples, dataset, method, model, permCheck, num_perm, pe
logger.info("Marker covars done");
if cofactors != "":
logger.info("Cofactors: " + cofactors);
- cross_object, trait_covars = add_cofactors(cross_object, dataset, cofactors, samples) # Create the covariates from selected traits
+ cross_object, trait_covars = add_cofactors(cross_object, dataset, cofactors, samples) # Create the covariates from selected traits
ro.r('all_covars <- cbind(marker_covars, trait_covars)')
else:
ro.r('all_covars <- marker_covars')
@@ -218,6 +238,34 @@ def add_phenotype(cross, pheno_as_string, col_name):
ro.r('the_cross$pheno <- cbind(pheno, ' + col_name + ' = as.numeric('+ pheno_as_string +'))')
return ro.r["the_cross"]
+def add_categorical_covar(cross, covar_as_string, i):
+ ro.globalenv["the_cross"] = cross
+ logger.info("cross set");
+ ro.r('covar <- as.factor(' + covar_as_string + ')')
+ logger.info("covar set");
+ ro.r('newcovar <- model.matrix(~covar-1)')
+ logger.info("model.matrix finished");
+ ro.r('cat("new covar columns", ncol(newcovar), "\n")')
+ nCol = ro.r('ncol(newcovar)')
+ logger.info("ncol covar done: " + str(nCol[0]));
+ ro.r('pheno <- data.frame(pull.pheno(the_cross))')
+ logger.info("pheno pulled from cross");
+ nCol = int(nCol[0])
+ logger.info("nCol python int:" + str(nCol));
+ col_names = []
+ #logger.info("loop")
+ for x in range(1, (nCol+1)):
+ #logger.info("loop" + str(x));
+ col_name = "covar_" + str(i) + "_" + str(x)
+ #logger.info("col_name" + col_name);
+ ro.r('the_cross$pheno <- cbind(pheno, ' + col_name + ' = newcovar[,' + str(x) + '])')
+ col_names.append(col_name)
+ #logger.info("loop" + str(x) + "done");
+
+ logger.info("returning from add_categorical_covar");
+ return ro.r["the_cross"], col_names
+
+
def add_names(cross, names_as_string, col_name):
ro.globalenv["the_cross"] = cross
ro.r('pheno <- data.frame(pull.pheno(the_cross))')
@@ -236,6 +284,7 @@ def add_cofactors(cross, this_dataset, covariates, samples):
covariate_list = covariates.split(",")
covar_name_string = "c("
for i, covariate in enumerate(covariate_list):
+ logger.info("Covariate: " + covariate);
this_covar_data = []
covar_as_string = "c("
trait_name = covariate.split(":")[0]
@@ -263,19 +312,33 @@ def add_cofactors(cross, this_dataset, covariates, samples):
covar_as_string += ")"
- col_name = "covar_" + str(i)
- cross = add_phenotype(cross, covar_as_string, col_name)
+ datatype = get_trait_data_type(covariate)
+ logger.info("Covariate: " + covariate + " is of type: " + datatype);
+ if(datatype == "categorical"): # Cat variable
+ logger.info("call of add_categorical_covar");
+ cross, col_names = add_categorical_covar(cross, covar_as_string, i) # Expand and add it to the cross
+ logger.info("add_categorical_covar returned");
+ for z, col_name in enumerate(col_names): # Go through the additional covar names
+ if i < (len(covariate_list) - 1):
+ covar_name_string += '"' + col_name + '", '
+ else:
+ if(z < (len(col_names) -1)):
+ covar_name_string += '"' + col_name + '", '
+ else:
+ covar_name_string += '"' + col_name + '"'
- if i < (len(covariate_list) - 1):
- covar_name_string += '"' + col_name + '", '
+ logger.info("covar_name_string:" + covar_name_string);
else:
+ col_name = "covar_" + str(i)
+ cross = add_phenotype(cross, covar_as_string, col_name)
+ if i < (len(covariate_list) - 1):
+ covar_name_string += '"' + col_name + '", '
+ else:
covar_name_string += '"' + col_name + '"'
covar_name_string += ")"
-
+ logger.info("covar_name_string:" + covar_name_string);
covars_ob = pull_var("trait_covars", cross, covar_name_string)
- # TODO: Pull in the types of the covars from MariaDB
- # TODO: Iterate through the covar types and create a design matrix based on it
return cross, covars_ob
def create_marker_covariates(control_marker, cross):
--
cgit v1.2.3