Spaces:
Running
Running
set node color by type
Browse files
app.py
CHANGED
@@ -131,6 +131,10 @@ for i in range(len(neighbors.index)):
|
|
131 |
layout = nx.spring_layout(G)
|
132 |
|
133 |
|
|
|
|
|
|
|
|
|
134 |
|
135 |
elements = []
|
136 |
for i in range(len(node_info.index)):
|
@@ -138,7 +142,8 @@ for i in range(len(node_info.index)):
|
|
138 |
elements.append({
|
139 |
"data": {
|
140 |
"id": node["gene_id"],
|
141 |
-
"label": node["gene_name"] if node["gene_name"] is not None else node["gene_id"]
|
|
|
142 |
"position": {
|
143 |
"x" : layout[node["gene_index"]][0] * 600 + 1500/2,
|
144 |
"y" : layout[node["gene_index"]][1] * 600 + 1500/2}})
|
@@ -149,7 +154,7 @@ for i in range(len(neighbors.index)):
|
|
149 |
"data" : {
|
150 |
"source" : edge["gene_id_1"],
|
151 |
"target" : edge["gene_id_2"],
|
152 |
-
"label" : edge["coexp_score"]}})
|
153 |
|
154 |
|
155 |
with col3:
|
@@ -169,7 +174,7 @@ stylesheet = [
|
|
169 |
"shape": "rectangle",
|
170 |
"label" : "data(label)",
|
171 |
"labelFontSize": 100,
|
172 |
-
'background-color': '
|
173 |
"text-halign": "center",
|
174 |
"text-valign": "center",
|
175 |
}},
|
|
|
131 |
layout = nx.spring_layout(G)
|
132 |
|
133 |
|
134 |
+
node_color_lut = {
|
135 |
+
"seed" : "#4866F0", # blue
|
136 |
+
"neighbor" : "#F0C547" # gold
|
137 |
+
}
|
138 |
|
139 |
elements = []
|
140 |
for i in range(len(node_info.index)):
|
|
|
142 |
elements.append({
|
143 |
"data": {
|
144 |
"id": node["gene_id"],
|
145 |
+
"label": node["gene_name"] if node["gene_name"] is not None else node["gene_id"],
|
146 |
+
"color": node_color_lut[node["gene_type"]]},
|
147 |
"position": {
|
148 |
"x" : layout[node["gene_index"]][0] * 600 + 1500/2,
|
149 |
"y" : layout[node["gene_index"]][1] * 600 + 1500/2}})
|
|
|
154 |
"data" : {
|
155 |
"source" : edge["gene_id_1"],
|
156 |
"target" : edge["gene_id_2"],
|
157 |
+
"label" : edge["coexp_score"] * 20}})
|
158 |
|
159 |
|
160 |
with col3:
|
|
|
174 |
"shape": "rectangle",
|
175 |
"label" : "data(label)",
|
176 |
"labelFontSize": 100,
|
177 |
+
'background-color': 'data(color)',
|
178 |
"text-halign": "center",
|
179 |
"text-valign": "center",
|
180 |
}},
|