Skip to content

Commit

Permalink
Merge pull request #107 from dengzq1234/desktop_v2
Browse files Browse the repository at this point in the history
Desktop v2
  • Loading branch information
dengzq1234 authored Dec 18, 2024
2 parents ff084c5 + 06f833e commit 7f593bc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
1 change: 0 additions & 1 deletion treeprofiler/layouts/profile_layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 9 additions & 6 deletions treeprofiler/tree_annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
'dup_sp': str,
'dup_percent': float,
'lca': str,
'common_name': str,
'species': str,
}

# Global Variable for emapper headers
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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']

Expand Down Expand Up @@ -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']
Expand Down
26 changes: 10 additions & 16 deletions treeprofiler/tree_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7f593bc

Please sign in to comment.