Skip to content

Commit 9fddd75

Browse files
committed
Version 1.0.6:
- Removed syncing query parameters 'input_file' and 'ref_genome' to the URL (it caused problems when reloading the page using CTRL-R). - Check if watchers exist before unwatching parameters (caused many warnings). - Removed unnecessary printouts
1 parent f451281 commit 9fddd75

File tree

4 files changed

+86
-96
lines changed

4 files changed

+86
-96
lines changed

SynTrackerVis_app/data_manipulation_multi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def complete_metadata(score_per_region_df, metadata_df):
4747
#new_row.append("NaN")
4848
metadata_df.loc[len(metadata_df)] = new_row
4949

50-
print("\nMetadata after filling missing samples:")
51-
print(metadata_df)
50+
#print("\nMetadata after filling missing samples:")
51+
#print(metadata_df)
5252

5353
# Go over the features
5454
for feature in metadata_features_list:

SynTrackerVis_app/data_manipulation_single.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,13 @@ def return_sorted_contigs_lists(score_per_region_df):
112112

113113
after = time.time()
114114
duration = after - before
115-
print("Extract position from region took " + str(duration) + " seconds.\n")
116-
117-
# Get a list of contigs, sorted by name
118-
# If the contig names contain numbers, sort them numerically
119-
#if re.search(r"^\S+_\d+$", score_per_region_df.iloc[0]['Contig_name']):
120-
121-
# Create a temporary column 'contigs_sort' to sort the contig names numericlly
122-
# score_per_region_df['Contig_number'] = score_per_region_df['Contig_name'].str.extract(r'\S+_(\d+)')\
123-
# .astype(int)
124-
125-
# contigs_list_by_name = list(score_per_region_df.sort_values('Contig_number').groupby(['Contig_name'],
126-
# sort=False).groups)
127-
128-
#else:
129-
# contigs_list_by_name = list(score_per_region_df.groupby(['Contig_name']).groups)
115+
#print("Extract position from region took " + str(duration) + " seconds.\n")
130116

131117
before = time.time()
132118
contigs_list_by_name = list(score_per_region_df.groupby(['Contig_name']).groups)
133119
after = time.time()
134120
duration = after - before
135-
print("Sort by name took " + str(duration) + " seconds.\n")
121+
#print("Sort by name took " + str(duration) + " seconds.\n")
136122

137123
# Get a list of contigs, sorted by length
138124
before = time.time()
@@ -141,7 +127,7 @@ def return_sorted_contigs_lists(score_per_region_df):
141127
groups)
142128
after = time.time()
143129
duration = after - before
144-
print("Sort by length took " + str(duration) + " seconds.\n")
130+
#print("Sort by length took " + str(duration) + " seconds.\n")
145131

146132
return contigs_list_by_name, contigs_list_by_length
147133

SynTrackerVis_app/plots_single_genome.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def create_clustermap(matrix, cmap, is_metadata, feature, cmap_metadata, custom_
9191
col_num = len(matrix.columns)
9292
mask_array = np.full((col_num, col_num), np.where(matrix == 100, True, False))
9393

94-
print("\ncreate_clustermap: selected cmap: " + cmap)
94+
#print("\ncreate_clustermap: selected cmap: " + cmap)
9595
colmap = plt.get_cmap(cmap)
9696
colmap.set_bad("lightgrey")
9797

@@ -105,15 +105,15 @@ def create_clustermap(matrix, cmap, is_metadata, feature, cmap_metadata, custom_
105105
if 'nan' in unique_groups:
106106
unique_groups.remove('nan')
107107
unique_groups.append('nan')
108-
print(unique_groups)
108+
#print(unique_groups)
109109

110110
# If the user defined a custom cmap - process it and turn it into a cmap
111111
if cmap_metadata == 'Define custom colormap':
112112
custom_colors_list = custom_cmap
113113
cmap_metadata_mpl = re.split(r'\s*,\s*', custom_colors_list)
114114
cmap_length = len(cmap_metadata_mpl)
115-
print("Custom cmap:")
116-
print(cmap_metadata_mpl)
115+
#print("Custom cmap:")
116+
#print(cmap_metadata_mpl)
117117

118118
# Assign each group with a color, according to the colormap order
119119
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_
126126
# Assign each group with a color, according to the colormap order
127127
group_to_color = {group: cmap_metadata_mpl(i % cmap_length) for i, group in enumerate(unique_groups)}
128128

129-
print("cmap length: " + str(cmap_length))
129+
#print("cmap length: " + str(cmap_length))
130130

131131
# Create a colors dataframe, with sample names as indices
132132
colors = [group_to_color[str(metadata_dict[feature][sample])] for sample in matrix.iloc[:, 0].index]
133133
colors_df = pd.DataFrame({feature: colors}, index=matrix.index)
134-
print(colors_df)
134+
#print(colors_df)
135135

136136
clustermap = sns.clustermap(matrix, cmap=colmap, row_cluster=True, linewidths=.5,
137137
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
196196
is_edge_colorby, edges_feature, within_edge_color, between_edge_color, iterations, pos_dict,
197197
show_labels, metadata_dict):
198198
iter_num = int(iterations)
199-
print("\nIn cretae_network_plot.\nIterations number = " + str(iter_num) + "\nFeature: " + nodes_feature)
199+
#print("\nIn cretae_network_plot.\nIterations number = " + str(iter_num) + "\nFeature: " + nodes_feature)
200200

201201
pos = nx.layout.fruchterman_reingold_layout(network, iterations=iter_num, pos=pos_dict, k=2)
202202

@@ -221,7 +221,7 @@ def cretae_network_plot(network, is_metadata, nodes_feature, is_continuous, cmap
221221

222222
# In case of numeric continuous feature:
223223
if is_continuous:
224-
print("Continuous feature")
224+
#print("Continuous feature")
225225

226226
# Step 1: Extract non-missing values (only if the values are not strings)
227227
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
230230
# Step 2: Define min and max values based only on non-missing values
231231
min_value = min(non_missing_values)
232232
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))
235235

236236
# Step 3: Create a colormap for non-missing values and normalize
237237
cmap = cmap
@@ -253,7 +253,7 @@ def cretae_network_plot(network, is_metadata, nodes_feature, is_continuous, cmap
253253

254254
# Feature is categorical
255255
else:
256-
print("Categorical feature")
256+
#print("Categorical feature")
257257

258258
# Prepare the colors mapping for the legend
259259
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
262262
if 'nan' in unique_groups:
263263
unique_groups.remove('nan')
264264
unique_groups.append('nan')
265-
print(unique_groups)
265+
#print(unique_groups)
266266

267267
cmap_length = len(cmap)
268-
print("Cmap length = " + str(cmap_length))
268+
#print("Cmap length = " + str(cmap_length))
269269

270270
# If the user defined a custom cmap - process it and turn it into a cmap
271271
if cmap_length == 1:
272272
custom_colors_list = custom_cmap
273273
cmap = re.split(r'\s*,\s*', custom_colors_list)
274274
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))
278278

279279
group_to_color = {group: cmap[i % cmap_length] for i, group in enumerate(unique_groups)}
280280
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
334334
edge_color, is_edge_colorby, edges_feature, within_edge_color, between_edge_color,
335335
iterations, pos_dict, show_labels, metadata_dict):
336336
iter_num = int(iterations)
337-
print("\nIn 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))
339339

340340
# Preparing network drawing also with matplotlib for better image production
341341
fig, ax1 = plt.subplots(figsize=(8, 7))
@@ -361,7 +361,7 @@ def cretae_network_plot_matplotlib(network, is_metadata, nodes_feature, is_conti
361361

362362
# In case of numeric continuous feature:
363363
if is_continuous:
364-
print("Continuous feature")
364+
#print("Continuous feature")
365365

366366
# Extract non-missing values
367367
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
370370
# Define min and max values based only on non-missing values
371371
min_value = min(non_missing_values)
372372
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))
375375

376376
nodes_feature_array = np.array([network.nodes[node][nodes_feature] for node in network.nodes()])
377377
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
421421
if 'nan' in unique_groups:
422422
unique_groups.remove('nan')
423423
unique_groups.append('nan')
424-
print(unique_groups)
424+
#print(unique_groups)
425425

426426
# If the user defined a custom cmap - process it and turn it into a cmap
427427
if cmap == 'Define custom colormap':
428428
custom_colors_list = custom_cmap
429429
cmap_mpl = re.split(r'\s*,\s*', custom_colors_list)
430430
cmap_length = len(cmap_mpl)
431-
print("Custom cmap:")
432-
print(cmap_mpl)
431+
#print("Custom cmap:")
432+
#print(cmap_mpl)
433433

434434
# Assign each group with a color, according to the colormap order
435435
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
440440
# Assign each group with a color, according to the colormap order
441441
group_to_color = {group: cmap_mpl(i % cmap_length) for i, group in enumerate(unique_groups)}
442442

443-
print("cmap length: " + str(cmap_length))
443+
#print("cmap length: " + str(cmap_length))
444444

445445
# Get a list of colors for all the nodes
446446
colors = [group_to_color[str(network.nodes[node][nodes_feature])] for node in network.nodes()]

0 commit comments

Comments
 (0)