Skip to content

Commit ee3f144

Browse files
refactor: use private column name '_partition' in plot_haplotype_network
1 parent 78e8a31 commit ee3f144

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

malariagen_data/anopheles.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,18 +2240,15 @@ def plot_haplotype_network(
22402240
color_discrete_map_display = None
22412241
ht_color_counts = None
22422242
if color is not None:
2243-
# sanitise color column - necessary to avoid grey pie chart segments
2244-
df_haps["partition"] = df_haps[color].str.replace(r"\W", "", regex=True)
2245-
2246-
# extract all unique values of the color column
2247-
color_values = df_haps["partition"].fillna("<NA>").unique()
2248-
color_values_mapping = dict(zip(df_haps["partition"], df_haps[color]))
2243+
df_haps["_partition"] = df_haps[color].str.replace(r"\\W", "", regex=True)
2244+
color_values = df_haps["_partition"].fillna("<NA>").unique()
2245+
color_values_mapping = dict(zip(df_haps["_partition"], df_haps[color]))
22492246
color_values_mapping["<NA>"] = "black"
22502247
color_values_display = [color_values_mapping[c] for c in color_values]
22512248

22522249
# count color values for each distinct haplotype
22532250
ht_color_counts = [
2254-
df_haps.iloc[list(s)]["partition"].value_counts().to_dict()
2251+
df_haps.iloc[list(s)]["_partition"].value_counts().to_dict()
22552252
for s in ht_distinct_sets
22562253
]
22572254

@@ -2262,7 +2259,7 @@ def plot_haplotype_network(
22622259
category_orders_prepped,
22632260
) = self._setup_sample_colors_plotly(
22642261
data=df_haps,
2265-
color="partition",
2262+
color="_partition",
22662263
color_discrete_map=color_discrete_map,
22672264
color_discrete_sequence=color_discrete_sequence,
22682265
category_orders=category_orders,

0 commit comments

Comments
 (0)