aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorAlexander Kabui2022-03-24 22:04:53 +0300
committerAlexander Kabui2022-03-24 22:04:53 +0300
commit0ee7de23de1a29c909fb0a461d980f8474ecadb9 (patch)
tree23ac4e8b8aeec84db5d9fd36ce86b76dde15f1fd /wqflask
parent12598c7a6be757efcc040e8e160190cae0af4596 (diff)
downloadgenenetwork2-0ee7de23de1a29c909fb0a461d980f8474ecadb9.tar.gz
code refactoring
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/templates/gn3_wgcna_results.html21
-rw-r--r--wqflask/wqflask/wgcna/gn3_wgcna.py13
2 files changed, 13 insertions, 21 deletions
diff --git a/wqflask/wqflask/templates/gn3_wgcna_results.html b/wqflask/wqflask/templates/gn3_wgcna_results.html
index 3a517954..8a31bf28 100644
--- a/wqflask/wqflask/templates/gn3_wgcna_results.html
+++ b/wqflask/wqflask/templates/gn3_wgcna_results.html
@@ -139,30 +139,15 @@
<script type="text/javascript">
-let results = {{results|safe}}
-
-let parameters = {{parameters|safe}}
-
-let phenoModules = results["data"]["output"]["net_colors"]
+let phenoModules = {{results|safe}}["data"]["output"]["net_colors"]
let phenotypes = Object.keys(phenoModules)
let phenoMods = Object.values(phenoModules)
let {col_names,mod_dataset} = {{data|safe}}
-
-let {MinModuleSize,TOMtype,corType,mergeCutHeight} = parameters
-
const summary = {
-
- strain_numbers:6,
-
- nphe:12,
-
modules_found:phenoMods.length,
- MinModuleSize,
- TOMtype,
- corType,
- mergeCutHeight
-
+ ...{{parameters|safe}}
+
}
$("#summary").DataTable( {
diff --git a/wqflask/wqflask/wgcna/gn3_wgcna.py b/wqflask/wqflask/wgcna/gn3_wgcna.py
index 7bf5c62b..ab7fe46c 100644
--- a/wqflask/wqflask/wgcna/gn3_wgcna.py
+++ b/wqflask/wqflask/wgcna/gn3_wgcna.py
@@ -76,8 +76,6 @@ def run_wgcna(form_data):
wgcna_api = f"{GN3_LOCAL_URL}/api/wgcna/run_wgcna"
- # parse form data
-
trait_dataset = fetch_trait_data(form_data)
form_data["minModuleSize"] = int(form_data["MinModuleSize"])
@@ -86,8 +84,10 @@ def run_wgcna(form_data):
try:
+ unique_strains = list(set(trait_dataset["sample_names"]))
+
response = requests.post(wgcna_api, json={
- "sample_names": list(set(trait_dataset["sample_names"])),
+ "sample_names": unique_strains,
"trait_names": trait_dataset["trait_names"],
"trait_sample_data": list(trait_dataset["input"].values()),
**form_data
@@ -98,8 +98,15 @@ def run_wgcna(form_data):
status_code = response.status_code
response = response.json()
+ parameters = {
+ "nstrains": len(unique_strains),
+ "nphe": len(trait_dataset["trait_names"]),
+ **{key: val for key, val in form_data.items() if key not in ["trait_list"]}
+ }
+
return {"error": response} if status_code != 200 else {
"error": 'null',
+ "parameters": parameters,
"results": response,
"data": process_wgcna_data(response["data"]),
"image": process_image(response["data"])