4

Working in python with matplotlib, venn3 and venn3_circles.

I am trying to get the list of elements of each intersection in a 3 circles venn diagram.

I will use the example here

from matplotlib import pyplot as plt
import numpy as np
from matplotlib_venn import venn3, venn3_circles


A = set(['DPEP1', 'CDC42BPA', 'GNG4', 'RAPGEFL1', 'MYH7B', 'SLC13A3', 'PHACTR3', 'SMPX', 'NELL2', 'PNMAL1', 'KRT23', 'PCP4', 'LOX', 'CDC42BPA'])
B = set(['ABLIM1','CDC42BPA','VSNL1','LOX','PCP4','SLC13A3'])
C = set(['PLCB4', 'VSNL1', 'TOX3', 'VAV3'])

v = venn3([A,B,C], ('GCPromoters', 'OCPromoters', 'GCSuppressors'))

ppp=v.get_label_by_id('100').set_text('\n'.join(A-B-C))
v.get_label_by_id('110').set_text('\n'.join(A&B-C))
v.get_label_by_id('011').set_text('\n'.join(B&C-A))
v.get_label_by_id('001').set_text('\n'.join(C-A-B))
v.get_label_by_id('010').set_text('')
plt.annotate(',\n'.join(B-A-C), xy=v.get_label_by_id('010').get_position() +
             np.array([0, 0.2]), xytext=(-20,40), ha='center',
             textcoords='offset points', 
             bbox=dict(boxstyle='round,pad=0.5', fc='gray', alpha=0.1),
             arrowprops=dict(arrowstyle='->',              
                             connectionstyle='arc',color='gray'))

In the example, they can show in the graphical venn diagram the contents of each intersection enter image description here

How can I store in a variable/list the contents of each intersection?

I want to get something like this:

A:[MYH7B, PHACTR3,...,DPEP1]
AB: [LOX,...,PCP4]
B: [ABLIM1]
ABC: empty
B: empty
BC: [VSNL1]
C: [TOX3,VAV3,PLCB4]

Where A, AB, ABC, C,... are lists in python

daniel_hck
  • 1,100
  • 3
  • 19
  • 38

1 Answers1

0

why would you not store it as an array using the alphanumeric 'token' as an index and a array of 3 integer flags [A, B, C]

so you would have items listed as

 - ['MYH7B', [ 1, 0, 0 ]],
 - ['LOX',   [ 1, 1, 0 ]],
 - ['ABLIM1',[ 0, 1, 0 ]],
 - ['VSNL1', [ 0, 1, 1 ]],
 - ['TOX3',  [ 0, 0, 1 ]]

as examples and then you slice the array to find pattern matches.

It is clear, concise and minimizes storage while maximizing versatility.

If you actually want to represent the 'B' Section as 2 subsections 'B1' and 'B2' then you would just add one additional column...[A , B1, B2, C]

 - ['MYH7B', [ 1, 0, 0, 0 ]],
 - ['LOX',   [ 1, 1, 0, 0 ]],
 - ['ABLIM1',[ 0, 1, 0, 0 ]],
 - ['VSNL1', [ 0, 1, 0, 1 ]],
 - ['TOX3',  [ 0, 0, 0, 1 ]]
webmite
  • 575
  • 3
  • 6