@@ -91,7 +91,7 @@ def create_clustermap(matrix, cmap, is_metadata, feature, cmap_metadata, custom_
91
91
col_num = len (matrix .columns )
92
92
mask_array = np .full ((col_num , col_num ), np .where (matrix == 100 , True , False ))
93
93
94
- print ("\n create_clustermap: selected cmap: " + cmap )
94
+ # print("\ncreate_clustermap: selected cmap: " + cmap)
95
95
colmap = plt .get_cmap (cmap )
96
96
colmap .set_bad ("lightgrey" )
97
97
@@ -105,15 +105,15 @@ def create_clustermap(matrix, cmap, is_metadata, feature, cmap_metadata, custom_
105
105
if 'nan' in unique_groups :
106
106
unique_groups .remove ('nan' )
107
107
unique_groups .append ('nan' )
108
- print (unique_groups )
108
+ # print(unique_groups)
109
109
110
110
# If the user defined a custom cmap - process it and turn it into a cmap
111
111
if cmap_metadata == 'Define custom colormap' :
112
112
custom_colors_list = custom_cmap
113
113
cmap_metadata_mpl = re .split (r'\s*,\s*' , custom_colors_list )
114
114
cmap_length = len (cmap_metadata_mpl )
115
- print ("Custom cmap:" )
116
- print (cmap_metadata_mpl )
115
+ # print("Custom cmap:")
116
+ # print(cmap_metadata_mpl)
117
117
118
118
# Assign each group with a color, according to the colormap order
119
119
group_to_color = {group : cmap_metadata_mpl [i % cmap_length ] for i , group in enumerate (unique_groups )}
@@ -126,12 +126,12 @@ def create_clustermap(matrix, cmap, is_metadata, feature, cmap_metadata, custom_
126
126
# Assign each group with a color, according to the colormap order
127
127
group_to_color = {group : cmap_metadata_mpl (i % cmap_length ) for i , group in enumerate (unique_groups )}
128
128
129
- print ("cmap length: " + str (cmap_length ))
129
+ # print("cmap length: " + str(cmap_length))
130
130
131
131
# Create a colors dataframe, with sample names as indices
132
132
colors = [group_to_color [str (metadata_dict [feature ][sample ])] for sample in matrix .iloc [:, 0 ].index ]
133
133
colors_df = pd .DataFrame ({feature : colors }, index = matrix .index )
134
- print (colors_df )
134
+ # print(colors_df)
135
135
136
136
clustermap = sns .clustermap (matrix , cmap = colmap , row_cluster = True , linewidths = .5 ,
137
137
cbar_pos = (0.04 , 0.82 , 0.02 , 0.15 ), xticklabels = 1 , yticklabels = 1 ,
@@ -196,7 +196,7 @@ def cretae_network_plot(network, is_metadata, nodes_feature, is_continuous, cmap
196
196
is_edge_colorby , edges_feature , within_edge_color , between_edge_color , iterations , pos_dict ,
197
197
show_labels , metadata_dict ):
198
198
iter_num = int (iterations )
199
- print ("\n In cretae_network_plot.\n Iterations number = " + str (iter_num ) + "\n Feature: " + nodes_feature )
199
+ # print("\nIn cretae_network_plot.\nIterations number = " + str(iter_num) + "\nFeature: " + nodes_feature)
200
200
201
201
pos = nx .layout .fruchterman_reingold_layout (network , iterations = iter_num , pos = pos_dict , k = 2 )
202
202
@@ -221,7 +221,7 @@ def cretae_network_plot(network, is_metadata, nodes_feature, is_continuous, cmap
221
221
222
222
# In case of numeric continuous feature:
223
223
if is_continuous :
224
- print ("Continuous feature" )
224
+ # print("Continuous feature")
225
225
226
226
# Step 1: Extract non-missing values (only if the values are not strings)
227
227
non_missing_values = [network .nodes [node ][nodes_feature ] for node in network .nodes
@@ -230,8 +230,8 @@ def cretae_network_plot(network, is_metadata, nodes_feature, is_continuous, cmap
230
230
# Step 2: Define min and max values based only on non-missing values
231
231
min_value = min (non_missing_values )
232
232
max_value = max (non_missing_values )
233
- print ("Min value: " + str (min_value ))
234
- print ("Max value: " + str (max_value ))
233
+ # print("Min value: " + str(min_value))
234
+ # print("Max value: " + str(max_value))
235
235
236
236
# Step 3: Create a colormap for non-missing values and normalize
237
237
cmap = cmap
@@ -253,7 +253,7 @@ def cretae_network_plot(network, is_metadata, nodes_feature, is_continuous, cmap
253
253
254
254
# Feature is categorical
255
255
else :
256
- print ("Categorical feature" )
256
+ # print("Categorical feature")
257
257
258
258
# Prepare the colors mapping for the legend
259
259
unique_groups = sorted (list (set ([str (network .nodes [node ][nodes_feature ]) for node in network .nodes ()])))
@@ -262,19 +262,19 @@ def cretae_network_plot(network, is_metadata, nodes_feature, is_continuous, cmap
262
262
if 'nan' in unique_groups :
263
263
unique_groups .remove ('nan' )
264
264
unique_groups .append ('nan' )
265
- print (unique_groups )
265
+ # print(unique_groups)
266
266
267
267
cmap_length = len (cmap )
268
- print ("Cmap length = " + str (cmap_length ))
268
+ # print("Cmap length = " + str(cmap_length))
269
269
270
270
# If the user defined a custom cmap - process it and turn it into a cmap
271
271
if cmap_length == 1 :
272
272
custom_colors_list = custom_cmap
273
273
cmap = re .split (r'\s*,\s*' , custom_colors_list )
274
274
cmap_length = len (cmap )
275
- print ("Custom cmap:" )
276
- print (cmap )
277
- print ("custom cmap length: " + str (cmap_length ))
275
+ # print("Custom cmap:")
276
+ # print(cmap)
277
+ # print("custom cmap length: " + str(cmap_length))
278
278
279
279
group_to_color = {group : cmap [i % cmap_length ] for i , group in enumerate (unique_groups )}
280
280
colors = [group_to_color [str (network .nodes [node ][nodes_feature ])] for node in network .nodes ()]
@@ -334,8 +334,8 @@ def cretae_network_plot_matplotlib(network, is_metadata, nodes_feature, is_conti
334
334
edge_color , is_edge_colorby , edges_feature , within_edge_color , between_edge_color ,
335
335
iterations , pos_dict , show_labels , metadata_dict ):
336
336
iter_num = int (iterations )
337
- print ("\n In cretae_network_plot_matplotlib. Iterations number = " + str (iter_num ))
338
- print ("cmap: " + str (cmap ))
337
+ # print("\nIn cretae_network_plot_matplotlib. Iterations number = " + str(iter_num))
338
+ # print("cmap: " + str(cmap))
339
339
340
340
# Preparing network drawing also with matplotlib for better image production
341
341
fig , ax1 = plt .subplots (figsize = (8 , 7 ))
@@ -361,7 +361,7 @@ def cretae_network_plot_matplotlib(network, is_metadata, nodes_feature, is_conti
361
361
362
362
# In case of numeric continuous feature:
363
363
if is_continuous :
364
- print ("Continuous feature" )
364
+ # print("Continuous feature")
365
365
366
366
# Extract non-missing values
367
367
non_missing_values = [network .nodes [node ][nodes_feature ] for node in network .nodes
@@ -370,8 +370,8 @@ def cretae_network_plot_matplotlib(network, is_metadata, nodes_feature, is_conti
370
370
# Define min and max values based only on non-missing values
371
371
min_value = min (non_missing_values )
372
372
max_value = max (non_missing_values )
373
- print ("Min value: " + str (min_value ))
374
- print ("Max value: " + str (max_value ))
373
+ # print("Min value: " + str(min_value))
374
+ # print("Max value: " + str(max_value))
375
375
376
376
nodes_feature_array = np .array ([network .nodes [node ][nodes_feature ] for node in network .nodes ()])
377
377
normalized_values = (nodes_feature_array - min_value ) / (max_value - min_value )
@@ -421,15 +421,15 @@ def cretae_network_plot_matplotlib(network, is_metadata, nodes_feature, is_conti
421
421
if 'nan' in unique_groups :
422
422
unique_groups .remove ('nan' )
423
423
unique_groups .append ('nan' )
424
- print (unique_groups )
424
+ # print(unique_groups)
425
425
426
426
# If the user defined a custom cmap - process it and turn it into a cmap
427
427
if cmap == 'Define custom colormap' :
428
428
custom_colors_list = custom_cmap
429
429
cmap_mpl = re .split (r'\s*,\s*' , custom_colors_list )
430
430
cmap_length = len (cmap_mpl )
431
- print ("Custom cmap:" )
432
- print (cmap_mpl )
431
+ # print("Custom cmap:")
432
+ # print(cmap_mpl)
433
433
434
434
# Assign each group with a color, according to the colormap order
435
435
group_to_color = {group : cmap_mpl [i % cmap_length ] for i , group in enumerate (unique_groups )}
@@ -440,7 +440,7 @@ def cretae_network_plot_matplotlib(network, is_metadata, nodes_feature, is_conti
440
440
# Assign each group with a color, according to the colormap order
441
441
group_to_color = {group : cmap_mpl (i % cmap_length ) for i , group in enumerate (unique_groups )}
442
442
443
- print ("cmap length: " + str (cmap_length ))
443
+ # print("cmap length: " + str(cmap_length))
444
444
445
445
# Get a list of colors for all the nodes
446
446
colors = [group_to_color [str (network .nodes [node ][nodes_feature ])] for node in network .nodes ()]
0 commit comments