Skip to content

Internal server (500) errors for datasets with "inf" values for Beta or std_err_beta  #47

@abought

Description

@abought

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.

Screen Shot 2024-02-22 at 4 15 01 PM

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.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions