@@ -2260,16 +2260,16 @@ def plot_haplotype_network(
22602260 )
22612261
22622262 # Now use the validated color_column for processing
2263- df_haps ["partition " ] = (
2263+ df_haps ["_partition " ] = (
22642264 df_haps [color_column ]
22652265 .astype (str )
22662266 .str .replace (r"\W" , "" , regex = True )
22672267 )
22682268
22692269 # extract all unique values of the color column
2270- color_values = df_haps ["partition " ].fillna ("<NA>" ).unique ()
2270+ color_values = df_haps ["_partition " ].fillna ("<NA>" ).unique ()
22712271 color_values_mapping = dict (
2272- zip (df_haps ["partition " ], df_haps [color_column ])
2272+ zip (df_haps ["_partition " ], df_haps [color_column ])
22732273 )
22742274 color_values_mapping ["<NA>" ] = "black"
22752275 color_values_display = [
@@ -2280,25 +2280,25 @@ def plot_haplotype_network(
22802280 elif isinstance (color , Mapping ):
22812281 # For mapping case, we need to create a new column based on the mapping
22822282 # Initialize with None
2283- df_haps ["partition " ] = None
2283+ df_haps ["_partition " ] = None
22842284
2285- # Apply each query in the mapping to create the partition column
2285+ # Apply each query in the mapping to create the _partition column
22862286 for label , query in color .items ():
22872287 # Apply the query and assign the label to matching rows
22882288 mask = df_haps .eval (query )
2289- df_haps .loc [mask , "partition " ] = label
2289+ df_haps .loc [mask , "_partition " ] = label
22902290
2291- # Clean up the partition column to avoid issues with special characters
2292- if df_haps ["partition " ].notna ().any ():
2293- df_haps ["partition " ] = df_haps ["partition " ].str .replace (
2291+ # Clean up the _partition column to avoid issues with special characters
2292+ if df_haps ["_partition " ].notna ().any ():
2293+ df_haps ["_partition " ] = df_haps ["_partition " ].str .replace (
22942294 r"\W" , "" , regex = True
22952295 )
22962296
22972297 # extract all unique values of the color column
2298- color_values = df_haps ["partition " ].fillna ("<NA>" ).unique ()
2299- # For mapping case, use partition values directly as they're already the labels
2298+ color_values = df_haps ["_partition " ].fillna ("<NA>" ).unique ()
2299+ # For mapping case, use _partition values directly as they're already the labels
23002300 color_values_mapping = dict (
2301- zip (df_haps ["partition " ], df_haps ["partition " ])
2301+ zip (df_haps ["_partition " ], df_haps ["_partition " ])
23022302 )
23032303 color_values_mapping ["<NA>" ] = "black"
23042304 color_values_display = [
@@ -2312,7 +2312,7 @@ def plot_haplotype_network(
23122312
23132313 # count color values for each distinct haplotype (same for both string and mapping cases)
23142314 ht_color_counts = [
2315- df_haps .iloc [list (s )]["partition " ].value_counts ().to_dict ()
2315+ df_haps .iloc [list (s )]["_partition " ].value_counts ().to_dict ()
23162316 for s in ht_distinct_sets
23172317 ]
23182318
@@ -2323,7 +2323,7 @@ def plot_haplotype_network(
23232323 category_orders_prepped ,
23242324 ) = self ._setup_sample_colors_plotly (
23252325 data = df_haps ,
2326- color = "partition " ,
2326+ color = "_partition " ,
23272327 color_discrete_map = color_discrete_map ,
23282328 color_discrete_sequence = color_discrete_sequence ,
23292329 category_orders = category_orders ,
@@ -2343,7 +2343,7 @@ def plot_haplotype_network(
23432343 ht_distinct_mjn = ht_distinct_mjn ,
23442344 ht_counts = ht_counts ,
23452345 ht_color_counts = ht_color_counts ,
2346- color = "partition " if color is not None else None ,
2346+ color = "_partition " if color is not None else None ,
23472347 color_values = color_values ,
23482348 edges = edges ,
23492349 alt_edges = alt_edges ,
@@ -2395,7 +2395,7 @@ def plot_haplotype_network(
23952395 debug ("create figure legend" )
23962396 if color is not None :
23972397 legend_fig = plotly_discrete_legend (
2398- color = "partition " , # Changed from color=color
2398+ color = "_partition " , # Changed from color=color
23992399 color_values = color_values_display ,
24002400 color_discrete_map = color_discrete_map_display ,
24012401 category_orders = category_orders_prepped ,
0 commit comments