diff options
Diffstat (limited to 'wqflask')
20 files changed, 474 insertions, 510 deletions
diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py index 2f6c3a96..0f72b29d 100644 --- a/wqflask/wqflask/collect.py +++ b/wqflask/wqflask/collect.py @@ -349,8 +349,11 @@ def delete_collection(): db_session.delete(uc) db_session.commit() else: - collection_name = params['collection_name'] - user_manager.AnonUser().delete_collection(collection_name) + if "collection_name" in params: + collection_name = params['collection_name'] + else: + for this_collection in params['uc_id'].split(":"): + user_manager.AnonUser().delete_collection(this_collection) flash("We've deleted the collection: {}.".format(collection_name), "alert-info") diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index 3d1c0d17..9b048346 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -32,6 +32,7 @@ import pp import math import collections import resource +import json import scipy @@ -51,6 +52,7 @@ import utility.webqtlUtil #this is for parallel computing only. from wqflask.correlation import correlation_functions from utility.benchmark import Bench import utility.webqtlUtil +from wqflask import user_manager from MySQLdb import escape_string as escape @@ -248,7 +250,7 @@ class CorrelationResults(object): else: self.this_trait_vals.append("None") num_overlap = len(self.this_trait_vals) - + logger.debug("DOING PARALLEL") self.do_parallel_correlation(db_filename, num_overlap) else: for trait, values in self.target_dataset.trait_data.iteritems(): @@ -335,6 +337,7 @@ class CorrelationResults(object): #print("self.correlation_results: ", pf(self.correlation_results)) + self.json_results = generate_corr_json(self.correlation_results, self.this_trait, self.dataset, self.target_dataset) #XZ, 09/18/2008: get all information about the user selected database. #target_db_name = fd.corr_dataset @@ -1195,6 +1198,17 @@ class CorrelationResults(object): import math import reaper + def cmpOrder2(A,B): + try: + if A[-1] < B[-1]: + return -1 + elif A[-1] == B[-1]: + return 0 + else: + return 1 + except: + return 0 + def calCorrelation(dbdata,userdata,N): X = [] Y = [] @@ -1420,3 +1434,61 @@ class CorrelationResults(object): # for one_result in results: # for one_traitinfo in one_result: # allcorrelations.append( one_traitinfo ) + +def generate_corr_json(corr_results, this_trait, dataset, target_dataset): + results_list = [] + for i, trait in enumerate(corr_results): + results_dict = {} + results_dict['checkbox'] = "<INPUT TYPE='checkbox' NAME='searchResult' class='checkbox trait_checkbox' style='padding-right: 0px;' VALUE='" + user_manager.data_hmac('{}:{}'.format(trait.name, trait.dataset.name)) + "'>" + results_dict['index'] = i + 1 + results_dict['trait_id'] = "<a href='/show_trait?trait_id="+str(trait.name)+"&dataset="+str(dataset.name)+"'>"+str(trait.name)+"</a>" + if target_dataset.type == "ProbeSet": + results_dict['symbol'] = trait.symbol + results_dict['description'] = trait.description_display + results_dict['location'] = trait.location_repr + results_dict['mean'] = float(trait.mean) + if trait.LRS_score_repr != "N/A": + results_dict['lrs_score'] = "%.1f" % float(trait.LRS_score_repr) + else: + results_dict['lrs_score'] = "N/A" + results_dict['lrs_location'] = trait.LRS_location_repr + if trait.additive != "": + results_dict['additive'] = "%0.3f" % float(trait.additive) + else: + results_dict['additive'] = "N/A" + results_dict['sample_r'] = "<a target='_blank' href='corr_scatter_plot?dataset_1=" + str(dataset.name) + "&dataset_2=" + str(trait.dataset.name) + "&trait_1=" + str(this_trait.name) + "&trait_2=" + str(trait.name) + "'>" + "%0.3f" % float(trait.sample_r) + "</a>" + results_dict['num_overlap'] = trait.num_overlap + results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) + if trait.lit_corr == "" or trait.lit_corr == 0: + results_dict['lit_corr'] = "--" + else: + results_dict['lit_corr'] = "%0.3f" % float(trait.lit_corr) + if trait.tissue_corr == "" or trait.tissue_corr == 0: + results_dict['tissue_corr'] = "--" + else: + results_dict['tissue_corr'] = "%0.3f" % float(trait.tissue_corr) + elif target_dataset.type == "Publish": + results_dict['description'] = trait.description_display + results_dict['authors'] = trait.authors + if trait.pubmed_id: + results_dict['pubmed'] = "<a href='" + trait.pubmed_link + "'> " + trait.pubmed_text + "</a>" + else: + results_dict['pubmed'] = "N/A" + results_dict['lrs_score'] = trait.LRS_score_repr + results_dict['lrs_location'] = trait.LRS_location_repr + if trait.additive != "": + results_dict['additive'] = "%0.3f" % float(trait.additive) + else: + results_dict['additive'] = "N/A" + results_dict['sample_r'] = "<a target='_blank' href='corr_scatter_plot?dataset_1=" + str(dataset.name) + "&dataset_2=" + str(trait.dataset.name) + "&trait_1=" + str(this_trait.name) + "&trait_2=" + str(trait.name) + "'>" + "%0.3f" % trait.sample_r + "</a>" + results_dict['num_overlap'] = trait.num_overlap + results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) + else: + results_dict['lrs_location'] = trait.LRS_location_repr + results_dict['sample_r'] = "<a target='_blank' href='corr_scatter_plot?dataset_1=" + str(dataset.name) + "&dataset_2=" + str(trait.dataset.name) + "&trait_1=" + str(this_trait.name) + "&trait_2=" + str(trait.name) + "'>" + "%0.3f" % float(trait.sample_r) + "</a>" + results_dict['num_overlap'] = trait.num_overlap + results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) + + results_list.append(results_dict) + + return json.dumps(results_list) diff --git a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py index b34beb7b..077386a3 100644 --- a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py +++ b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py @@ -173,9 +173,12 @@ class CorrelationMatrix(object): for sample in self.all_sample_list: groups.append(1) - pca = self.calculate_pca(range(len(self.traits)), corr_eigen_value, corr_eigen_vectors) - - self.loadings_array = self.process_loadings() + try: + self.pca_works = "True" + pca = self.calculate_pca(range(len(self.traits)), corr_eigen_value, corr_eigen_vectors) + self.loadings_array = self.process_loadings() + except: + self.pca_works = "False" self.js_data = dict(traits = [trait.name for trait in self.traits], groups = groups, diff --git a/wqflask/wqflask/marker_regression/gemma_mapping.py b/wqflask/wqflask/marker_regression/gemma_mapping.py index 68920130..7563eb2c 100644 --- a/wqflask/wqflask/marker_regression/gemma_mapping.py +++ b/wqflask/wqflask/marker_regression/gemma_mapping.py @@ -3,7 +3,7 @@ import os, math, string, random, json from base import webqtlConfig from base.trait import GeneralTrait from base.data_set import create_dataset -from utility.tools import flat_files, GEMMA_COMMAND, GEMMA_WRAPPER_COMMAND, TEMPDIR, assert_bin, assert_file +from utility.tools import flat_files, GEMMA_COMMAND, GEMMA_WRAPPER_COMMAND, TEMPDIR import utility.logger logger = utility.logger.getLogger(__name__ ) @@ -11,7 +11,6 @@ logger = utility.logger.getLogger(__name__ ) def run_gemma(this_dataset, samples, vals, covariates, method, use_loco): """Generates p-values for each marker using GEMMA""" - assert_bin(GEMMA_COMMAND); if this_dataset.group.genofile != None: genofile_name = this_dataset.group.genofile[:-5] else: @@ -193,7 +192,7 @@ def parse_gemma_output(genofile_name): # if marker['chr'] != previous_chr: # previous_chr = marker['chr'] marker['Mb'] = float(line.split("\t")[2]) / 1000000 - marker['p_value'] = float(line.split("\t")[10]) + marker['p_value'] = float(line.split("\t")[11]) if math.isnan(marker['p_value']) or (marker['p_value'] <= 0): marker['lod_score'] = 0 #marker['lrs_value'] = 0 @@ -203,20 +202,15 @@ def parse_gemma_output(genofile_name): marker_obs.append(marker) included_markers.append(line.split("\t")[1]) - p_values.append(float(line.split("\t")[10])) + p_values.append(float(line.split("\t")[11])) return marker_obs def parse_loco_output(this_dataset, gwa_output_filename): output_filelist = [] - jsonfn = "{}/gn2/".format(TEMPDIR) + gwa_output_filename + ".json" - assert_file(jsonfn) - try: - with open(jsonfn) as data_file: - data = json.load(data_file) - except: - logger.error("Can not parse "+jsonfn) + with open("{}/gn2/".format(TEMPDIR) + gwa_output_filename + ".json") as data_file: + data = json.load(data_file) files = data['files'] for file in files: @@ -241,7 +235,7 @@ def parse_loco_output(this_dataset, gwa_output_filename): else: marker['chr'] = line.split("\t")[0] marker['Mb'] = float(line.split("\t")[2]) / 1000000 - marker['p_value'] = float(line.split("\t")[10]) + marker['p_value'] = float(line.split("\t")[11]) if math.isnan(marker['p_value']) or (marker['p_value'] <= 0): marker['lod_score'] = 0 #marker['lrs_value'] = 0 @@ -251,6 +245,6 @@ def parse_loco_output(this_dataset, gwa_output_filename): marker_obs.append(marker) included_markers.append(line.split("\t")[1]) - p_values.append(float(line.split("\t")[10])) + p_values.append(float(line.split("\t")[11])) - return marker_obs + return marker_obs
\ 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 c189fb96..3ec61e55 100644 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -228,6 +228,7 @@ class MarkerRegression(object): results, self.json_data, self.perm_output, self.suggestive, self.significant, self.bootstrap_results = qtlreaper_mapping.gen_reaper_results(self.this_trait, self.dataset, self.samples, + self.vals, self.json_data, self.num_perm, self.bootCheck, diff --git a/wqflask/wqflask/marker_regression/marker_regression_gn1.py b/wqflask/wqflask/marker_regression/marker_regression_gn1.py index 211cf187..66884b0c 100644 --- a/wqflask/wqflask/marker_regression/marker_regression_gn1.py +++ b/wqflask/wqflask/marker_regression/marker_regression_gn1.py @@ -1204,6 +1204,8 @@ class MarkerRegression(object): else: if self.mapping_method == "gemma" or self.mapping_method == "gemma_bimbam": string2 = 'Using GEMMA mapping method with no control for other QTLs.' + if self.covariates != "": + string3 = 'Using following traits as covariates: ' + self.covariates elif self.mapping_method == "rqtl_plink" or self.mapping_method == "rqtl_geno": string2 = 'Using R/qtl mapping method with no control for other QTLs.' elif self.mapping_method == "plink": diff --git a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py index 50228b5e..6b58190f 100644 --- a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py +++ b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py @@ -1,17 +1,20 @@ -def gen_reaper_results(this_trait, dataset, samples_before, json_data, num_perm, bootCheck, num_bootstrap, do_control, control_marker, manhattan_plot): +import utility.logger +logger = utility.logger.getLogger(__name__ ) + +def gen_reaper_results(this_trait, dataset, samples_before, trait_vals, json_data, num_perm, bootCheck, num_bootstrap, do_control, control_marker, manhattan_plot): genotype = dataset.group.read_genotype_file() if manhattan_plot != True: genotype = genotype.addinterval() - samples, values, variances, sample_aliases = this_trait.export_informative() - trimmed_samples = [] trimmed_values = [] - for i in range(0, len(samples)): - if this_trait.data[samples[i]].name in samples_before: - trimmed_samples.append(samples[i]) - trimmed_values.append(values[i]) + for i in range(0, len(samples_before)): + try: + trimmed_values.append(float(trait_vals[i])) + trimmed_samples.append(samples_before[i]) + except: + pass perm_output = [] bootstrap_results = [] diff --git a/wqflask/wqflask/static/dbdoc/TODO.md b/wqflask/wqflask/static/dbdoc/TODO.md new file mode 100644 index 00000000..c0a8bab7 --- /dev/null +++ b/wqflask/wqflask/static/dbdoc/TODO.md @@ -0,0 +1 @@ +TODO: Add all database documentation into this folder diff --git a/wqflask/wqflask/static/new/javascript/draw_corr_scatterplot-2.js b/wqflask/wqflask/static/new/javascript/draw_corr_scatterplot-2.js index 43ac6086..bf0a14e6 100644 --- a/wqflask/wqflask/static/new/javascript/draw_corr_scatterplot-2.js +++ b/wqflask/wqflask/static/new/javascript/draw_corr_scatterplot-2.js @@ -1,6 +1,7 @@ var chart; +var srchart; -function drawg () { +function drawg() { // chart = nv.models.scatterChart(); // @@ -27,11 +28,45 @@ function drawg () { chart.yAxis.tickFormat(d3.format(checkformat(yrange))); // chart.tooltip.contentGenerator(function (obj) { - // return '<b style="font-size: 18px">(' + obj.point.x + ', ' + obj.point.y + ')</b>'; - return '<b style="font-size: 18px">' + obj.point.name + '</b>'; + return tiptext(obj); }); } +function srdrawg() { + // + srchart = nv.models.scatterChart(); + // + srchart.showLegend(false); + srchart.duration(300); + srchart.color(d3.scale.category10().range()); + srchart.pointRange([0, 400]); + srchart.pointDomain([0, 10]); + // + srchart.xAxis.axisLabel(js_data.trait_1); + srchart.xAxis.axisLabelDistance(11); + srchart.yAxis.axisLabel(js_data.trait_2); + srchart.yAxis.axisLabelDistance(11); + // + xmin = d3.min(js_data.rdata[0]); + xmax = d3.max(js_data.rdata[0]); + xrange = xmax - xmin; + ymin = d3.min(js_data.rdata[1]); + ymax = d3.max(js_data.rdata[1]); + yrange = ymax - ymin; + srchart.xDomain([0, xmax + xrange/10]); + srchart.yDomain([0, ymax + yrange/10]); + srchart.xAxis.tickFormat(d3.format(checkformat(xrange))); + srchart.yAxis.tickFormat(d3.format(checkformat(yrange))); + // + srchart.tooltip.contentGenerator(function (obj) { + return tiptext(obj); + }); +} + +function tiptext(obj) { + return '<b style="font-size: 18px">' + obj.point.name + " (" + obj.point.x + ', ' + obj.point.y + ')</b>'; +} + function getdata(size, shape) { var data = []; data.push({ @@ -50,6 +85,25 @@ function getdata(size, shape) { } return data; } + +function srgetdata(size, shape) { + var data = []; + data.push({ + values: [], + slope: js_data.srslope, + intercept: js_data.srintercept + }); + for (j = 0; j < js_data.rdata[0].length; j++) { + data[0].values.push({ + x: js_data.rdata[0][j], + y: js_data.rdata[1][j], + name: js_data.indIDs[j], + size: size, + shape: shape + }); + } + return data; +} function checkformat(range) { cell = range / 10.0; @@ -64,50 +118,47 @@ function checkformat(range) { function chartupdate() { // - var axisxcolor = $("#axisxcolor").val(); - $(".nvd3 .nv-axis.nv-x text").css("fill", axisxcolor); + var labelcolor = $("#labelcolor").val(); + $(".nvd3 .nv-axis.nv-x text").css("fill", labelcolor); + $(".nvd3 .nv-axis.nv-y text").css("fill", labelcolor); // - var axisycolor = $("#axisycolor").val(); - $(".nvd3 .nv-axis.nv-y text").css("fill", axisycolor); + var labelfont = $("#labelfont").val(); + $(".nvd3 .nv-axis.nv-x text").css("font-size", labelfont); + $(".nvd3 .nv-axis.nv-y text").css("font-size", labelfont); // - var axisxfont = $("#axisxfont").val(); - $(".nvd3 .nv-axis.nv-x text").css("font-size", axisxfont); + var numbercolor = $("#numbercolor").val(); + $("g.tick text").css("fill", numbercolor); // - var axisyfont = $("#axisyfont").val(); - $(".nvd3 .nv-axis.nv-y text").css("font-size", axisyfont); + var numberfont = $("#numberfont").val(); + $("g.tick text").css("font-size", numberfont); // - var domainxcolor = $("#domainxcolor").val(); - $(".nv-x .nv-axis g path.domain").css("stroke", domainxcolor); - // - var domainycolor = $("#domainycolor").val(); - $(".nv-y .nv-axis g path.domain").css("stroke", domainycolor); - // - var domainxwidth = $("#domainxwidth").val(); - $(".nv-x .nv-axis g path.domain").css("stroke-width", domainxwidth); + var axiscolor = $("#axiscolor").val(); + $(".nv-x .nv-axis g path.domain").css("stroke", axiscolor); + $(".nv-y .nv-axis g path.domain").css("stroke", axiscolor); // - var domainywidth = $("#domainywidth").val(); - $(".nv-y .nv-axis g path.domain").css("stroke-width", domainywidth); + var axiswidth = $("#axiswidth").val(); + $(".nv-x .nv-axis g path.domain").css("stroke-width", axiswidth); + $(".nv-y .nv-axis g path.domain").css("stroke-width", axiswidth); // - var clinecolor = $("#clinecolor").val(); - $("line.nv-regLine").css("stroke", clinecolor); + var linecolor = $("#linecolor").val(); + $("line.nv-regLine").css("stroke", linecolor); // - var clinewidth = $("#clinewidth").val(); - $("line.nv-regLine").css("stroke-width", clinewidth); + var linewidth = $("#linewidth").val(); + $("line.nv-regLine").css("stroke-width", linewidth); // - var axiscolor = $("#axiscolor").val(); - $(".tick").css("stroke", axiscolor); - // - var axiswidth = $("#axiswidth").val(); - $("line.nv-regLine").css("stroke-width", axiswidth); + var markcolor = $("#markcolor").val(); + $(".nvd3 g path").css("fill", markcolor); } function chartupdatewh() { // var width = $("#width").val(); $("#scatterplot2 svg").css("width", width); + $("#srscatterplot2 svg").css("width", width); // var height = $("#height").val(); $("#scatterplot2 svg").css("height", height); + $("#srscatterplot2 svg").css("height", height); // window.dispatchEvent(new Event('resize')); } @@ -118,7 +169,9 @@ function chartupdatedata() { var shape = $("#markshape").val(); // d3.select('#scatterplot2 svg').datum(nv.log(getdata(size, shape))).call(chart); + d3.select('#srscatterplot2 svg').datum(nv.log(srgetdata(size, shape))).call(srchart); nv.utils.windowResize(chart.update); + nv.utils.windowResize(srchart.update); } function savesvg(svgEl, name) { @@ -140,10 +193,14 @@ function saveassvg_pcs() { savesvg($("#svg_pcs")[0], "Pearson Correlation Scatterplot.svg"); } +function saveassvg_srcs() { + savesvg($("#svg_srcs")[0], "Spearman Rank Correlation Scatterplot.svg"); +} + drawg(); -chartupdate(); -chartupdatewh(); -chartupdatedata(); +srdrawg(); + + $(".chartupdate").change(function () { chartupdate(); @@ -156,3 +213,10 @@ $(".chartupdatewh").change(function () { $(".chartupdatedata").change(function () { chartupdatedata(); }); + +$(document).ready(function(){ + //chartupdate(); +//chartupdatewh(); +chartupdatedata(); +//chartupdate(); +});
\ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/draw_corr_scatterplot-2_sr.js b/wqflask/wqflask/static/new/javascript/draw_corr_scatterplot-2_sr.js deleted file mode 100644 index d0392dd7..00000000 --- a/wqflask/wqflask/static/new/javascript/draw_corr_scatterplot-2_sr.js +++ /dev/null @@ -1,137 +0,0 @@ -var srchart; - -function srdrawg () { - // - srchart = nv.models.scatterChart(); - // - srchart.showLegend(false); - srchart.duration(300); - srchart.color(d3.scale.category10().range()); - srchart.pointRange([0, 400]); - srchart.pointDomain([0, 10]); - // - srchart.xAxis.axisLabel(js_data.trait_1); - srchart.xAxis.axisLabelDistance(11); - srchart.yAxis.axisLabel(js_data.trait_2); - srchart.yAxis.axisLabelDistance(11); - // - xmin = d3.min(js_data.rdata[0]); - xmax = d3.max(js_data.rdata[0]); - xrange = xmax - xmin; - ymin = d3.min(js_data.rdata[1]); - ymax = d3.max(js_data.rdata[1]); - yrange = ymax - ymin; - srchart.xDomain([0, xmax + xrange/10]); - srchart.yDomain([0, ymax + yrange/10]); - srchart.xAxis.tickFormat(d3.format(srcheckformat(xrange))); - srchart.yAxis.tickFormat(d3.format(srcheckformat(yrange))); - // - srchart.tooltip.contentGenerator(function (obj) { - // return '<b style="font-size: 18px">(' + obj.point.x + ', ' + obj.point.y + ')</b>'; - return '<b style="font-size: 18px">' + obj.point.name + '</b>'; - }); -} - -function srgetdata(size, shape) { - var data = []; - data.push({ - values: [], - slope: js_data.srslope, - intercept: js_data.srintercept - }); - for (j = 0; j < js_data.rdata[0].length; j++) { - data[0].values.push({ - x: js_data.rdata[0][j], - y: js_data.rdata[1][j], - name: js_data.indIDs[j], - size: size, - shape: shape - }); - } - return data; -} - -function srcheckformat(range) { - cell = range / 10.0; - if (cell >= 1) { - return ",r"; - } else { - cell = -Math.log(cell); - n = cell.toString().split(".")[0].length; - return ",.0" + n + "f"; - } -} - -function srchartupdate() { - // - var axisxcolor = $("#axisxcolor").val(); - $(".nvd3 .nv-axis.nv-x text").css("fill", axisxcolor); - // - var axisycolor = $("#axisycolor").val(); - $(".nvd3 .nv-axis.nv-y text").css("fill", axisycolor); - // - var axisxfont = $("#axisxfont").val(); - $(".nvd3 .nv-axis.nv-x text").css("font-size", axisxfont); - // - var axisyfont = $("#axisyfont").val(); - $(".nvd3 .nv-axis.nv-y text").css("font-size", axisyfont); - // - var domainxcolor = $("#domainxcolor").val(); - $(".nv-x .nv-axis g path.domain").css("stroke", domainxcolor); - // - var domainycolor = $("#domainycolor").val(); - $(".nv-y .nv-axis g path.domain").css("stroke", domainycolor); - // - var domainxwidth = $("#domainxwidth").val(); - $(".nv-x .nv-axis g path.domain").css("stroke-width", domainxwidth); - // - var domainywidth = $("#domainywidth").val(); - $(".nv-y .nv-axis g path.domain").css("stroke-width", domainywidth); - // - var clinecolor = $("#clinecolor").val(); - $("line.nv-regLine").css("stroke", clinecolor); - // - var clinewidth = $("#clinewidth").val(); - $("line.nv-regLine").css("stroke-width", clinewidth); -} - -function srchartupdatewh() { - // - var width = $("#srwidth").val(); - $("#srscatterplot2 svg").css("width", width); - // - var height = $("#srheight").val(); - $("#srscatterplot2 svg").css("height", height); - // - window.dispatchEvent(new Event('resize')); -} - -function srchartupdatedata() { - // - var size = $("#srmarksize").val(); - var shape = $("#srmarkshape").val(); - // - d3.select('#srscatterplot2 svg').datum(nv.log(srgetdata(size, shape))).call(srchart); - nv.utils.windowResize(srchart.update); -} - -function saveassvg_srcs() { - savesvg($("#svg_srcs")[0], "Spearman Rank Correlation Scatterplot.svg"); -} - -srdrawg(); -srchartupdate(); -srchartupdatewh(); -srchartupdatedata(); - -$(".srchartupdate").change(function () { - srchartupdate(); -}); - -$(".srchartupdatewh").change(function () { - srchartupdatewh(); -}); - -$(".srchartupdatedata").change(function () { - srchartupdatedata(); -}); diff --git a/wqflask/wqflask/static/new/javascript/get_covariates_from_collection.js b/wqflask/wqflask/static/new/javascript/get_covariates_from_collection.js index 92e2b13b..f2e694d8 100644 --- a/wqflask/wqflask/static/new/javascript/get_covariates_from_collection.js +++ b/wqflask/wqflask/static/new/javascript/get_covariates_from_collection.js @@ -24,6 +24,7 @@ collection_click = function() { submit_click = function() { var covariates_string = ""; + var covariates_display_string = ""; $('#collections_holder').find('input[type=checkbox]:checked').each(function() { var this_dataset, this_trait; this_trait = $(this).parents('tr').find('.trait').text(); @@ -31,12 +32,15 @@ submit_click = function() { this_dataset = $(this).parents('tr').find('.dataset').text(); console.log("this_dataset is:", this_dataset); covariates_string += this_trait + ":" + this_dataset + "," + covariates_display_string += this_trait + "\n" }); // Trim the last comma covariates_string = covariates_string.substring(0, covariates_string.length - 1) + //covariates_display_string = covariates_display_string.substring(0, covariates_display_string.length - 2) console.log("COVARIATES:", covariates_string) $("input[name=covariates]").val(covariates_string) + $(".selected_covariates").val(covariates_display_string) return $.colorbox.close(); }; @@ -46,6 +50,7 @@ trait_click = function() { trait = $(this).parent().find('.trait').text(); dataset = $(this).parent().find('.dataset').text(); $("input[name=covariates]").val(trait + ":" + dataset) + $(".selected_covariates").text(trait) return $.colorbox.close(); }; diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 099d8010..df10c060 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -88,7 +88,8 @@ }; })(this)); $("#remove_covariates").click(function () { - $("input[name=covariates]").val("") + $("input[name=covariates]").val("") + $(".selected_covariates").val("") }); d3.select("#clear_compare_trait").on("click", (function(_this) { return function() { diff --git a/wqflask/wqflask/templates/collections/list.html b/wqflask/wqflask/templates/collections/list.html index ad72052e..e7f3229b 100644 --- a/wqflask/wqflask/templates/collections/list.html +++ b/wqflask/wqflask/templates/collections/list.html @@ -26,13 +26,13 @@ {% endif %} </div> <div> - <form id="collections_form" action="/delete" method="post"> - <input type="hidden" name="uc_id" id="uc_id" value="" /> - </form> + <form id="collections_form" action="/delete" method="post"> + <input type="hidden" name="uc_id" id="uc_id" value="" /> + </form> <button class="btn btn-default" id="select_all"><span class="glyphicon glyphicon-ok"></span> Select All</button> <button class="btn btn-default" id="deselect_all"><span class="glyphicon glyphicon-remove"></span> Deselect All</button> <button class="btn btn-default" id="invert"><span class="glyphicon glyphicon-resize-vertical"></span> Invert</button> - <button class="btn btn-danger" id="remove_collections" data-url="/collections/delete">Remove Collections</button> + <button class="btn btn-danger" id="remove_collections" data-url="/collections/delete">Remove Collections</button> </div> <br> <div id="collections_list" style="width:50%;"> @@ -51,7 +51,11 @@ <tbody> {% for uc in collections %} <tr class="collection_line"> + {% if g.user_session.user_ob %} <td style="padding-left: 8px; padding-right: 0px; padding-top: 4px; align: center;"><INPUT TYPE="checkbox" NAME="collection" class="checkbox trait_checkbox" VALUE="{{ uc.id }}"></td> + {% else %} + <td style="padding-left: 8px; padding-right: 0px; padding-top: 4px; align: center;"><INPUT TYPE="checkbox" NAME="collection" class="checkbox trait_checkbox" VALUE="{{ uc.name }}"></td> + {% endif %} <td align="right">{{ loop.index }} {% if g.user_session.user_ob %} <td><a class="collection_name" href="{{ url_for('view_collection', uc_id=uc.id) }}">{{ uc.name }}</a></td> diff --git a/wqflask/wqflask/templates/corr_scatterplot.html b/wqflask/wqflask/templates/corr_scatterplot.html index fb2bd55c..bb509270 100644 --- a/wqflask/wqflask/templates/corr_scatterplot.html +++ b/wqflask/wqflask/templates/corr_scatterplot.html @@ -75,72 +75,16 @@ <table class="table">
<tr>
-
- <td>Axis X Color</td>
- <td><input class="chartupdate" id="axisxcolor" type="color" value="#000000"></td>
-
- <td>Axis X Font</td>
- <td><input class="chartupdate" id="axisxfont" type="text" value="16" style="width: 44px;"> px</td>
-
- <td>Domain X Color</td>
- <td><input class="chartupdate" id="domainxcolor" type="color" value="#000000"></td>
-
- <td>Domain X Width</td>
- <td><input class="chartupdate" id="domainxwidth" type="text" value="2" style="width: 44px;"> px</td>
-
- <td>Correlation Line Color</td>
- <td><input class="chartupdate" id="clinecolor" type="color" value="#000000"></td>
-
- <td>Axis Line Color</td>
- <td><input class="chartupdate" id="axiscolor" type="color" value="#000000"></td>
-
- </tr>
- <tr>
-
- <td>Axis Y Color</td>
- <td><input class="chartupdate" id="axisycolor" type="color" value="#000000"></td>
-
- <td>Axis Y Font</td>
- <td><input class="chartupdate" id="axisyfont" type="text" value="16" style="width: 44px;"> px</td>
-
- <td>Domain Y Color</td>
- <td><input class="chartupdate" id="domainycolor" type="color" value="#000000"></td>
-
- <td>Domain Y Width</td>
- <td><input class="chartupdate" id="domainywidth" type="text" value="2" style="width: 44px;"> px</td>
-
- <td>Correlation Line Width</td>
- <td><input class="chartupdate" id="clinewidth" type="text" value="1" style="width: 44px;"> px</td>
-
- <td>Axis Line Width</td>
- <td><input class="chartupdate" id="axiswidth" type="text" value="1" style="width: 44px;"> px</td>
-
- </tr>
+ <td style="vertical-align: middle;">Width <input class="chartupdatewh" id="width" type="text" value="1000" style="width: 44px; height: 22px;"> px</td>
+ <td style="vertical-align: middle;">Height <input class="chartupdatewh" id="height" type="text" value="800" style="width: 44px; height: 22px;"> px</td>
+ </tr>
</table>
-<br>
-
-<ul class="nav nav-tabs">
- <li class="active"><a href="#tp1" data-toggle="tab">Pearson</a></li>
- <li> <a href="#tp2" data-toggle="tab">Spearman Rank</a></li>
-</ul>
-
-<div class="tab-content">
- <div class="tab-pane active" id="tp1">
-
-<br>
<table class="table">
- <tr>
-
- <td>Width</td>
- <td><input class="chartupdatewh" id="width" type="text" value="1000" style="width: 44px;"> px</td>
-
- <td>Height</td>
- <td><input class="chartupdatewh" id="height" type="text" value="800" style="width: 44px;"> px</td>
-
- <td>Size</td>
- <td>
- <select class="chartupdatedata" id="marksize" style="width: 100px;">
+ <tr>
+ <td style="vertical-align: middle;">Mark
+ <input class="chartupdate" id="markcolor" type="color" value="#8fbbda">
+ <select class="chartupdatedata" id="marksize" style="width: 44px; height: 22px;">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
@@ -152,12 +96,12 @@ <option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
+ <option value="15">15</option>
+ <option value="20">20</option>
+ <option value="25">25</option>
+ <option value="30">30</option>
</select>
- </td>
-
- <td>Shape</td>
- <td>
- <select class="chartupdatedata" id="markshape" style="width: 100px;">
+ <select class="chartupdatedata" id="markshape" style="width: 100px; height: 22px;">
<option value="circle" selected>Circle</option>
<option value="cross">Cross</option>
<option value="triangle-up">Triangle-up</option>
@@ -166,23 +110,47 @@ <option value="square">Square</option>
</select>
</td>
-
- </tr>
+ </tr>
</table>
-<div><a id="a_svg_pcs" href="#" onclick="javascript:saveassvg_pcs();" class="btn btn-primary">Save as SVG</a></div>
+<table class="table">
+ <tr>
+ <td style="vertical-align: middle;">Label
+ <input class="chartupdate" id="labelcolor" type="color" value="#000000">
+ <input class="chartupdate" id="labelfont" type="text" value="16" style="width: 44px; height: 22px;"> px
+ </td>
+ <td style="vertical-align: middle;">Number
+ <input class="chartupdate" id="numbercolor" type="color" value="#000000">
+ <input class="chartupdate" id="numberfont" type="text" value="16" style="width: 44px; height: 22px;"> px
+ </td>
+ <td style="vertical-align: middle;">Axis
+ <input class="chartupdate" id="axiscolor" type="color" value="#000000">
+ <input class="chartupdate" id="axiswidth" type="text" value="2" style="width: 44px; height: 22px;"> px
+ </td>
+ <td style="vertical-align: middle;">Line
+ <input class="chartupdate" id="linecolor" type="color" value="#8fbbda">
+ <input class="chartupdate" id="linewidth" type="text" value="1" style="width: 44px; height: 22px;"> px
+ </td>
+ </tr>
+</table>
-<div style="width: 1000px; text-align: center;"><h2>Pearson Correlation Scatterplot</h2></div>
+<br>
-<div id="scatterplot2">
- <svg id="svg_pcs" style="width: 1000px; height: 800px; margin-left: 10px;"></svg>
-</div>
+<ul class="nav nav-tabs">
+ <li class="active"><a href="#tp1" data-toggle="tab">Pearson</a></li>
+ <li> <a href="#tp2" data-toggle="tab">Spearman Rank</a></li>
+</ul>
+
+<div class="tab-content">
+ <div class="tab-pane active" id="tp1">
<br>
-<div class="alert alert-info" style="width: 200px; margin-left: 80px;">
- y = {{'%0.3f' % jsdata.slope}} * x + {{'%0.3f' % jsdata.intercept}}
-</div>
+<div><a id="a_svg_pcs" href="#" onclick="javascript:saveassvg_pcs();" class="btn btn-primary">Save as SVG</a></div>
+
+<div style="width: 1000px; text-align: center;"><h2>Pearson Correlation Scatterplot</h2></div>
+
+<div id="scatterplot2"><svg id="svg_pcs" style="width: 1000px; height: 800px; margin-left: 10px;"></svg></div>
<br>
@@ -196,6 +164,13 @@ <tr><td>Intercept</td> <td>{{'%0.3f' % jsdata.intercept}}</td></tr>
<tr><td>r value</td> <td>{{'%0.3f' % jsdata.r_value}}</td></tr>
<tr><td>P value</td> <td>{% if jsdata.p_value < 0.001 %}{{'%0.3e' % jsdata.p_value}}{% else %}{{'%0.3f' % jsdata.p_value}}{% endif %}</td></tr>
+ <tr>
+ <td style="text-align: left;" colspan="2">
+ Regression Line
+ <br>
+ y = {{'%0.3f' % jsdata.slope}} * x + {{'%0.3f' % jsdata.intercept}}
+ </td>
+ </tr>
</tbody>
</table>
@@ -204,54 +179,12 @@ <div class="tab-pane" id="tp2">
<br>
-<table class="table">
- <tr>
-
- <td>Width</td>
- <td><input class="srchartupdatewh" id="srwidth" type="text" value="1000" style="width: 44px;"> px</td>
-
- <td>Height</td>
- <td><input class="srchartupdatewh" id="srheight" type="text" value="800" style="width: 44px;"> px</td>
-
- <td>Size</td>
- <td>
- <select class="srchartupdatedata" id="srmarksize" style="width: 100px;">
- <option value="0">0</option>
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- <option value="4">4</option>
- <option value="5" selected>5</option>
- <option value="6">6</option>
- <option value="7">7</option>
- <option value="8">8</option>
- <option value="9">9</option>
- <option value="10">10</option>
- </select>
- </td>
-
- <td>Shape</td>
- <td>
- <select class="srchartupdatedata" id="srmarkshape" style="width: 100px;">
- <option value="circle" selected>Circle</option>
- <option value="cross">Cross</option>
- <option value="triangle-up">Triangle-up</option>
- <option value="triangle-down">Triangle-down</option>
- <option value="diamond">Diamond</option>
- <option value="square">Square</option>
- </select>
- </td>
-
- </tr>
-</table>
<div><a id="a_svg_srcs" href="#" onclick="javascript:saveassvg_srcs();" class="btn btn-primary">Save as SVG</a></div>
<div style="width: 1000px; text-align: center;"><h2>Spearman Rank Correlation Scatterplot</h2></div>
-<div id="srscatterplot2">
- <svg id="svg_srcs" style="width: 1000px; height: 800px; margin-left: 10px;"></svg>
-</div>
+<div id="srscatterplot2"><svg id="svg_srcs" style="width: 1000px; height: 800px; margin-left: 10px;"></svg></div>
<br>
@@ -287,5 +220,4 @@ <script language="javascript" type="text/javascript" src="/static/new/javascript/colorbrewer.js"></script>
<script language="javascript" type="text/javascript" src="/static/new/javascript/panelutil.js"></script>
<script language="javascript" type="text/javascript" src="/static/new/javascript/draw_corr_scatterplot-2.js"></script>
- <script language="javascript" type="text/javascript" src="/static/new/javascript/draw_corr_scatterplot-2_sr.js"></script>
{% endblock %}
diff --git a/wqflask/wqflask/templates/correlation_matrix.html b/wqflask/wqflask/templates/correlation_matrix.html index ab793d58..d27788a8 100644 --- a/wqflask/wqflask/templates/correlation_matrix.html +++ b/wqflask/wqflask/templates/correlation_matrix.html @@ -61,6 +61,7 @@ <br> <button class="btn btn-default" id="short_labels">Short Labels</button> <button class="btn btn-default" id="long_labels">Long Labels</button> +{% if pca_works == "True" %} <br> <br> <h2>Factor Loadings Plot</h2> @@ -93,7 +94,7 @@ </tbody> </table> </div> - +{% endif %} {% endblock %} {% block js %} diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index fa9e3585..fb4e19a1 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -1,8 +1,7 @@ {% extends "base.html" %} {% block css %} + <link rel="stylesheet" type="text/css" href="/static/new/packages/tabulator/css/tabulator.css" /> <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/css/jquery.dataTables.css" /> - <link rel="stylesheet" type="text/css" href="/static/packages/DT_bootstrap/DT_bootstrap.css" /> - <link rel="stylesheet" type="text/css" href="/static/packages/TableTools/media/css/TableTools.css" /> <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.bootstrap.css" /> {% endblock %} {% block content %} @@ -63,15 +62,15 @@ </div> <div style="width: {% if target_dataset.type == "ProbeSet" %}1600px{% elif target_dataset.type == "Publish" %}1400px{% else %}800px{% endif %};"> - <table id="trait_table" class="display dataTable nowrap" style="float: left;"> + <table id="trait_table" class="display dataTable nowrap" style="font-size: 12px; float: left;"> <thead> <tr> - <th style="width: 30px;"></th> + <th></th> {% for header in target_dataset.header_fields %} {% if header == 'Year' %} <th>{{header}}</th> {% elif header == 'Max LRS' %} - <th>Max LRS<a href="http://genenetwork.org//glossary.html#L" target="_blank"><sup style="color:#f00"> ?</sup></a></th> + <th>Max LRS</th> {% elif header == 'Max LRS Location' %} <th>{{header}}</th> {% elif header == 'Location' %} @@ -79,7 +78,7 @@ {% elif header == 'Mean' %} <th>{{header}}</th> {% elif header == 'Additive Effect' %} - <th>Additive Effect<a href="http://genenetwork.org//glossary.html#A" target="_blank"><sup style="color:#f00"> ?</sup></a></th> + <th>Additive Effect</th> {% elif header == 'Index' %} <th>{{header}}</th> {% elif header == 'N' %} @@ -91,7 +90,7 @@ {% if target_dataset.type == "ProbeSet" %} {% if corr_method == 'pearson' %} <th>Sample r</th> - <th> N</th> + <th>N</th> <th>Sample p(r)</th> <th>Lit r</th> <th>Tissue r</th> @@ -129,8 +128,8 @@ <tbody> {% for trait in correlation_results %} <tr> - <td style="padding-left: 8px; padding-right: 0px; padding-top: 4px; align: center;"><INPUT TYPE="checkbox" NAME="searchResult" class="checkbox trait_checkbox" style="padding-right: 0px;" VALUE="{{ data_hmac('{}:{}'.format(trait.name, trait.dataset.name)) }}"></td> - <td align="right">{{ loop.index }}</td> + <td><INPUT TYPE="checkbox" NAME="searchResult" class="checkbox trait_checkbox" style="padding-right: 0px;" VALUE="{{ data_hmac('{}:{}'.format(trait.name, trait.dataset.name)) }}"></td> + <td style="padding-left: 8px; padding-right: 0px; padding-top: 4px; align: center;">{{ loop.index }}</td> <td> <a href="{{ url_for('show_trait_page', trait_id = trait.name, @@ -191,13 +190,15 @@ {% block js %} <script type="text/javascript" src="/static/new/javascript/search_results.js"></script> + <script language="javascript" type="text/javascript" src="/static/new/js_external/jszip.min.js"></script> + <script language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script> + <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.js"></script> <script language="javascript" type="text/javascript" src="https://cdn.datatables.net/buttons/1.0.0/js/dataTables.buttons.min.js"></script> <script language="javascript" type="text/javascript" src="https://cdn.datatables.net/buttons/1.0.0/js/buttons.html5.min.js"></script> <script language="javascript" type="text/javascript" src="https://cdn.datatables.net/buttons/1.0.0/js/buttons.bootstrap.min.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/js_external/jszip.min.js"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> - <script language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script> + <script type="text/javascript" charset="utf-8"> function getValue(x) { if (x.indexOf('input') >= 0) { @@ -213,7 +214,8 @@ } return parseFloat(x); } - + + jQuery.fn.dataTableExt.oSort['numeric-html-asc'] = function(a,b) { a = Math.abs(parseFloat($(a).text())); b = Math.abs(parseFloat($(b).text())); @@ -263,6 +265,8 @@ $(document).ready( function () { + var table_json = {{ json_results | safe }} + $('#trait_table tr').click(function(event) { if (event.target.type !== 'checkbox') { $(':checkbox', this).trigger('click'); diff --git a/wqflask/wqflask/templates/empty_collection.html b/wqflask/wqflask/templates/empty_collection.html new file mode 100644 index 00000000..d1b779ef --- /dev/null +++ b/wqflask/wqflask/templates/empty_collection.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} +{% block title %}{{ tool }}{% endblock %} +{% block content %} +<!-- Start of body --> + {{ header("Error") }} + + <div class="container"> + <input type="hidden" name="uc_id" id="uc_id" value="{{ uc_id }}"> + <p>You must select at least two traits to use the {{ tool }}.</p> + </div> + + +<!-- End of body --> + +{% endblock %} diff --git a/wqflask/wqflask/templates/show_trait_calculate_correlations.html b/wqflask/wqflask/templates/show_trait_calculate_correlations.html index c5f815ce..ef233333 100644 --- a/wqflask/wqflask/templates/show_trait_calculate_correlations.html +++ b/wqflask/wqflask/templates/show_trait_calculate_correlations.html @@ -1,9 +1,10 @@ <div> + <div class="col-xs-7"> <div style="padding: 20px" class="form-horizontal"> <div class="form-group"> - <label for="corr_type" class="col-xs-1 control-label">Method</label> - <div class="col-xs-2 controls"> + <label for="corr_type" class="col-xs-2 control-label">Method</label> + <div class="col-xs-3 controls"> <select name="corr_type" class="form-control"> <option value="sample">Sample r</option> <option value="lit">Literature r</option> @@ -13,8 +14,8 @@ </div> <div class="form-group"> - <label for="corr_dataset" class="col-xs-1 control-label">Database</label> - <div class="col-xs-6 controls"> + <label for="corr_dataset" class="col-xs-2 control-label">Database</label> + <div class="col-xs-10 controls"> <select name="corr_dataset" class="form-control"> {% for tissue in corr_tools.dataset_menu %} {% if tissue.tissue %} @@ -37,8 +38,8 @@ </div> <div class="form-group"> - <label for="corr_return_results" class="col-xs-1 control-label">Return</label> - <div class="col-xs-2 controls"> + <label for="corr_return_results" class="col-xs-2 control-label">Return</label> + <div class="col-xs-3 controls"> <select name="corr_return_results" class="form-control"> {% for return_result in corr_tools.return_results_menu %} <option value="{{ return_result }}" @@ -53,8 +54,8 @@ </div> <div class="form-group"> - <label for="corr_samples_group" class="col-xs-1 control-label">Samples</label> - <div class="col-xs-2 controls"> + <label for="corr_samples_group" class="col-xs-2 control-label">Samples</label> + <div class="col-xs-3 controls"> <select name="corr_samples_group" class="form-control"> {% for group, pretty_group in sample_group_types.items() %} <option value="{{ group }}">{{ pretty_group }}</option> @@ -64,8 +65,8 @@ </div> <div id="corr_sample_method" class="form-group"> - <label for="corr_sample_method" class="col-xs-1 control-label">Type</label> - <div class="col-xs-2 controls"> + <label for="corr_sample_method" class="col-xs-2 control-label">Type</label> + <div class="col-xs-3 controls"> <select name="corr_sample_method" class="form-control"> <option value="pearson">Pearson</option> <option value="spearman">Spearman Rank</option> @@ -73,14 +74,14 @@ </div> </div> <div class="form-group"> - <label class="col-xs-1 control-label">Min Expr</label> - <div class="col-xs-2 controls"> + <label class="col-xs-2 control-label">Min Expr</label> + <div class="col-xs-3 controls"> <input name="min_expr" value="" type="text" class="form-control" style="width: 50px;"> </div> </div> <div class="form-group"> - <label class="col-xs-1 control-label">Location</label> - <div class="col-xs-4 controls"> + <label class="col-xs-2 control-label">Location</label> + <div class="col-xs-5 controls"> <span> Chr: <input name="loc_chr" value="" type="text" class="form-control" style="width: 50px; display: inline;"> Mb: <input name="min_loc_mb" value="" type="text" class="form-control" style="width: 50px; display: inline;"> to <input name="max_loc_mb" value="" type="text" class="form-control" style="width: 50px; display: inline;"> @@ -89,8 +90,8 @@ </div> </div> <div class="form-group"> - <label class="col-xs-1 control-label">Range</label> - <div class="col-xs-4 controls"> + <label class="col-xs-2 control-label">Range</label> + <div class="col-xs-5 controls"> <input name="p_range_lower" value="" type="hidden"> <input name="p_range_upper" value="" type="hidden"> <span style="display: inline;"> @@ -103,48 +104,45 @@ </div> <div class="form-group"> - <label for="corr_sample_method" class="col-xs-1 control-label"></label> - <div class="col-xs-4 controls"> + <label for="corr_sample_method" class="col-xs-2 control-label"></label> + <div class="col-xs-3 controls"> <button class="btn corr_compute submit_special btn-success" data-url="/corr_compute" title="Compute Correlation"> <i class="icon-ok-circle icon-white"></i> Compute </button> </div> </div> - - <div class="form-group"> - <label for="descriptions" class="col-xs-1 control-label"></label> - <div class="col-xs-6 controls"> - <span id="sample_r_desc" class="correlation_desc fs12"> - The <a href="http://genenetwork.org/correlationAnnotation.html#genetic_r">Sample Correlation</a> - is computed - between trait data and any - other traits in the sample database selected above. Use - <a href="http://www.genenetwork.org/glossary.html#Correlations">Spearman - Rank</a> - when the sample size is small (<20) or when there are influential outliers. - </span> - <span id="lit_r_desc" style="display: none;" class="correlation_desc fs12"> - The <a href="http://genenetwork.org/correlationAnnotation.html#literatureCorr">Literature Correlation</a> - (Lit r) between - this gene and all other genes is computed<br> - using the <a href="https://grits.eecs.utk.edu/sgo/sgo.html"> - Semantic Gene Organizer</a> - and human, rat, and mouse data from PubMed. - Values are ranked by Lit r, but Sample r and Tissue r are also displayed.<br> - <a href="http://genenetwork.org/glossary.html#Literature">More on using Lit r</a> - </span> - <span id="tissue_r_desc" style="display: none;" class="correlation_desc fs12"> - The <a href="http://genenetwork.org/webqtl/main.py?FormID=tissueCorrelation">Tissue Correlation</a> - (Tissue r) - estimates the similarity of expression of two genes - or transcripts across different cells, tissues, or organs - (<a href="http://genenetwork.org/correlationAnnotation.html#tissueCorr">glossary</a>). - Tissue correlations - are generated by analyzing expression in multiple samples usually taken from single cases.<br> - <strong>Pearson</strong> and <strong>Spearman Rank</strong> correlations have been - computed for all pairs of genes using data from mouse samples.<br> - </span> - </div> - </div> </div> + </div> + <div class="col-xs-5"> + <span id="sample_r_desc" class="correlation_desc fs12"> + The <a href="http://genenetwork.org/correlationAnnotation.html#genetic_r">Sample Correlation</a> + is computed + between trait data and any + other traits in the sample database selected above. Use + <a href="http://www.genenetwork.org/glossary.html#Correlations">Spearman + Rank</a> + when the sample size is small (<20) or when there are influential outliers. + </span> + <span id="lit_r_desc" style="display: none;" class="correlation_desc fs12"> + The <a href="http://genenetwork.org/correlationAnnotation.html#literatureCorr">Literature Correlation</a> + (Lit r) between + this gene and all other genes is computed<br> + using the <a href="https://grits.eecs.utk.edu/sgo/sgo.html"> + Semantic Gene Organizer</a> + and human, rat, and mouse data from PubMed. + Values are ranked by Lit r, but Sample r and Tissue r are also displayed.<br> + <a href="http://genenetwork.org/glossary.html#Literature">More on using Lit r</a> + </span> + <span id="tissue_r_desc" style="display: none;" class="correlation_desc fs12"> + The <a href="http://genenetwork.org/webqtl/main.py?FormID=tissueCorrelation">Tissue Correlation</a> + (Tissue r) + estimates the similarity of expression of two genes + or transcripts across different cells, tissues, or organs + (<a href="http://genenetwork.org/correlationAnnotation.html#tissueCorr">glossary</a>). + Tissue correlations + are generated by analyzing expression in multiple samples usually taken from single cases.<br> + <strong>Pearson</strong> and <strong>Spearman Rank</strong> correlations have been + computed for all pairs of genes using data from mouse samples.<br> + </span> + </div> </div>
\ No newline at end of file diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html index dcec2b9e..03590c2c 100644 --- a/wqflask/wqflask/templates/show_trait_mapping_tools.html +++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html @@ -1,6 +1,6 @@ <div> - {% if (use_pylmm_rqtl and dataset.group.species != "human") or use_plink_gemma %} - <div class="col-xs-4"> + {% if dataset.group.mapping_names|length > 0 %} + <div class="col-xs-5"> <div class="tabbable"> <!-- Only required for left/right tabs --> <ul class="nav nav-pills"> @@ -38,11 +38,11 @@ {# if use_pylmm_rqtl and not use_plink_gemma and dataset.group.species != "human" #} {% if dataset.group.mapping_id == "1" %} <div class="tab-pane active" id="gemma"> - <div style="padding-top: 10px;" class="form-horizontal"> + <div style="padding-top: 20px;" class="form-horizontal"> {% if genofiles and genofiles|length>0 %} <div class="mapping_method_fields form-group"> - <label for="genofiles" class="col-xs-3 control-label">Genotypes</label> - <div style="margin-left: 20px;" class="col-xs-8 controls"> + <label for="genofiles" style="text-align: right;" class="col-xs-3 control-label">Genotypes</label> + <div style="margin-left:20px;" class="col-xs-4 controls"> <select id="genofile_gemma" class="form-control"> {% for item in genofiles %} <option value="{{item['location']}}:{{item['title']}}">{{item['title']}}</option> @@ -52,50 +52,72 @@ </div> {% endif %} <div class="mapping_method_fields form-group"> - <label for="maf_gemma" class="col-xs-5 control-label">Minor allele threshold</label> - <div style="margin-left: 20px;" class="col-xs-3 controls"> + <label for="maf_gemma" style="text-align: right;" class="col-xs-3 control-label">MAF</label> + <div style="margin-left:20px;" class="col-xs-4 controls"> <input name="maf_gemma" value="0.01" type="text" class="form-control"> </div> </div> <div class="mapping_method_fields form-group"> - <label class="col-xs-4 control-label">Use LOCO</label> - <div style="margin-left: 20px;" class="col-xs-4 controls"> + <label style="text-align: right;" class="col-xs-3 control-label">Use LOCO</label> + <div style="margin-left:20px;" class="col-xs-6 controls"> <label class="radio-inline"> - <input type="radio" name="use_loco" value="True"> + <input type="radio" name="use_loco" value="True" checked=""> Yes </label> <label class="radio-inline"> - <input type="radio" name="use_loco" value="False" checked=""> + <input type="radio" name="use_loco" value="False"> No </label> </div> </div> + <!-- </div> <div style="padding-top: 5px; padding-bottom: 5px; padding-left: 20px;" class="form-horizontal"> + --> <div class="mapping_method_fields form-group"> - <button type="button" id="select_covariates" class="btn btn-default"> - Select Covariates - </button> - <button type="button" id="remove_covariates" class="btn btn-default"> - Remove Covariates + <label style="text-align: right;" class="col-xs-3 control-label">Covariates</label> + <div style="margin-left:20px;" class="col-xs-7"> + {% if g.user_session.user_ob and (g.user_session.user_ob.display_num_collections() == "") %} + No collections available. Please add traits to a collection to use them as covariates. + {% elif g.cookie_session.display_num_collections() == "" %} + No collections available. Please add traits to a collection to use them as covariates. + {% else %} + <div style="margin-bottom: 10px;" class="btn-group" role="group"> + <button type="button" id="select_covariates" class="btn btn-default">Select</button> + <button type="button" id="remove_covariates" class="btn btn-default">Remove</button> + </div> + <textarea rows="3" cols="20" readonly placeholder="No covariates selected" style="overflow-y: scroll; resize: none;" class="selected_covariates"></textarea> + {% endif %} + </div> + </div> + <div class="mapping_method_fields form-group"> + <label class="col-xs-3 control-label"></label> + <div style="margin-left:20px;" class="col-xs-6"> + <button id="gemma_bimbam_compute" class="btn submit_special btn-success" data-url="/marker_regression" title="Compute Marker Regression"> + Compute </button> + </div> </div> </div> - +<!-- <div class="form-group"> <div class="col-xs-4 controls"> + <label class="col-xs-2 control-label"></label> + <div class="col-xs-4"> <button id="gemma_bimbam_compute" class="btn submit_special btn-success" data-url="/marker_regression" title="Compute Marker Regression"> Compute </button> + </div> </div> </div> +--> </div> <div class="tab-pane" id="interval_mapping"> <div style="margin-top: 20px" class="form-horizontal"> {% if genofiles and genofiles|length>0 %} <div class="mapping_method_fields form-group"> - <label for="genofiles" class="col-xs-3 control-label">Genotypes</label> - <div style="margin-left: 20px;" class="col-xs-8 controls"> + <label style="text-align: right;" for="genofiles" class="col-xs-3 control-label">Genotypes</label> + <div style="margin-left:20px;" class="col-xs-4 controls"> <select id="genofile_reaper" class="form-control"> {% for item in genofiles %} <option value="{{item['location']}}:{{item['title']}}">{{item['title']}}</option> @@ -105,20 +127,20 @@ </div> {% endif %} <div class="mapping_method_fields form-group"> - <label for="mapping_permutations" class="col-xs-3 control-label">Permutations</label> - <div style="margin-left: 20px;" class="col-xs-4 controls"> + <label style="text-align: right;" for="mapping_permutations" class="col-xs-3 control-label">Permutations</label> + <div style="margin-left:20px;" class="col-xs-4 controls"> <input name="num_perm_reaper" value="2000" type="text" class="form-control"> </div> </div> <div class="mapping_method_fields form-group"> - <label for="mapping_bootstraps" class="col-xs-3 control-label">Bootstraps</label> - <div style="margin-left: 20px;" class="col-xs-4 controls"> + <label style="text-align: right;" for="mapping_bootstraps" class="col-xs-3 control-label">Bootstraps</label> + <div style="margin-left:20px;" class="col-xs-4 controls"> <input name="num_bootstrap" value="2000" type="text" class="form-control"> </div> </div> <div class="mapping_method_fields form-group"> - <label for="control_for" class="col-xs-3 control-label">Control for</label> - <div style="margin-left: 20px;" class="col-xs-4 controls"> + <label style="text-align: right;" for="control_for" class="col-xs-3 control-label">Control for</label> + <div style="margin-left:20px;" class="col-xs-6 controls"> {% if dataset.type == 'ProbeSet' and this_trait.locus_chr != "" %} <input name="control_reaper" value="{{ nearest_marker }}" type="text" style="width: 160px;" class="form-control" /> {% else %} @@ -162,8 +184,8 @@ <div class="mapping_method_fields form-group"> - <label style="text-align:left;" class="col-xs-3 control-label">Marker<br>Regression</label> - <div style="margin-left: 20px;" class="col-xs-4 controls"> + <label style="text-align: right;" class="col-xs-3 control-label">Marker<br>Regression</label> + <div style="margin-left:20px;" class="col-xs-6 controls"> <label class="radio-inline"> <input type="radio" name="manhattan_plot_reaper" value="True"> Yes @@ -174,11 +196,12 @@ </label> </div> </div> - <div class="form-group"> - <div style="padding-left:15px;" class="controls"> - <button id="interval_mapping_compute" class="btn submit_special btn-success" data-url="/marker_regression" title="Compute Interval Mapping"> - <i class="icon-ok-circle icon-white"></i> Compute - </button> + <div class="mapping_method_fields form-group"> + <label class="col-xs-3 control-label"></label> + <div style="margin-left:20px;" class="col-xs-6"> + <button id="interval_mapping_compute" class="btn submit_special btn-success" data-url="/marker_regression" title="Compute Interval Mapping"> + Compute + </button> </div> </div> <!--<div id="alert_placeholder"></div>--> @@ -189,8 +212,8 @@ <div style="margin-top: 20px" class="form-horizontal"> {% if genofiles and genofiles|length>0 %} <div class="mapping_method_fields form-group"> - <label for="genofiles" class="col-xs-3 control-label">Genotypes</label> - <div style="margin-left: 20px;" class="col-xs-8 controls"> + <label style="text-align:right;" for="genofiles" class="col-xs-3 control-label">Genotypes</label> + <div style="margin-left:20px;" class="col-xs-4 controls"> <select id="genofile_rqtl_geno" class="form-control"> {% for item in genofiles %} <option value="{{item['location']}}:{{item['title']}}">{{item['title']}}</option> @@ -200,17 +223,14 @@ </div> {% endif %} <div class="mapping_method_fields form-group"> - <label for="mapping_permutations" class="col-xs-3 control-label">Permutations</label> - <div style="margin-left: 20px;" class="col-xs-4 controls"> - <input name="num_perm_rqtl_geno" value="" type="text" class="form-control"> + <label style="text-align:right;" for="mapping_permutations" class="col-xs-3 control-label">Permutations</label> + <div style="margin-left:20px;" class="col-xs-4 controls"> + <input name="num_perm_rqtl_geno" value="2000" type="text" class="form-control"> </div> </div> - <div id="permutations_alert" class="alert alert-error alert-warning" style="display:none;"> - Please be aware that permutations can take a very long time (~20 minutes for 500 permutations) - </div> <div class="mapping_method_fields form-group"> - <label for="control_for" class="col-xs-3 control-label">Control for</label> - <div style="margin-left: 20px;" class="col-xs-4 controls"> + <label style="text-align:right;" for="control_for" class="col-xs-3 control-label">Control for</label> + <div style="margin-left:20px;" class="col-xs-6 controls"> {% if dataset.type == 'ProbeSet' and this_trait.locus_chr != "" %} <input name="control_rqtl_geno" value="{{ nearest_marker }}" type="text" style="width: 160px;" class="form-control" /> {% else %} @@ -228,8 +248,8 @@ </div> <div class="mapping_method_fields form-group"> - <label for="mapmethod_rqtl_geno" style="text-align:left;" class="col-xs-3 control-label">Method</label> - <div class="col-xs-4 controls"> + <label style="text-align:right;" for="mapmethod_rqtl_geno" class="col-xs-3 control-label">Method</label> + <div style="margin-left:20px;" class="col-xs-4 controls"> <select name="mapmethod_rqtl_geno" class="form-control"> <option value="em">em</option> <option value="imp">imp</option> @@ -243,8 +263,8 @@ </div> <div class="mapping_method_fields form-group"> - <label for="mapmodel_rqtl_geno" style="text-align:left;" class="col-xs-3 control-label">Model</label> - <div class="col-xs-4 controls"> + <label style="text-align:right;" for="mapmodel_rqtl_geno" class="col-xs-3 control-label">Model</label> + <div style="margin-left:20px;" class="col-xs-4 controls"> <select name="mapmodel_rqtl_geno" class="form-control"> <option value="normal">normal</option> <!--<option value="binary">binary</option> @@ -269,8 +289,8 @@ </div> --> <div class="mapping_method_fields form-group"> - <label style="text-align:left;" class="col-xs-12 control-label">Manhattan Plot</label> - <div class="col-xs-12 controls"> + <label style="text-align:right;" class="col-xs-3 control-label">Marker<br>Regression</label> + <div style="margin-left:20px;" class="col-xs-6 controls"> <label class="radio-inline"> <input type="radio" name="manhattan_plot_rqtl" value="True"> Yes @@ -282,11 +302,12 @@ </div> </div> - <div class="form-group"> - <div style="padding-left:15px;" class="controls"> - <button id="rqtl_geno_compute" class="btn submit_special btn-success" data-url="/marker_regression" title="Compute Marker Regression"> - <i class="icon-ok-circle icon-white"></i> Compute - </button> + <div class="mapping_method_fields form-group"> + <label class="col-xs-3 control-label"></label> + <div style="margin-left:20px;" class="col-xs-6"> + <button id="rqtl_geno_compute" class="btn submit_special btn-success" data-url="/marker_regression" title="Compute Interval Mapping"> + Compute + </button> </div> </div> </div> @@ -295,8 +316,8 @@ <div style="margin-top: 20px" class="form-horizontal"> {% if genofiles and genofiles|length>0 %} <div class="mapping_method_fields form-group"> - <label for="genofiles" class="col-xs-3 control-label">Genotypes</label> - <div style="margin-left: 20px;" class="col-xs-8 controls"> + <label style="text-align:right;" class="col-xs-3 control-label">Genotypes</label> + <div style="margin-left: 20px;" class="col-xs-4 controls"> <select id="genofile_pylmm" class="form-control"> {% for item in genofiles %} <option value="{{item['location']}}:{{item['title']}}">{{item['title']}}</option> @@ -305,44 +326,12 @@ </div> </div> {% endif %} -<!-- <div class="mapping_method_fields form-group"> - <label for="control_for" class="col-xs-3 control-label">Control for</label> - <div style="margin-left: 20px;" class="col-xs-4 controls"> - {% if dataset.type == 'ProbeSet' and this_trait.locus_chr != "" %} - <input name="control_pylmm" value="{{ nearest_marker }}" type="text" /> - {% else %} - <input name="control_pylmm" value="" type="text" /> - {% endif %} - <label class="radio-inline"> - <input type="radio" name="do_control_pylmm" value="true"> - Yes - </label> - <label class="radio-inline"> - <input type="radio" name="do_control_pylmm" value="false" checked=""> - No - </label> - </div> - </div> - <div class="mapping_method_fields form-group"> - <label style="text-align:left;" class="col-xs-12 control-label">Manhattan Plot</label> - <div class="col-xs-12 controls"> - <label class="radio-inline"> - <input type="radio" name="manhattan_plot_pylmm" value="True"> - Yes - </label> - <label class="radio-inline"> - <input type="radio" name="manhattan_plot_pylmm" value="False" checked=""> - No - </label> - </div> - </div> ---> - <div class="form-group"> - <div style="padding-left:15px;" class="controls"> - <button id="pylmm_compute" class="btn submit_special btn-success" title="Compute Marker Regression"> - <i class="icon-ok-circle icon-white"></i> Compute - </button> + <label class="col-xs-3 control-label"></label> + <div style="margin-left:20px;" class="col-xs-6"> + <button id="pylmm_compute" class="btn submit_special btn-success" data-url="/marker_regression" title="Compute Interval Mapping"> + Compute + </button> </div> </div> </div> @@ -354,8 +343,8 @@ <div style="padding-top: 10px;" class="form-horizontal"> {% if genofiles and genofiles|length>0 %} <div class="mapping_method_fields form-group"> - <label for="genofiles" class="col-xs-3 control-label">Genotypes</label> - <div style="margin-left: 20px;" class="col-xs-8 controls"> + <label style="text-align:right;" class="col-xs-3 control-label">Genotypes</label> + <div style="margin-left: 20px;" class="col-xs-4 controls"> <select id="genofile_gemma" class="form-control"> {% for item in genofiles %} <option value="{{item['location']}}:{{item['title']}}">{{item['title']}}</option> @@ -365,29 +354,34 @@ </div> {% endif %} <div class="mapping_method_fields form-group"> - <label for="maf_gemma" class="col-xs-5 control-label">Minor allele threshold</label> - <div style="margin-left: 20px;" class="col-xs-3 controls"> + <label style="text-align:right;" class="col-xs-3 control-label">MAF</label> + <div style="margin-left: 20px;" class="col-xs-4 controls"> <input name="maf_gemma" value="0.01" type="text" class="form-control"> </div> </div> - </div> - - <div style="padding-top: 5px; padding-bottom: 5px; padding-left: 20px;" class="form-horizontal"> <div class="mapping_method_fields form-group"> - <button type="button" id="select_covariates" class="btn btn-default"> - Select Covariates - </button> - <button type="button" id="remove_covariates" class="btn btn-default"> - Remove Covariates - </button> + <label style="text-align: right;" class="col-xs-3 control-label">Covariates</label> + <div style="margin-left:20px;" class="col-xs-7"> + {% if g.user_session.user_ob and (g.user_session.user_ob.display_num_collections() == "") %} + No collections available. Please add traits to a collection to use them as covariates. + {% elif g.cookie_session.display_num_collections() == "" %} + No collections available. Please add traits to a collection to use them as covariates. + {% else %} + <div style="margin-bottom: 10px;" class="btn-group" role="group"> + <button type="button" id="select_covariates" class="btn btn-default">Select</button> + <button type="button" id="remove_covariates" class="btn btn-default">Remove</button> + </div> + <textarea rows="3" cols="20" readonly placeholder="No covariates selected" style="overflow-y: scroll; resize: none;" class="selected_covariates"></textarea> + {% endif %} + </div> </div> - </div> - - <div class="form-group"> - <div class="col-xs-4 controls"> + <div class="mapping_method_fields form-group"> + <label class="col-xs-3 control-label"></label> + <div style="margin-left:20px;" class="col-xs-6"> <button id="gemma_compute" class="btn submit_special btn-success" data-url="/marker_regression" title="Compute Marker Regression"> Compute </button> + </div> </div> </div> </div> @@ -395,16 +389,16 @@ <div class="tab-pane" id="plink"> <div style="padding: 20px" class="form-horizontal"> <div class="mapping_method_fields form-group"> - <label for="maf_plink" class="col-xs-3 control-label">Minor allele threshold</label> - <div style="margin-left: 20px;" class="col-xs-3 controls"> + <label style="text-align: right;" class="col-xs-3 control-label">MAF</label> + <div style="margin-left: 20px;" class="col-xs-4 controls"> <input name="maf_plink" value="0.01" type="text" class="form-control"> </div> </div> </div> <div class="form-group"> - <label for="plink_compute" class="col-xs-1 control-label"></label> - <div style="margin-left:20px;" class="col-xs-4 controls"> + <label style="text-align: right;" class="col-xs-3 control-label"></label> + <div style="margin-left:20px;" class="col-xs-6 controls"> <button id="plink_compute" class="btn submit_special btn-success" data-url="/marker_regression" title="Compute Marker Regression"> Compute </button> @@ -416,25 +410,29 @@ </div> </div> </div> - <div class="col-xs-6"> + <div class="col-xs-5"> {% if dataset.group.mapping_id == "1" %} <dl> + <dt>GEMMA</dt> + <dd>GEMMA is software implementing the Genome-wide Efficient Mixed Model Association algorithm for a standard linear mixed model for genome-wide association studies (GWAS).</dd> <dt>Interval Mapping</dt> <dd>Interval mapping is a process in which the statistical significance of a hypothetical QTL is evaluated at regular points across a chromosome, even in the absence of explicit genotype data at those points.</dd> - <dt>pyLMM</dt> - <dd>pyLMM is a fast and lightweight linear mixed-model (LMM) solver for use in genome-wide association studies (GWAS).</dd> <dt>R/qtl</dt> <dd>R/qtl is an extensible, interactive environment for mapping quantitative trait loci (QTL) in experimental crosses.</dd> + <dt>pyLMM</dt> + <dd>pyLMM is a fast and lightweight linear mixed-model (LMM) solver for use in genome-wide association studies (GWAS).</dd> </dl> {% else %} <dl> + {% if mapping_method == "GEMMA" %} <dt>GEMMA</dt> <dd> GEMMA is software implementing the Genome-wide Efficient Mixed Model Association algorithm for a standard linear mixed model for genome-wide association studies (GWAS).<br> - Note: There currently exists an issue where GEMMA can't be run on traits from the same group simultaneously. If you receive an error, please wait a few minutes and try again. </dd> + {% elif mapping_method == "PLINK" %} <dt>PLINK</dt> <dd>PLINK is a free, open-source whole genome association analysis toolset.</dd> + {% endif %} </dl> {% endif %} </div> diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 8476b6c5..3ebef046 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -582,7 +582,7 @@ def marker_regression_page(): 'control_marker', 'control_marker_db', 'do_control', - 'genofile', + 'genofile_string', 'pair_scan', 'startMb', 'endMb', @@ -743,7 +743,7 @@ def corr_matrix_page(): start_vars = request.form traits = [trait.strip() for trait in start_vars['trait_list'].split(',')] - if traits[0] != "": + if len(traits) > 1: template_vars = show_corr_matrix.CorrelationMatrix(start_vars) template_vars.js_data = json.dumps(template_vars.js_data, default=json_default_handler, |