@@ -694,7 +694,7 @@ def run_tree_annotate(tree, input_annotated_tree=False,
694694 return annotated_tree , prop2type
695695
696696
697- def run_array_annotate (tree , array_dict , num_stat = 'none' , column2method = {}):
697+ def run_array_annotate (tree , array_dict , num_stat = 'none' , column2method = {}, prop2type = {} ):
698698 matrix_props = list (array_dict .keys ())
699699 # annotate to the leaves
700700 start = time .time ()
@@ -708,17 +708,20 @@ def run_array_annotate(tree, array_dict, num_stat='none', column2method={}):
708708 for node in tree .traverse ():
709709 if not node .is_leaf :
710710 for prop in matrix_props :
711+
711712 # get the array from the children leaf nodes
712713 arrays = [child .get_prop (prop ) for child in node .leaves () if child .get_prop (prop ) is not None ]
713714
714715 if column2method .get (prop ) is not None :
715716 num_stat = column2method .get (prop )
716717
717718 stats = compute_matrix_statistics (arrays , num_stat = num_stat )
719+
718720 if stats :
719721 for stat , value in stats .items ():
722+
720723 node .add_prop (utils .add_suffix (prop , stat ), value .tolist ())
721- # prop2type[utils.add_suffix(prop, stat)] = float
724+ prop2type [utils .add_suffix (prop , stat )] = list
722725 end = time .time ()
723726 logger .info (f'Time for run_array_annotate to run: { end - start } ' )
724727 return tree
@@ -915,7 +918,7 @@ def run(args):
915918 )
916919
917920 if args .data_matrix :
918- annotated_tree = run_array_annotate (annotated_tree , array_dict , num_stat = args .num_stat , column2method = column2method )
921+ annotated_tree = run_array_annotate (annotated_tree , array_dict , num_stat = args .num_stat , column2method = column2method , prop2type = prop2type )
919922 # update prop2type
920923 for filename in array_dict .keys ():
921924 prop2type [filename ] = list
@@ -954,12 +957,20 @@ def run(args):
954957 list_keys = [key for key , value in prop2type .items () if value == list ]
955958 # Replace all commas in the tree with '||'
956959 list_sep = '||'
957- for node in annotated_tree .leaves ():
958- for key in list_keys :
959- if node .props .get (key ):
960- cont2str = list (map (str , node .props .get (key )))
961- list2str = list_sep .join (cont2str )
962- node .add_prop (key , list2str )
960+ if args .data_matrix and args .num_stat != 'none' :
961+ for node in annotated_tree .traverse ():
962+ for key in list_keys :
963+ if node .props .get (key ):
964+ cont2str = list (map (str , node .props .get (key )))
965+ list2str = list_sep .join (cont2str )
966+ node .add_prop (key , list2str )
967+ else :
968+ for node in annotated_tree .leaves ():
969+ for key in list_keys :
970+ if node .props .get (key ):
971+ cont2str = list (map (str , node .props .get (key )))
972+ list2str = list_sep .join (cont2str )
973+ node .add_prop (key , list2str )
963974
964975
965976 avail_props = list (prop2type .keys ())
0 commit comments