#----------------------------------------------------------------------------------------------------------------------
-def generate_venn(venn_data) :
+def generate_venn(venn_data, colors, is_ref, ref_species, proj_species, reciprocal_id, confidence) :
#----------------------------------------------------------------------------------------------------------------------
"""build and display Venn diagrams representing reference loci overlap"""
- intersection_ref_loci = len(venn_data[0] & venn_data[1])
- union_ref_loci = len(venn_data[0] | venn_data[1])
- inp_exc_ref_loci = len(venn_data[0] - venn_data[1])
- cmp_exc_ref_loci = len(venn_data[1] - venn_data[0])
+ intersection_loci = len(venn_data[0] & venn_data[1])
+ union_loci = len(venn_data[0] | venn_data[1])
+ inp_exc_loci = len(venn_data[0] - venn_data[1])
+ cmp_exc_loci = len(venn_data[1] - venn_data[0])
+
+ plt.figure(figsize=(8, 7))
v = venn2(venn_data, ('Inparanoid', 'Compara'))
v.get_patch_by_id('10').set_alpha(0.5)
- v.get_patch_by_id('10').set_color('red')
+ v.get_patch_by_id('10').set_color(colors[0])
v.get_patch_by_id('01').set_alpha(0.5)
- v.get_patch_by_id('01').set_color('yellow')
+ v.get_patch_by_id('01').set_color(colors[1])
v.get_patch_by_id('11').set_alpha(0.75)
- v.get_patch_by_id('11').set_color('orange')
+ v.get_patch_by_id('11').set_color(colors[2])
- v.get_label_by_id('10').set_text(str(inp_exc_ref_loci))
- v.get_label_by_id('01').set_text(str(cmp_exc_ref_loci))
- v.get_label_by_id('11').set_text(str(intersection_ref_loci))
+ v.get_label_by_id('10').set_text(str(inp_exc_loci))
+ v.get_label_by_id('01').set_text(str(cmp_exc_loci))
+ v.get_label_by_id('11').set_text(str(intersection_loci))
v.get_label_by_id('A').set_text('')
v.get_label_by_id('B').set_text('')
-
- #v.get_label_by_id('A').set_size(20)
- #v.get_label_by_id('B').set_size(20)
-
+
plt.annotate('Inparanoid', xy = v.get_label_by_id('10').get_position(), xytext = (-30,-70), size = 'x-large',
- ha = 'center', textcoords = 'offset points', bbox = dict(boxstyle = 'round, pad=0.5', fc = '#cc88ff', alpha = 0.3))
+ ha = 'center', textcoords = 'offset points', bbox = dict(boxstyle = 'round, pad=0.5', fc = colors[3], alpha = 0.3))
plt.annotate('Compara', xy = v.get_label_by_id('01').get_position(), xytext = (30,-70), size = 'x-large',
- ha = 'center', textcoords = 'offset points', bbox = dict(boxstyle = 'round, pad = 0.5', fc = 'lime', alpha = 0.3))
-
- #plt.annotate('Reference Loci (' + str(union_ref_loci) + ' total)', xy = v.get_label_by_id('11').get_position(), xytext = (0,0), size = 'xx-large',
- # ha = 'center', textcoords = 'offset points', bbox = dict(boxstyle = 'round, pad=0.5', fc = 'black', alpha = 0.0))
+ ha = 'center', textcoords = 'offset points', bbox = dict(boxstyle = 'round, pad = 0.5', fc = colors[4], alpha = 0.3))
+ plt.title('Overlap of ' + ref_species + (' reference ' if not is_ref else ' projection ') + 'loci (' + str(union_loci) + ' total)\nbetween Inparanoid super-clusters and Compara orthology data,\ngiven ' + str(reciprocal_id) + '% Compara reciprocal identity' + (', high-confidence only' if confidence else ''))
+
plt.show()
parser.add_argument('-r', '--reciprocal_id', type=int, help='reciprocal identity percentage')
parser.add_argument('-C', '--confidence_high', help='only use ensembl projections marked as high-confidence', action='store_true')
parser.add_argument('-u', '--uniprot_substitution', help='file path to UniProt substitution data for reference loci')
+parser.add_argument('--ref_species', help='reference species')
+parser.add_argument('--proj_species', help='projection species')
# TODO: add an "inparanoid super-cluster vs. conventional input" flag
# output settings
# NOTE: requires local matplotlib backend configuration
if args.venn_diagram :
- generate_venn(venn_data)
+ generate_venn(venn_data, ['red', 'yellow', 'orange', 'purple', 'lime'], 0, args.ref_species, args.proj_species, args.reciprocal_id, 1 if args.confidence_high else 0)
+ generate_venn(venn_data, ['green', 'yellow', 'lightgreen', 'purple', 'lime'], 1, args.ref_species, args.proj_species, args.reciprocal_id, 1 if args.confidence_high else 0)
#----------------------------------------------------------------------------------------------------------------------
# end