aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base
diff options
context:
space:
mode:
authorzsloan2019-03-18 17:03:30 -0500
committerzsloan2019-03-18 17:03:30 -0500
commitd515061c4878b448f5b866e32eee7e37301ecdb7 (patch)
treef88efd6fb87044065d68ff1602a8d57692de5f1f /wqflask/base
parentf8f0a2aecd14b7a45172d67d7eac3c9c2ac3618f (diff)
downloadgenenetwork2-d515061c4878b448f5b866e32eee7e37301ecdb7.tar.gz
- Added PCA traits to correlation matrix. You can't change their names yet or add them to a collection from the corr matrix page,
but you can click them and access them from the trait page. I'll add the option to access them from the corr matrix page as well, but adding the option to change their names might be trickier since they're currently used as their Redis keys. I need some better way of passing the Redis key around so it can be stored in collections, but this is tricky without changing the structure in ElasticSearch - Fixed the way temp traits work so you can use them with various functions, like mapping, correlations, network graph, etc - Fixed some appearance issue where the network graph options were too wide if a trait name was too long
Diffstat (limited to 'wqflask/base')
-rw-r--r--wqflask/base/data_set.py3
-rw-r--r--wqflask/base/trait.py40
2 files changed, 28 insertions, 15 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index ca6621e9..beb2a8a2 100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -277,7 +277,6 @@ class DatasetGroup(object):
"""
def __init__(self, dataset, name=None):
"""This sets self.group and self.group_id"""
- #logger.debug("DATASET NAME2:", dataset.name)
if name == None:
self.name, self.id, self.genetic_type = fetchone(dataset.query_for_group)
else:
@@ -500,7 +499,7 @@ class DataSet(object):
self.setup()
if self.type == "Temp": #Need to supply group name as input if temp trait
- self.group = DatasetGroup(self, group_name) # sets self.group and self.group_id and gets genotype
+ self.group = DatasetGroup(self, name=group_name) # sets self.group and self.group_id and gets genotype
else:
self.check_confidentiality()
self.retrieve_other_names()
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 79aa196f..0689e950 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -6,6 +6,9 @@ import codecs
from htmlgen import HTMLgen2 as HT
+import redis
+Redis = redis.StrictRedis()
+
from base import webqtlConfig
from base.webqtlCaseData import webqtlCaseData
from base.data_set import create_dataset
@@ -35,13 +38,15 @@ class GeneralTrait(object):
def __init__(self, get_qtl_info=False, get_sample_info=True, **kw):
# xor assertion
assert bool(kw.get('dataset')) != bool(kw.get('dataset_name')), "Needs dataset ob. or name";
+ self.name = kw.get('name') # Trait ID, ProbeSet ID, Published ID, etc.
if kw.get('dataset_name'):
- self.dataset = create_dataset(kw.get('dataset_name'))
- #print(" in GeneralTrait created dataset:", self.dataset)
+ if kw.get('dataset_name') == "Temp":
+ temp_group = self.name.split("_")[2]
+ self.dataset = create_dataset(dataset_name = "Temp", dataset_type = "Temp", group_name = temp_group)
+ else:
+ self.dataset = create_dataset(kw.get('dataset_name'))
else:
self.dataset = kw.get('dataset')
- self.name = kw.get('name') # Trait ID, ProbeSet ID, Published ID, etc.
- #print("THE NAME IS:", self.name)
self.cellid = kw.get('cellid')
self.identification = kw.get('identification', 'un-named trait')
self.haveinfo = kw.get('haveinfo', False)
@@ -73,8 +78,8 @@ class GeneralTrait(object):
# So we could add a simple if statement to short-circuit this if necessary
if self.dataset.type != "Temp":
self = retrieve_trait_info(self, self.dataset, get_qtl_info=get_qtl_info)
- if get_sample_info != False:
- self = retrieve_sample_data(self, self.dataset)
+ if get_sample_info != False:
+ self = retrieve_sample_data(self, self.dataset)
def export_informative(self, include_variance=0):
"""
@@ -154,18 +159,27 @@ def retrieve_sample_data(trait, dataset, samplelist=None):
if samplelist == None:
samplelist = []
- results = dataset.retrieve_sample_data(trait.name)
+ if dataset.type == "Temp":
+ results = Redis.get(trait.name).split()
+ else:
+ results = dataset.retrieve_sample_data(trait.name)
# Todo: is this necessary? If not remove
trait.data.clear()
- all_samples_ordered = dataset.group.all_samples_ordered()
-
if results:
- for item in results:
- name, value, variance, num_cases, name2 = item
- if not samplelist or (samplelist and name in samplelist):
- trait.data[name] = webqtlCaseData(*item) #name, value, variance, num_cases)
+ if dataset.type == "Temp":
+ all_samples_ordered = dataset.group.all_samples_ordered()
+ for i, item in enumerate(results):
+ try:
+ trait.data[all_samples_ordered[i]] = webqtlCaseData(all_samples_ordered[i], float(item))
+ except:
+ pass
+ else:
+ for item in results:
+ name, value, variance, num_cases, name2 = item
+ if not samplelist or (samplelist and name in samplelist):
+ trait.data[name] = webqtlCaseData(*item) #name, value, variance, num_cases)
return trait
@app.route("/trait/get_sample_data")