-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
JSON does not support serializing values of "infinity". Trying to do so results in errors on the client, server, or both.
When a GWAS file has a value of infinity in these columns, plots of that region fail to render with a 500 Internal Server Error (see screenshot) because the backend json serializer fails.
Proposed fix
We already special-case serialization of these values for the neg_log_pvalue field. Similar treatment of beta and stderr_beta should alleviate this error. This should be tested on a real dataset, in case there are follow on problems (UI etc) when displaying plot tooltips with inf values.
locuszoom-hosted/locuszoom_plotting_service/api/serializers.py
Lines 46 to 61 in d726fb2
| beta = drf_serializers.FloatField(read_only=True) | |
| se = drf_serializers.FloatField(source='stderr_beta', read_only=True) | |
| alt_allele_freq = drf_serializers.FloatField(read_only=True) | |
| def get_neg_log_pvalue(self, row): | |
| """ | |
| Many GWAS programs suffer from underflow and may represent small p=0/-logp=inf | |
| The JSON standard can't handle "Infinity", but the string 'Infinity' can be type-coerced by JS, eg +value | |
| Therefore we serialize this as a special case so it can be used in the frontend | |
| """ | |
| value = row.neg_log_pvalue | |
| if value is not None and math.isinf(value): | |
| return 'Infinity' | |
| else: | |
| return value |
We've seen several reports of this problem recently, after a long period of none. It's possible that a new GWAS program has been released that is prone to under/overflow, which might make this a higher priority for users in the future.
