@@ -47,22 +47,15 @@ def change_collapse_state(selection_val):
47
47
return False
48
48
49
49
50
- def change_continuous_state (chkbox_state ):
51
- if chkbox_state :
52
- return config .continuous_colormap_dict
53
- else :
54
- return config .categorical_colormap_dict
55
-
56
-
57
- def change_continuous_state_for_value (chkbox_state ):
58
- if chkbox_state :
59
- return config .continuous_colormap_dict ['cet_rainbow4' ]
50
+ def change_disabled_state_threshold (value ):
51
+ if value == 'Define another threshold' :
52
+ return False
60
53
else :
61
- return config . categorical_colormap_dict [ 'cet_glasbey' ]
54
+ return True
62
55
63
56
64
- def change_disabled_state_threshold (value ):
65
- if value == 'Define another threshold' :
57
+ def change_disabled_state_custom_colormap (value ):
58
+ if value == config . categorical_colormap_dict [ 'Define custom colormap' ] :
66
59
return False
67
60
else :
68
61
return True
@@ -152,6 +145,7 @@ def __init__(self):
152
145
self .feature_select_watcher = ""
153
146
self .continuous_watcher = ""
154
147
self .colormap_watcher = ""
148
+ self .custom_colormap_watcher = ""
155
149
self .nodes_colorby_watcher = ""
156
150
self .visited_multi_genome_tab = 0
157
151
@@ -332,7 +326,7 @@ def __init__(self):
332
326
self .use_metadata_network = pn .widgets .Checkbox (name = 'Use metadata for coloring' , value = False )
333
327
self .color_edges_by_feature = pn .widgets .Checkbox (name = 'Color edges by feature (same/different)' , value = False )
334
328
self .metadata_colorby_card = pn .Card (title = 'Set the coloring by metadata' , header_background = "#ffffff" ,
335
- styles = {'background' : "#ffffff" , 'margin' : "10px" , 'width' : "300px " },
329
+ styles = {'background' : "#ffffff" , 'margin' : "10px" , 'width' : "335px " },
336
330
hide_header = True , collapsed = pn .bind (change_disabled_state_inverse ,
337
331
chkbox_state = self .use_metadata_network ,
338
332
watch = True ))
@@ -344,11 +338,18 @@ def __init__(self):
344
338
disabled = pn .bind (change_disabled_state_straight ,
345
339
chkbox_state = self .use_metadata_network ,
346
340
watch = True ))
347
- self .nodes_color_by = pn .widgets .Select (options = ['Select feature' ], name = "Color nodes by:" , width = 100 )
341
+ self .nodes_color_by = pn .widgets .Select (options = ['Select feature' ], name = "Color nodes by:" , width = 130 )
348
342
self .is_continuous = pn .widgets .Checkbox (name = 'Continuous feature' , value = False )
349
343
self .nodes_colormap = pn .widgets .ColorMap (name = "Select colormap for nodes:" ,
350
344
options = config .categorical_colormap_dict ,
351
- value = config .categorical_colormap_dict ['cet_glasbey' ])
345
+ value = config .categorical_colormap_dict ['Glasbey' ])
346
+ self .custom_colormap_input = pn .widgets .TextInput (name = 'Custom colormap: enter a list of colors separated by '
347
+ 'comma:' ,
348
+ placeholder = 'color1, color2, color3, etc...' ,
349
+ disabled = pn .bind (change_disabled_state_custom_colormap ,
350
+ value = self .nodes_colormap ,
351
+ watch = True )
352
+ )
352
353
self .edges_color_by = pn .widgets .Select (options = ['Select feature' ],
353
354
name = "Color edges by:" , width = 100 ,
354
355
disabled = pn .bind (change_disabled_state_inverse ,
@@ -532,6 +533,7 @@ def init_parameters(self):
532
533
self .nodes_color_by .param .unwatch (self .nodes_colorby_watcher )
533
534
self .is_continuous .param .unwatch (self .continuous_watcher )
534
535
self .nodes_colormap .param .unwatch (self .colormap_watcher )
536
+ self .custom_colormap_input .param .unwatch (self .custom_colormap_watcher )
535
537
self .box_plot_feature_select .param .unwatch (self .feature_select_watcher )
536
538
self .genomes_select .param .unwatch (self .genomes_select_watcher )
537
539
self .genomes_sort_select .param .unwatch (self .genomes_sort_select_watcher )
@@ -1057,11 +1059,12 @@ def create_single_genome_plots_by_APSS(self, event):
1057
1059
if self .is_metadata :
1058
1060
self .is_continuous .param .unwatch (self .continuous_watcher )
1059
1061
self .nodes_colormap .param .unwatch (self .colormap_watcher )
1062
+ self .custom_colormap_input .param .unwatch (self .custom_colormap_watcher )
1060
1063
self .nodes_color_by .param .unwatch (self .nodes_colorby_watcher )
1061
1064
self .network_threshold_input .value = config .APSS_connections_threshold_default
1062
1065
self .is_continuous .value = False
1063
1066
self .nodes_colormap .options = config .categorical_colormap_dict
1064
- self .nodes_colormap .value = config .categorical_colormap_dict ['cet_glasbey ' ]
1067
+ self .nodes_colormap .value = config .categorical_colormap_dict ['Glasbey ' ]
1065
1068
1066
1069
# Check if the requested genome and size have already been calculated. If so, fetch the specific dataframe
1067
1070
if self .calculated_APSS_genome_size_dict [self .sampling_size ]:
@@ -1408,18 +1411,22 @@ def change_continuous_state(self, event):
1408
1411
# Feature is indeed really continuous
1409
1412
else :
1410
1413
self .nodes_colormap .options = config .continuous_colormap_dict
1411
- self .nodes_colormap .value = config .continuous_colormap_dict ['cet_rainbow4 ' ]
1414
+ self .nodes_colormap .value = config .continuous_colormap_dict ['Rainbow4 ' ]
1412
1415
1413
1416
# Categorical feature
1414
1417
else :
1415
1418
#print("\nIn change_continuous_state. Categorical feature")
1416
1419
self .nodes_colormap .options = config .categorical_colormap_dict
1417
- self .nodes_colormap .value = config .categorical_colormap_dict ['cet_glasbey ' ]
1420
+ self .nodes_colormap .value = config .categorical_colormap_dict ['Glasbey ' ]
1418
1421
1419
1422
def change_colormap (self , event ):
1420
1423
#print("\nIn change_colormap. Continuous state = " + str(self.is_continuous.value))
1421
1424
self .update_network_plot ()
1422
1425
1426
+ def get_custom_colormap (self , event ):
1427
+ #print("\nIn change_colormap. Continuous state = " + str(self.is_continuous.value))
1428
+ self .update_network_plot ()
1429
+
1423
1430
def set_not_continuous (self , event ):
1424
1431
#print("\nIn set_not_continuous")
1425
1432
self .is_continuous .value = False
@@ -1438,6 +1445,7 @@ def create_network_pane(self, selected_genome_and_size_avg_df):
1438
1445
self .network_between_color )
1439
1446
metadata_coloring_col = pn .Column (nodes_color_by_row ,
1440
1447
self .nodes_colormap ,
1448
+ self .custom_colormap_input ,
1441
1449
pn .Spacer (height = 10 ),
1442
1450
self .color_edges_by_feature ,
1443
1451
edges_color_by_row ,
@@ -1580,6 +1588,8 @@ def create_network_pane(self, selected_genome_and_size_avg_df):
1580
1588
onlychanged = True )
1581
1589
self .colormap_watcher = self .nodes_colormap .param .watch (self .change_colormap , 'value' ,
1582
1590
onlychanged = True )
1591
+ self .custom_colormap_watcher = self .custom_colormap_input .param .watch (self .get_custom_colormap ,
1592
+ 'value' , onlychanged = True )
1583
1593
1584
1594
# Insert the features information as nodes attributes
1585
1595
for node in self .nodes_list :
@@ -1602,7 +1612,9 @@ def create_network_pane(self, selected_genome_and_size_avg_df):
1602
1612
is_metadata = self .use_metadata_network ,
1603
1613
nodes_feature = self .nodes_color_by .value ,
1604
1614
is_continuous = self .is_continuous .value ,
1605
- cmap = self .nodes_colormap .value , node_color = self .network_node_color ,
1615
+ cmap = self .nodes_colormap .value ,
1616
+ custom_cmap = self .custom_colormap_input .value ,
1617
+ node_color = self .network_node_color ,
1606
1618
edge_color = self .network_edge_color ,
1607
1619
is_edge_colorby = self .color_edges_by_feature ,
1608
1620
edges_feature = self .edges_color_by ,
@@ -1654,7 +1666,9 @@ def download_network(self, event):
1654
1666
is_metadata = self .use_metadata_network ,
1655
1667
nodes_feature = self .nodes_color_by .value ,
1656
1668
is_continuous = self .is_continuous .value ,
1657
- cmap = self .nodes_colormap .value_name , node_color = self .network_node_color ,
1669
+ cmap = self .nodes_colormap .value_name ,
1670
+ custom_cmap = self .custom_colormap_input .value ,
1671
+ node_color = self .network_node_color ,
1658
1672
edge_color = self .network_edge_color ,
1659
1673
is_edge_colorby = self .color_edges_by_feature ,
1660
1674
edges_feature = self .edges_color_by ,
@@ -1785,6 +1799,7 @@ def update_network_plot(self):
1785
1799
self .network_plot_hv = pn .bind (ps .cretae_network_plot , network = self .network ,
1786
1800
is_metadata = self .use_metadata_network , nodes_feature = self .nodes_color_by .value ,
1787
1801
is_continuous = self .is_continuous .value , cmap = self .nodes_colormap .value ,
1802
+ custom_cmap = self .custom_colormap_input .value ,
1788
1803
node_color = self .network_node_color , edge_color = self .network_edge_color ,
1789
1804
is_edge_colorby = self .color_edges_by_feature , edges_feature = self .edges_color_by ,
1790
1805
within_edge_color = self .network_within_color ,
0 commit comments