statgen / locuszoom-api

Flask server code for LocusZoom APIs
https://portaldev.sph.umich.edu/docs/api/v1/
1 stars 3 forks source link

Assoc API endpoint returns DB columns instead of field names for empty region #19

Closed abought closed 6 years ago

abought commented 6 years ago

Description

The API response payload from the AssociationLZ endpoint is subtly different if no data can be returned. Specifically, it has different (or excluded) fields. At first glance, the alternative field names resemble the underlying database column identifiers.

This causes LocusZoom demo plots to break when encountering a region with no data, because it cannot find the expected columns at all.

screen shot 2018-04-12 at 9 36 44 pm

Estimated impact

Base behavior

Low impact. Fortunately our internal datasets are quite rich, and this scenario is rarely encountered in demos.

The main impact is for anyone using our API as a reference implementation for custom LZ plots. For example, the Broad encountered the same error until they standardized their API responses.

Side effects

Looking at the code, variant_name appears to be the raw database column name. The bug may affect other things that use shared code; worth a look in the future.

Sample cases

A query for a region in which data is present. Note the presence of an array field, "variant". https://portaldev.sph.umich.edu/api/v1/statistic/single/results/?filter=analysis%20in%2045%20and%20chromosome%20in%20%20%272%27%20and%20position%20ge%20242000000%20and%20position%20le%20242005000

screen shot 2018-04-12 at 9 27 31 pm

Compare to a query from a narrower region (which substantially overlaps the above) in which no data is available. https://portaldev.sph.umich.edu/api/v1/statistic/single/results/?filter=analysis%20in%2045%20and%20chromosome%20in%20%20%272%27%20and%20position%20ge%20242023897%20and%20position%20le%20242025881

screen shot 2018-04-12 at 9 29 41 pm