Skip to content

Commit eb5bdaf

Browse files
authored
Merge pull request #1269 from malariagen/GH1268-plot_samples_interactive_maps_bug_on_colonies
Use the pivot table directly for taxa
2 parents 657b9bb + e7edb0f commit eb5bdaf

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

malariagen_data/anoph/sample_metadata.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,8 @@ def plot_samples_interactive_map(
971971
fill_value=0,
972972
)
973973

974+
taxa = df_pivot.columns.dropna().sort_values().unique()
975+
974976
# Append aggregations to pivot.
975977
df_location_aggs = df_samples.groupby(location_composite_key).agg(
976978
{
@@ -1015,7 +1017,6 @@ def plot_samples_interactive_map(
10151017
samples_map.layout.width = width
10161018

10171019
# Add markers.
1018-
count_factors = df_samples[count_by].dropna().sort_values().unique()
10191020
for _, row in df_pivot.reset_index().iterrows():
10201021
title = (
10211022
f"Location: {row.location} ({row.latitude:.3f}, {row.longitude:.3f})"
@@ -1028,13 +1029,13 @@ def plot_samples_interactive_map(
10281029
title += f"\nContributors: {row.contributor}"
10291030
title += "\nNo. specimens: "
10301031
all_n = 0
1031-
for factor in count_factors:
1032+
for taxon in taxa:
10321033
# Get the number of samples in this taxon
1033-
n = row[factor]
1034+
n = int(row[taxon])
10341035
# Count the number of samples in all taxa
10351036
all_n += n
10361037
if n > 0:
1037-
title += f"{n} {factor}; "
1038+
title += f"{n} {taxon}; "
10381039
# Only show a marker when there are enough samples
10391040
if all_n >= min_samples:
10401041
marker = ipyleaflet.Marker(

0 commit comments

Comments
 (0)