5
stk_path = os.path.join( os.path.realpath(os.path.dirname(__file__)), os.pardir )
6
sys.path.insert(0, stk_path)
7
import supertree_toolkit as stk
12
'legend.fontsize': 25,
13
'xtick.labelsize': 25,
14
'ytick.labelsize': 25,
16
'axes.labelsize' : 32,
19
# need to do these to make room for labels
20
# no labels, then comment these out
21
'figure.subplot.top' : 0.75,
22
'figure.subplot.right' : 0.75,
24
rcParams.update(params)
30
parser = argparse.ArgumentParser(
31
prog="plot chracter taxa matrix",
32
description="""Plot a matrix of character availability against taxa""",
38
help="Verbose output: mainly progress reports.",
49
metavar='output_file',
51
help="The output graphics. .png, .pdf, or .svg"
55
args = parser.parse_args()
56
verbose = args.verbose
57
input_file = args.input_file[0]
58
output_file = args.output_file[0]
60
XML = stk.load_phyml(input_file)
61
all_taxa = stk.get_all_taxa(XML)
62
all_chars_d = stk.get_all_characters(XML)
65
all_chars.extend(all_chars_d[c])
67
taxa_character_matrix = {}
69
taxa_character_matrix[t] = []
71
trees = stk.obtain_trees(XML)
73
chars = stk.get_characters_from_tree(XML,t,sort=True)
74
taxa = stk.get_taxa_from_tree(XML,t, sort=True)
76
taxa_character_matrix[taxon].extend(chars)
78
for t in taxa_character_matrix:
79
array = taxa_character_matrix[t]
80
taxa_character_matrix[t] = list(set(array))
85
for i in range(0,len(all_taxa)):
86
for j in range(0,len(all_chars)):
87
if (all_chars[j] in taxa_character_matrix[all_taxa[i]]):
91
fig=figure(figsize=(22,17),dpi=90)
92
fig.subplots_adjust(left=0.3)
93
ax = fig.add_subplot(1,1,1)
94
ax.scatter(x,y,50,marker='o',c='r',lw=0)
95
yticks(range(0,len(all_chars)), all_chars)
96
ax.set_xlim(0,len(all_taxa))
97
ax.set_ylim(0,len(all_chars))
100
savefig(output_file, dpi=90)
102
if __name__ == "__main__":