Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
abought opened this issue Feb 22, 2024 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@abought
Copy link
Member

abought commented Feb 22, 2024

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.

@abought abought added bug Something isn't working help wanted Extra attention is needed labels Feb 22, 2024
@abought abought changed the title 500 errors for datasets with "inf" values for Beta or std_err_beta Internal server (500) errors for datasets with "inf" values for Beta or std_err_beta Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant