diff --git a/treeprofiler/layouts/profile_layouts.py b/treeprofiler/layouts/profile_layouts.py index 95e54c9..ef37a8c 100644 --- a/treeprofiler/layouts/profile_layouts.py +++ b/treeprofiler/layouts/profile_layouts.py @@ -357,7 +357,6 @@ def get_array(self, node): def set_node_style(self, node): array = self.get_array(node) - #array = self.get_array(node) if array: if not self.is_list: if len(self.matrix_props) > 1: diff --git a/treeprofiler/tree_annotate.py b/treeprofiler/tree_annotate.py index 211e9ba..e4a5a72 100644 --- a/treeprofiler/tree_annotate.py +++ b/treeprofiler/tree_annotate.py @@ -39,6 +39,8 @@ 'dup_sp': str, 'dup_percent': float, 'lca': str, + 'common_name': str, + 'species': str, } # Global Variable for emapper headers @@ -269,7 +271,7 @@ def run_tree_annotate(tree, input_annotated_tree=False, total_color_dict = [] layouts = [] level = 1 # level 1 is the leaf name - taxa_props = ['rank', 'sci_name', 'taxid', 'lineage', 'named_lineage', 'lca', 'evoltype', 'common_name', 'species'] + if text_prop: text_prop = text_prop else: @@ -352,12 +354,12 @@ def run_tree_annotate(tree, input_annotated_tree=False, else: if dtype == list: - multiple_text_prop.append(key) + if key not in TAXONOMICDICT.keys(): + multiple_text_prop.append(key) if dtype == str: - if key not in multiple_text_prop and key not in taxa_props: + if key not in multiple_text_prop and key not in TAXONOMICDICT.keys(): text_prop.append(key) - else: - pass + if dtype == float: num_prop.append(key) if dtype == bool: @@ -736,6 +738,8 @@ def run(args): prop2type.update(utils.get_prop2type(node)) del prop2type['name'] del prop2type['dist'] + if '__id' in prop2type: + del prop2type['__id'] if 'support' in prop2type: del prop2type['support'] @@ -1380,7 +1384,6 @@ def merge_text_annotations(nodes, target_props, column2method, emapper_mode=Fals for target_prop in target_props: counter_stat = column2method.get(target_prop, "raw") prop_list = utils.children_prop_array_missing(nodes, target_prop) - counter = dict(Counter(prop_list)) # Store the counter if 'NaN' in counter: del counter['NaN'] diff --git a/treeprofiler/tree_plot.py b/treeprofiler/tree_plot.py index fa7262b..00ae71f 100644 --- a/treeprofiler/tree_plot.py +++ b/treeprofiler/tree_plot.py @@ -689,7 +689,7 @@ def run(args): matrix, minval, maxval, value2color, results_list, list_props, single_props = numerical2matrix(tree, numerical_props, count_negative=True, internal_num_rep=internal_num_rep, color_config=color_config, norm_method='min-max') - + if list_props: index_map = {value: idx for idx, value in enumerate(numerical_props)} sorted_list_props = sorted(list_props, key=lambda x: index_map[x]) @@ -1990,23 +1990,17 @@ def process_color_configuration(node2matrix, profiling_props=None): for node in tree.traverse(): node2matrix_single[node.name] = [] for profiling_prop in profiling_props: - if node.is_leaf: - prop_value = node.props.get(profiling_prop) - if prop_value is not None: - if isinstance(prop_value, list): - list_props.add(profiling_prop) - prop_value = list(map(float, prop_value)) - if node.name not in node2matrix_list[profiling_prop]: - node2matrix_list[profiling_prop][node.name] = [] - node2matrix_list[profiling_prop][node.name] = prop_value - else: - single_props.add(profiling_prop) - node2matrix_single[node.name].append(float(prop_value)) - else: - node2matrix_single[node.name].append(None) + prop_value = node.props.get(profiling_prop) + if prop_value is not None: + if isinstance(prop_value, list): + list_props.add(profiling_prop) + prop_value = list(map(float, prop_value)) if node.name not in node2matrix_list[profiling_prop]: node2matrix_list[profiling_prop][node.name] = [] - node2matrix_list[profiling_prop][node.name].append(None) + node2matrix_list[profiling_prop][node.name] = prop_value + else: + single_props.add(profiling_prop) + node2matrix_single[node.name].append(float(prop_value)) else: if internal_num_rep != 'none': representative_prop = utils.add_suffix(profiling_prop, internal_num_rep)