Skip to content

Commit f088d49

Browse files
committed
MLR lineage fitness: Save missing values as null rather than NaN
Explicitly set these entries as Python None rather than the NaN that Pandas wants to do. Then the resulting JSON gets values of `null` rather than `NaN`.
1 parent 904fdde commit f088d49

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

scripts/fetch_mlr_lineage_fitness.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
importjson
33
importpandasaspd
44
importrequests
5-
importmath
65
importsys
76
fromaugur.ioimportread_metadata
87
fromaugur.utilsimportwrite_json
@@ -30,7 +29,7 @@ def fetch_growth_advantages(mlr_url):
3029
growth_advantages[entry["variant"]] =entry["value"]
3130
returngrowth_advantages
3231
exceptExceptionase:
33-
print(f"Error fetching the JSON file: {e}")
32+
print(f"Error fetching the JSON file: {e}", file=sys.stderr)
3433
returnNone
3534

3635
defmain():
@@ -60,13 +59,13 @@ def main():
6059
ifgrowth_advantages:
6160
metadata[args.metadata_clade_attribute] =metadata[args.metadata_clade_attribute].map(growth_advantages)
6261
else:
63-
metadata[args.metadata_clade_attribute] =math.nan
62+
metadata[args.metadata_clade_attribute] =None
6463

6564
# Create a node data object with growth advantages
6665
node_data= {}
6766
forindex, recordinmetadata.iterrows():
6867
node_data[index] = {
69-
"mlr_lineage_fitness": record[args.metadata_clade_attribute]
68+
"mlr_lineage_fitness": record[args.metadata_clade_attribute]ifpd.notna(record[args.metadata_clade_attribute]) elseNone
7069
}
7170

7271
# Save node data

0 commit comments

Comments
 (0)
close