diff --git a/malariagen_data/anoph/sample_metadata.py b/malariagen_data/anoph/sample_metadata.py index c69d87038..13aeec13a 100644 --- a/malariagen_data/anoph/sample_metadata.py +++ b/malariagen_data/anoph/sample_metadata.py @@ -971,6 +971,8 @@ def plot_samples_interactive_map( fill_value=0, ) + taxa = df_pivot.columns.dropna().sort_values().unique() + # Append aggregations to pivot. df_location_aggs = df_samples.groupby(location_composite_key).agg( { @@ -1015,7 +1017,6 @@ def plot_samples_interactive_map( samples_map.layout.width = width # Add markers. - count_factors = df_samples[count_by].dropna().sort_values().unique() for _, row in df_pivot.reset_index().iterrows(): title = ( f"Location: {row.location} ({row.latitude:.3f}, {row.longitude:.3f})" @@ -1028,13 +1029,13 @@ def plot_samples_interactive_map( title += f"\nContributors: {row.contributor}" title += "\nNo. specimens: " all_n = 0 - for factor in count_factors: + for taxon in taxa: # Get the number of samples in this taxon - n = row[factor] + n = int(row[taxon]) # Count the number of samples in all taxa all_n += n if n > 0: - title += f"{n} {factor}; " + title += f"{n} {taxon}; " # Only show a marker when there are enough samples if all_n >= min_samples: marker = ipyleaflet.Marker(