diff options
author | zsloan | 2021-06-17 19:45:40 +0000 |
---|---|---|
committer | zsloan | 2021-06-17 19:45:40 +0000 |
commit | e5a8fad251bff8160e49c6c9fea42b815488e6c3 (patch) | |
tree | 1eeea63a4e58f444accc7cef9b067af4e684ee01 /wqflask | |
parent | 90a427fcc855910a812f3cee710ede335071768a (diff) | |
download | genenetwork2-e5a8fad251bff8160e49c6c9fea42b815488e6c3.tar.gz |
Added function for getting list of attributes with all numerical values (that can be used with the 'Filter by value' feature)
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/show_trait/show_trait.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 9ee6a16d..c07430dd 100644 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -177,10 +177,13 @@ class ShowTrait: sample_lists = [group.sample_list for group in self.sample_groups] categorical_var_list = [] + self.numerical_var_list = [] if not self.temp_trait: # ZS: Only using first samplelist, since I think mapping only uses those samples categorical_var_list = get_categorical_variables( self.this_trait, self.sample_groups[0]) + self.numerical_var_list = get_numerical_variables( + self.this_trait, self.sample_groups[0]) # ZS: Get list of chromosomes to select for mapping self.chr_list = [["All", -1]] @@ -694,6 +697,26 @@ def get_categorical_variables(this_trait, sample_list) -> list: return categorical_var_list +def get_numerical_variables(this_trait, sample_list) -> list: + numerical_var_list = [] + + if len(sample_list.attributes) > 0: + for attribute in sample_list.attributes: + all_numeric = True + all_none = True + for attr_val in sample_list.attributes[attribute].distinct_values: + if not attr_val: + continue + try: + val_as_float = float(attr_val) + all_none = False + except: + all_numeric = False + break + if all_numeric and not all_none: + numerical_var_list.append(sample_list.attributes[attribute].name) + + return numerical_var_list def get_genotype_scales(genofiles): geno_scales = {} |