forked from RuotoloLab/Fragariyo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCircosPlot.py
158 lines (122 loc) · 4.11 KB
/
CircosPlot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
"""
Author: Carolina Rojas Ramirez
Date: 02/20/20
Circos Plot
"""
import matplotlib.pyplot as plt
from nxviz import CircosPlot
from nxviz import ArcPlot
import networkx as nx
import numpy.random as npr
from random import choice
#Adding a node and an edge one at a time
# T.add_node(1, color = 'green')
# T.add_node(2, color = 'green')
# T.add_node(3, color = 'blue')
# T.add_node(4, color = 'blue')
# T.add_edge(1,2)
#
#Test
# Foo = nx.Graph()
# Foo.add_nodes_from(list(range(1, 3+1)), color = 'r', group='first')
# Foo.add_nodes_from(list(range(4, 7+1)), color = 'b', group='second')
# Foo.add_nodes_from(list(range(8, 10+1)), color = 'g', group='third')
# Foo.add_edges_from([(1, 4), (5, 7)])
# cp = CircosPlot(Foo, node_color='color', node_grouping='group', group_label_position="beginning", group_label_offset=0.25, fontsize=14)
# cp.draw()
# plt.show()
#
#
#
#
# G = nx.lollipop_graph(m=10, n=4)
# for n, d in G.nodes(data=True):
# G.node[n]["value"] = npr.normal()
# c = CircosPlot(G, node_color="value", node_order="value")
# c.draw()
# plt.show()
#
#
# G = nx.barbell_graph(m1=10, m2=3)
# for n, d in G.nodes(data=True):
# G.node[n]["class"] = choice(["one", "two", "three"])
# c = CircosPlot(G, node_color="class", node_order="class", node_labels=True)
# c.draw()
# plt.show()
# HSA = nx.Graph()
#
# #Signal Peptide
# HSA.add_nodes_from(list(range(1, 18+1)), color = 'p', group = 'Signal Peptide')
#
# #Propeptide
# HSA.add_nodes_from(list(range(19, 24+1)), color = 'r', group = 'Propeptide')
#
# #Domain1
# HSA.add_nodes_from(list(range(25, 211+1)), color = 'b', group = 'Domain I')
#
# #Domain2
# HSA.add_nodes_from(list(range(211, 403+1)), color = 'y', group = 'Domain II')
#
# #Domain3
# HSA.add_nodes_from(list(range(404, 600+1)), color = 'b', group = 'Domain III')
#
# #c-term
# HSA.add_nodes_from(list(range(600, 609+1)), color = 'g', group = "c-term")
#
# # T.add_nodes_from([1,2,3,4,5,6,7,8,9,10])
# # T.add_nodes_from([1,2], color = 'red')
# # T.add_nodes_from([3,4,5,6,7,8], color = 'blue')
#
#
# #Disulfide bond pairs
#
#
# disulfide_ls = [(77,86), (99,115), (114,125), (148,193), (192,201), (224,270), (269,277), (289,303), (302,313), (340,385),(384,393), (416,462), (461,472), (485,501), (500,511), (538,583), (582,591)]
# HSA.add_edges_from(disulfide_ls)
#
# #To remove all nodes and edges
# #T.clear()
#
#
# # nx.draw(T)
# # plt.show()
#
# print(HSA.nodes.data())
#
# c = CircosPlot(HSA, node_color='color', node_grouping='group', group_label_position="middle", group_label_offset=0.5, fontsize=14)
# c.draw()
# plt.show()
HSA_matches = nx.Graph()
#Signal Peptide+Propeptide
HSA_matches.add_nodes_from(list(range(1, 5+1)), color = 'p', group = 'n-term')
HSA_matches.add_nodes_from(list(range(6, 609+1)), color = 'g', group = "c-term")
# T.add_nodes_from([1,2,3,4,5,6,7,8,9,10])
# T.add_nodes_from([1,2], color = 'red')
# T.add_nodes_from([3,4,5,6,7,8], color = 'blue')
#Disulfide bond pairs
disulfide_ls = [(77,86), (99,115), (114,125), (148,193), (192,201), (224,270), (269,277), (289,303), (302,313), (340,385),(384,393), (416,462), (461,472), (485,501), (500,511), (538,583), (582,591)]
HSA_matches.add_edges_from(disulfide_ls)
#To remove all nodes and edges
#T.clear()
# nx.draw(T)
# plt.show()
print(HSA_matches.nodes.data())
c = CircosPlot(HSA_matches, node_color='color', node_grouping='group', group_label_position="middle", group_label_offset=0.5, fontsize=14)
c.draw()
plt.show()
#Notch3
# Notch= nx.Graph()
#
# Notch.add_nodes_from(list(range(1, 30+1)), color = 'p')
# Notch.add_nodes_from(list(range(31, 55+1)), color = 'r')
# Notch.add_nodes_from(list(range(56, 61+1)), color = 'b')
# Notch.add_nodes_from(list(range(62, 270+1)), color = 'r')
# Notch.add_nodes_from(list(range(271, 397+1)), color = 'g')
# notchss_ls = [(43+271, 55+271), (49+271,65+271), (67+271,76+271), (82+271,93+271), (87+271,106+271), (108+271,117+271)]
# Notch.add_edges_from(notchss_ls)
# n = CircosPlot(Notch, node_color='color')
# n.draw()
# plt.show()
# a = ArcPlot(T)
# a.draw()
# plt.show()