From 1613f83c2d6e82eb2613a70a67dd1d14904bd851 Mon Sep 17 00:00:00 2001 From: Jon Brenas Date: Wed, 1 Apr 2026 18:16:11 +0100 Subject: [PATCH 1/4] Use the pivot table directly for taxa --- malariagen_data/anoph/sample_metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/malariagen_data/anoph/sample_metadata.py b/malariagen_data/anoph/sample_metadata.py index c69d87038..ef66025f6 100644 --- a/malariagen_data/anoph/sample_metadata.py +++ b/malariagen_data/anoph/sample_metadata.py @@ -1015,7 +1015,7 @@ def plot_samples_interactive_map( samples_map.layout.width = width # Add markers. - count_factors = df_samples[count_by].dropna().sort_values().unique() + count_factors = df_pivot.columns.dropna().sort_values().unique() for _, row in df_pivot.reset_index().iterrows(): title = ( f"Location: {row.location} ({row.latitude:.3f}, {row.longitude:.3f})" From c68701b9af72f4c325dc1652aaaf2c49a64d91ee Mon Sep 17 00:00:00 2001 From: Jon Brenas Date: Wed, 1 Apr 2026 19:02:28 +0100 Subject: [PATCH 2/4] Trying to sort out types --- malariagen_data/anoph/sample_metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/malariagen_data/anoph/sample_metadata.py b/malariagen_data/anoph/sample_metadata.py index ef66025f6..fa53cc653 100644 --- a/malariagen_data/anoph/sample_metadata.py +++ b/malariagen_data/anoph/sample_metadata.py @@ -1030,7 +1030,7 @@ def plot_samples_interactive_map( all_n = 0 for factor in count_factors: # Get the number of samples in this taxon - n = row[factor] + n = int(row[factor]) # Count the number of samples in all taxa all_n += n if n > 0: From 67d56678830a57e283e6973d8090cb96846f4b52 Mon Sep 17 00:00:00 2001 From: Jon Brenas Date: Wed, 1 Apr 2026 19:48:47 +0100 Subject: [PATCH 3/4] Removed the other columns --- malariagen_data/anoph/sample_metadata.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/malariagen_data/anoph/sample_metadata.py b/malariagen_data/anoph/sample_metadata.py index fa53cc653..56f38f7f2 100644 --- a/malariagen_data/anoph/sample_metadata.py +++ b/malariagen_data/anoph/sample_metadata.py @@ -1015,7 +1015,11 @@ def plot_samples_interactive_map( samples_map.layout.width = width # Add markers. - count_factors = df_pivot.columns.dropna().sort_values().unique() + taxa = [ + c + for c in df_pivot.columns.dropna().sort_values().unique() + if c not in ["year", "sample_set", "contributor"] + ] for _, row in df_pivot.reset_index().iterrows(): title = ( f"Location: {row.location} ({row.latitude:.3f}, {row.longitude:.3f})" @@ -1028,13 +1032,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 = int(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( From 95d0c3a0de8e50b2b0403e52f79d8e245350fed2 Mon Sep 17 00:00:00 2001 From: Jon Brenas Date: Thu, 2 Apr 2026 18:06:38 +0100 Subject: [PATCH 4/4] Moved the taxa thing --- malariagen_data/anoph/sample_metadata.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/malariagen_data/anoph/sample_metadata.py b/malariagen_data/anoph/sample_metadata.py index 56f38f7f2..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,11 +1017,6 @@ def plot_samples_interactive_map( samples_map.layout.width = width # Add markers. - taxa = [ - c - for c in df_pivot.columns.dropna().sort_values().unique() - if c not in ["year", "sample_set", "contributor"] - ] for _, row in df_pivot.reset_index().iterrows(): title = ( f"Location: {row.location} ({row.latitude:.3f}, {row.longitude:.3f})"