3

在 python 中使用 matplotlib、venn3 和 venn3_circles。

我正在尝试在 3 圈维恩图中获取每个交叉点的元素列表。

我将在这里使用示例

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'))

在示例中,他们可以在图形维恩图中显示每个交叉点的内容 在此处输入图像描述

如何将每个交叉点的内容存储在变量/列表中?

我想得到这样的东西:

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

其中A,AB,ABC,C,...是python中的列表

4

1 回答 1

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 ]]
于 2018-05-04T22:16:05.300 回答