Skip to content

Commit

Permalink
consistent color for NA
Browse files Browse the repository at this point in the history
  • Loading branch information
alimanfoo committed Oct 17, 2024
1 parent e8edd41 commit c3ff849
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions malariagen_data/anoph/sample_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,9 @@ def _setup_sample_symbol(
data.loc[data.query(value).index, "symbol"] = key
symbol_prepped = "symbol"

# Handle missing data in a consistent way.
data[symbol_prepped].fillna("<NA>", inplace=True)

return symbol_prepped

def _setup_sample_colors_plotly(
Expand Down Expand Up @@ -1016,9 +1019,11 @@ def _setup_sample_colors_plotly(
# Finish handling of color parameter.
del color

# Handle missing data in a consistent way.
data[color_prepped].fillna("<NA>", inplace=True)

# Obtain the values that we will be mapping to colors.
color_data_values = data[color_prepped].dropna()
color_data_unique_values = color_data_values.unique()
color_data_unique_values = data[color_prepped].unique()

# Now set up color choices.
if color_discrete_map is None:
Expand All @@ -1040,6 +1045,9 @@ def _setup_sample_colors_plotly(
else:
color_discrete_map_prepped = color_discrete_map

# Consistent color for missing data.
color_discrete_map_prepped["<NA>"] = "black"

# Finished handling of color map params.
del color_discrete_map
del color_discrete_sequence
Expand Down

0 comments on commit c3ff849

Please sign in to comment.