aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wqflask/wqflask/correlation_matrix/show_corr_matrix.py11
-rw-r--r--wqflask/wqflask/templates/correlation_matrix.html6
-rw-r--r--wqflask/wqflask/templates/pca_scree_plot.html14
-rw-r--r--wqflask/wqflask/templates/show_trait_calculate_correlations.html3
4 files changed, 24 insertions, 10 deletions
diff --git a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
index 88d62045..cf37b9e9 100644
--- a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
+++ b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
@@ -37,6 +37,7 @@ from gn3.computations.pca import compute_pca
from gn3.computations.pca import process_factor_loadings_tdata
from gn3.computations.pca import generate_pca_temp_traits
from gn3.computations.pca import cache_pca_dataset
+from gn3.computations.pca import generate_scree_plot_data
class CorrelationMatrix:
@@ -169,6 +170,7 @@ class CorrelationMatrix:
pca = self.calculate_pca()
self.loadings_array = process_factor_loadings_tdata(
factor_loadings=self.loadings, traits_num=len(self.trait_list))
+
else:
self.pca_works = "False"
except:
@@ -176,6 +178,7 @@ class CorrelationMatrix:
self.js_data = dict(traits=[trait.name for trait in self.traits],
groups=groups,
+ scree_data = self.scree_data,
cols=list(range(len(self.traits))),
rows=list(range(len(self.traits))),
samples=self.all_sample_list,
@@ -187,6 +190,7 @@ class CorrelationMatrix:
self.loadings = pca["components"]
self.scores = pca["scores"]
+ self.pca_obj = pca["pca"]
this_group_name = self.trait_list[0][1].group.name
temp_dataset = create_dataset(
@@ -205,6 +209,13 @@ class CorrelationMatrix:
self.pca_trait_ids = list(pca_temp_traits.keys())
+ x_coord, y_coord = generate_scree_plot_data(
+ list(self.pca_obj.explained_variance_ratio_))
+
+ self.scree_data = {
+ "x_coord": x_coord,
+ "y_coord": y_coord
+ }
return pca
diff --git a/wqflask/wqflask/templates/correlation_matrix.html b/wqflask/wqflask/templates/correlation_matrix.html
index 3da6981c..e90accf2 100644
--- a/wqflask/wqflask/templates/correlation_matrix.html
+++ b/wqflask/wqflask/templates/correlation_matrix.html
@@ -71,6 +71,12 @@
<button class="btn btn-default" id="export">Download <span class="glyphicon glyphicon-download"></span></button>
</form>
<br>
+
+<div style="margin:20x;">
+ {% include 'pca_scree_plot.html' %}
+
+</div>
+
{% if pca_works == "True" %}
<h2>PCA Traits</h2>
<div style="margin-bottom: 20px; overflow:hidden; width: 450px;">
diff --git a/wqflask/wqflask/templates/pca_scree_plot.html b/wqflask/wqflask/templates/pca_scree_plot.html
index 41036333..11bfebff 100644
--- a/wqflask/wqflask/templates/pca_scree_plot.html
+++ b/wqflask/wqflask/templates/pca_scree_plot.html
@@ -9,25 +9,25 @@
<body>
<div>
- pca scree plot
+
<div id="scree_plot" style="width:700px;height:600px;"></div>
</div>
</body>
<script type="text/javascript" src="{{ url_for('js', filename='plotly/plotly.min.js') }}"></script>
<script type="text/javascript">
-js_data = { { js_data | safe } }
-
+js_data = {{ js_data | safe }}
let { x_coord, y_coord } = js_data["scree_data"]
+
const layout = {
title: {
- text: "<b>Scree Plot</b>",
+ text: "<b>Pca Scree Plot</b>",
font: {
"size": 24,
"family": "Arial",
- "color": "#FF0000"
+ "color": "#000000"
}
},
@@ -77,8 +77,8 @@ let custom_configs = (filename, download_format, modebar = true) => {
displayModeBar: modebar,
scrollZoom: false,
toImageButtonOptions: {
- download_format,
filename,
+ format:download_format,
height: 600,
width: 700,
scale: 1
@@ -87,7 +87,7 @@ let custom_configs = (filename, download_format, modebar = true) => {
}
-Plotly.newPlot(document.getElementById(), data, layout,
+Plotly.newPlot(document.getElementById("scree_plot"), data, layout,
custom_configs(file_name = "scree_plot", download_format = "svg"));
</script>
diff --git a/wqflask/wqflask/templates/show_trait_calculate_correlations.html b/wqflask/wqflask/templates/show_trait_calculate_correlations.html
index 16a819fa..2f98f14e 100644
--- a/wqflask/wqflask/templates/show_trait_calculate_correlations.html
+++ b/wqflask/wqflask/templates/show_trait_calculate_correlations.html
@@ -119,9 +119,6 @@
<div class="col-xs-3 controls">
<input type="button" class="btn corr_compute submit_special btn-success" data-url="/corr_compute" title="Compute Correlation" value="Compute">
</div>
- <div class="col-xs-3 controls">
- <input type="button" class="btn test_corr_compute submit_special btn-success" data-url="/test_corr_compute" title="Compute Correlation" value="Test Compute">
- </div>
</div>
</div>
</div>