Skip to content

Commit

Permalink
Fix incorrect chord links calc from table (#75)
Browse files Browse the repository at this point in the history
Fix to calc correct chord links for similar `from` & `to` label table
  • Loading branch information
moshi4 committed Sep 20, 2024
1 parent 9359f9c commit 41ade23
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/pycirclize/circos.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,10 @@ def initialize_from_matrix(
outer_track.xticks_by_interval(ticks_interval, **ticks_kws)

# Plot links
fromto_label2color = {f"{t[0]}{t[1]}": t[2] for t in link_cmap}
fromto_label2color = {f"{t[0]}--->{t[1]}": t[2] for t in link_cmap}
for link in matrix.to_links():
from_label, to_label = link[0][0], link[1][0]
fromto_label = f"{from_label}{to_label}"
fromto_label = f"{from_label}--->{to_label}"
# Set link color
if fromto_label in fromto_label2color:
color = fromto_label2color[fromto_label]
Expand Down
4 changes: 2 additions & 2 deletions src/pycirclize/parser/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def parse_fromto_table(
for row in fromto_table.itertuples():
from_label, to_label, value = str(row[1]), str(row[2]), row[3]
if float(value) > 0:
fromto = f"{from_label}{to_label}"
fromto = f"{from_label}-->{to_label}"
fromto2value[fromto] = value
label2value_sum[from_label] += value
label2value_sum[to_label] += value
Expand Down Expand Up @@ -134,7 +134,7 @@ def parse_fromto_table(
for row_label in all_labels:
row_data = []
for col_label in all_labels:
row_data.append(fromto2value[f"{row_label}{col_label}"])
row_data.append(fromto2value[f"{row_label}-->{col_label}"])
matrix_data.append(row_data)
matrix_df = pd.DataFrame(matrix_data, index=all_labels, columns=all_labels)

Expand Down

0 comments on commit 41ade23

Please sign in to comment.